Skip to content

Commit

Permalink
smoke-test: semver sort latest versions (#12229)
Browse files Browse the repository at this point in the history
Co-authored-by: kruskall <[email protected]>
  • Loading branch information
v1v and kruskall authored Dec 17, 2023
1 parent 040c836 commit 5158fea
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions testing/smoke/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ get_versions() {
local RC=0
RES=$(curl_fail -H "Authorization: ApiKey ${EC_API_KEY}" ${EC_VERSION_ENDPOINT}) || RC=$?
if [ $RC -ne 0 ]; then echo "${RES}"; fi
VERSIONS=$(echo "${RES}" | jq -r -c '[.stacks[].version | select(. | contains("-") | not)] | sort')
# NOTE: jq with semver requires some numeric transformation with sort_by
VERSIONS=$(echo "${RES}" | jq -r -c '[.stacks[].version | select(. | contains("-") | not)] | sort_by(.| split(".") | map(tonumber))')
}

get_latest_patch() {
Expand All @@ -38,7 +39,9 @@ get_latest_snapshot() {
local RC=0
RES=$(curl_fail -H "Authorization: ApiKey ${EC_API_KEY}" ${EC_VERSION_ENDPOINT}) || RC=$?
if [ $RC -ne 0 ]; then echo "${RES}"; fi
VERSIONS=$(echo "${RES}" | jq -r -c '[.stacks[].version | select(. | contains("-"))] | sort')
# NOTE: semver with SNAPSHOT is not working when using the sort_by function in jq,
# that's the reason for transforming the SNAPSHOT in a semver 4 digits.
VERSIONS=$(echo "${RES}" | jq -r -c '[.stacks[].version | select(. | contains("-SNAPSHOT"))] | sort' | sed 's#-SNAPSHOT#.0#g' | jq -r -c ' sort_by(.| split(".") | map(tonumber))' | sed 's#.0"#-SNAPSHOT"#g' | jq -r -c .)
}

terraform_init() {
Expand Down

0 comments on commit 5158fea

Please sign in to comment.