Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Jul 27, 2024
1 parent c2f4edb commit 659bb43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion scripts/compute-tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ if [[ $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
tags "${BASE_BUILD_IMAGE}:${MAJOR_MINOR_PATCH}"
tags "${BASE_BUILD_IMAGE}:${MAJOR_MINOR}"
tags "${BASE_BUILD_IMAGE}:${MAJOR}"
else
tags "${BASE_BUILD_IMAGE}:latest"
elif [[ $BRANCH != "main" ]]; then
tags "${BASE_BUILD_IMAGE}:latest"
fi

Expand Down
21 changes: 15 additions & 6 deletions scripts/compute-tags.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ out=""
expect() {
echo ' Actual:' "$out"
while [ "$#" -gt 0 ]; do
echo ' checking' "$1"
assertContains "actual !!$out!!" "$out" "--tag docker.io/$1"
assertContains "actual !!$out!!" "$out" "--tag quay.io/$1"
echo ' checking includes' "$1"
assertContains "actual [$out]" "$out" "--tag docker.io/$1"
assertContains "actual [$out]" "$out" "--tag quay.io/$1"
shift
done
}

expectNot() {
echo ' Actual:' "$out"
while [ "$#" -gt 0 ]; do
echo ' checking excludes' "$1"
assertNotContains "actual [$out]" "$out" "--tag docker.io/$1"
assertNotContains "actual [$out]" "$out" "--tag quay.io/$1"
shift
done
}
Expand All @@ -54,21 +64,20 @@ testRandomBranch() {

testMainBranch() {
out=$(BRANCH=main GITHUB_SHA=sha bash "$computeTags" foo/bar)
# TODO we do not want :latest tag in this scenario for non-snapshot images
expected=(
"foo/bar"
"foo/bar:latest"
"foo/bar-snapshot:sha"
"foo/bar-snapshot:latest"
)
expect "${expected[@]}"
expectNot "foo/bar:latest"
}

testSemVerBranch() {
out=$(BRANCH=v1.2.3 GITHUB_SHA=sha bash "$computeTags" foo/bar)
# TODO we want :latest tag in this scenario, it's currently not produced
expected=(
"foo/bar"
"foo/bar:latest"
"foo/bar:1"
"foo/bar:1.2"
"foo/bar:1.2.3"
Expand Down

0 comments on commit 659bb43

Please sign in to comment.