diff --git a/scripts/meta/resolve/missing/highest_release_tag.sh b/scripts/meta/resolve/missing/highest_release_tag.sh index a7769f62e2..d078c8782f 100755 --- a/scripts/meta/resolve/missing/highest_release_tag.sh +++ b/scripts/meta/resolve/missing/highest_release_tag.sh @@ -15,6 +15,10 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" OWNER="$("${script_dir}/../repository/owner.sh")" REPO_PREFIX="${REPO_PREFIX,,}" +below_floor() { + [[ "$(printf '%s\n' "$1" "${oldest_buildable_tag}" | sort -V | head -n 1)" != "${oldest_buildable_tag}" ]] +} + serves_pool() { local img="$1" local absent @@ -47,13 +51,16 @@ if ! serves_pool "${REGISTRY}/${OWNER}/${REPO_PREFIX}:latest"; then fi if [[ "${latest_incomplete}" == "true" ]]; then - printf '%s\n' "${tags[$((${#tags[@]} - 1))]}" + newest="${tags[$((${#tags[@]} - 1))]}" + if ! below_floor "${newest}"; then + printf '%s\n' "${newest}" + fi exit 0 fi for ((i = ${#tags[@]} - 1; i >= 0; i--)); do tag="${tags[$i]}" - if [[ "$(printf '%s\n' "${tag}" "${oldest_buildable_tag}" | sort -V | head -n 1)" != "${oldest_buildable_tag}" ]]; then + if below_floor "${tag}"; then exit 0 fi tag_missing="false" diff --git a/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py b/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py index c9801bb119..0af79981b9 100644 --- a/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py +++ b/tests/unit/python/scripts/meta/resolve/missing/test_highest_release_tag.py @@ -17,6 +17,8 @@ STUBS = { "docker": ( "#!/usr/bin/env bash\n" 'case " ${STUB_MISSING} " in *" ${3##*:} "*) exit 1 ;; esac\n' + 'printf \'{"manifests":[{"platform":{"architecture":"amd64"}},' + '{"platform":{"architecture":"arm64"}}]}\\n\'\n' ), } @@ -24,6 +26,10 @@ STUBS = { def pick(*missing: str) -> subprocess.CompletedProcess: """Run the picker against stubbed ``git`` tags and ``docker`` manifests. + A present tag answers with a manifest index serving the whole architecture + pool, because ``architectures.sh`` parses that index and reads an empty + answer as every architecture missing. + Args: missing: tags whose images the registry does not hold. """