Skip to content

Commit

Permalink
test: fix chart.next version on release branches by removing semver bump
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
niladrih committed Oct 29, 2024
1 parent 69fbd21 commit bd072d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scripts/python/generate-test-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ done

case "$CHART_VERSION" in
0.0.0)
latest_branch=$(git fetch -q && latest_release_branch $GIT_REMOTE $ROOT_DIR)
latest_branch=$(git fetch -q && latest_release_branch "$GIT_REMOTE" "$ROOT_DIR")
latest=${latest_branch#release/}
if [[ "$latest" =~ ^([0-9]+\.[0-9]+)$ ]]; then
latest="$latest.0"
Expand All @@ -62,7 +62,7 @@ case "$CHART_VERSION" in
;;
*)
test "$(semver validate $CHART_VERSION)" = "valid"
TAG=$(semver bump patch $CHART_VERSION)
TAG=$CHART_VERSION
;;
esac

Expand Down
2 changes: 1 addition & 1 deletion scripts/python/tag-chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
CHART_VERSION=${1#v}
IMAGE_TAG="v$CHART_VERSION"
CHART_DIR="$ROOT_DIR/chart"
# TODO: tests should copy the chart and work with its own copy of the chart. Shouldn't modify the chart.
# TODO: tests should work with its own copy of the chart. Shouldn't modify the chart.
# chart/Chart.yaml
yq_ibl "
.version = \"$CHART_VERSION\" |
Expand Down
30 changes: 30 additions & 0 deletions scripts/utils/repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,33 @@ latest_release_branch() {

echo "${latest_release_branch#*$remote/}"
}

# Get the latest tag created against a commit of a specific branch
# Args:
# 1. Branch name
# 2. Git remote name
# 3. Root directory of the repository
latest_tag_at_branch() {
local -r branch=$1
local -r remote=${2:-"origin"}
local -r root_dir=${3:-"$ROOTDIR"}

pushd "$root_dir" > /dev/null

git fetch --quiet --tags "$remote"

local latest_tag=""
local git_tag_exit_code=0
local -r git_tag_output=$(git tag --list --merged "$remote"/"$branch" --sort=-creatordate 2> /dev/null) || git_tag_exit_code=$?
if [ "$git_tag_exit_code" = 0 ]; then
local head_exit_code=0
local -r head_output=$(echo $git_tag_output | head -n 1) || head_exit_code=$?
if [ "$head_exit_code" = 0 ]; then
latest_tag=$head_output
fi
fi

popd > /dev/null

echo "$latest_tag"
}

0 comments on commit bd072d3

Please sign in to comment.