Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smoke-test: sort latest versions using the semver format #12229

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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