From 0582a0cc229ef42356d2374c2742a30ee76967cc Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 20 Sep 2023 14:33:19 -0400 Subject: [PATCH 1/2] Minor: Fix documentation URL Previous value was missing `$head_sha` and for some containers-org repos would point at the wrong path. Fix this by confirming the existence of the README file, then using the location in the docs URL. Signed-off-by: Chris Evich --- build-push/bin/containers_build_push.sh | 16 +++++++++++++++- build-push/test.sh | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/build-push/bin/containers_build_push.sh b/build-push/bin/containers_build_push.sh index 9d13f560..f88b5c8d 100644 --- a/build-push/bin/containers_build_push.sh +++ b/build-push/bin/containers_build_push.sh @@ -123,6 +123,15 @@ cd "$CLONE_TMP" head_sha=$(git rev-parse HEAD) dbg "HEAD is $head_sha" +# Docs should always be in one of two places, otherwise don't list any. +DOCS_URL="" +for _docs_subdir in "$CTX_SUB/README.md" "$(dirname $CTX_SUB)/README.md"; do + if [[ -r "./$_docs_subdir" ]]; then + dbg "Found README.md under '$CLONE_TMP/$_docs_subdir'" + DOCS_URL="${REPO_URL%.git}/blob/${head_sha}/$_docs_subdir" + fi +done + req_env_vars CIRRUS_TASK_ID CIRRUS_CHANGE_IN_REPO CIRRUS_REPO_NAME # Labels to add to all images as per @@ -139,10 +148,15 @@ for arg in "--label" "--annotation"; do "$arg=org.opencontainers.image.source=${REPO_URL%.git}/blob/${head_sha}/${CTX_SUB}/" "$arg=org.opencontainers.image.revision=$head_sha" "$arg=org.opencontainers.image.created=$(date -u --iso-8601=seconds)" - "$arg=org.opencontainers.image.documentation=${REPO_URL%.git}/tree/$CTX_SUB/README.md" "$arg=org.opencontainers.image.authors=podman@lists.podman.io" ) + if [[ -n "$DOCS_URL" ]]; then + label_args+=(\ + "$arg=org.opencontainers.image.documentation=${DOCS_URL}" + ) + fi + # Perhaps slightly outside the intended purpose, but it kind of fits, and may help # somebody ascertain provenance a little better. Note: Even if the console logs # are blank, the Cirrus-CI GraphQL API keeps build and task metadata for years. diff --git a/build-push/test.sh b/build-push/test.sh index cb3886c9..b10795db 100644 --- a/build-push/test.sh +++ b/build-push/test.sh @@ -65,6 +65,8 @@ EOF # the 'stable' flavor name as a command-line arg instead # of using the subdirectory dirname (old method). cd $SRC_TMP/testing/contrib/testimage +# This file is looked up by the build script. +echo "Test Docs" > README.md cp stable/* ./ cd $SRC_TMP/testing # The images will have the repo & commit ID set as labels From 99a28fad77b299870e3dcdeb87c7161dabdf927e Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 20 Sep 2023 14:47:56 -0400 Subject: [PATCH 2/2] Use latest common library + show version The automation common library is version-pinned (in `lib.sh`) and updates are carefully managed by renovate. This is by design, so breaking changes don't impact important CI environments. However, on more than one occasion, there's been a need to update the podman/buildah/skopeo image building scripts rapidly. Since the latest build-push VM image is always used, it's production doesn't need to be tied down in the same way. Mainly because there's extensive testing of it from CI in this repo. Make the necessary changes to allow installing the latest version of the common automation library, along with the `build_push.sh` script, specifically in the build-push VM image. Also, add a debug message for the library version installed (will include commit sha) to assist any future debugging. Signed-off-by: Chris Evich --- IMG_SFX | 2 +- build-push/bin/containers_build_push.sh | 1 + build-push/test.sh | 7 ++++++- cache_images/build-push_packaging.sh | 6 ++++-- lib.sh | 11 ++++++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/IMG_SFX b/IMG_SFX index daee30e4..a3a11294 100644 --- a/IMG_SFX +++ b/IMG_SFX @@ -1 +1 @@ -20230920t195830z-f38f37d13 +20230921t145748z-f38f37d13 diff --git a/build-push/bin/containers_build_push.sh b/build-push/bin/containers_build_push.sh index f88b5c8d..576239f7 100644 --- a/build-push/bin/containers_build_push.sh +++ b/build-push/bin/containers_build_push.sh @@ -27,6 +27,7 @@ if [[ -r "/etc/automation_environment" ]]; then source /etc/automation_environment # defines AUTOMATION_LIB_PATH #shellcheck disable=SC1090,SC2154 source "$AUTOMATION_LIB_PATH/common_lib.sh" + dbg "Using automation common library version $(<$AUTOMATION_LIB_PATH/../AUTOMATION_VERSION)" else echo "Expecting to find automation common library installed." exit 1 diff --git a/build-push/test.sh b/build-push/test.sh index b10795db..44ffc3b4 100644 --- a/build-push/test.sh +++ b/build-push/test.sh @@ -82,7 +82,7 @@ TEST_REPO_URL="file://$SRC_TMP/testing" # on the `latest` tagged FQINs. verify_built_images() { local _fqin _arch xy_ver x_ver img_ver img_src img_rev _fltr - local _test_tag expected_flavor _test_fqins + local _test_tag expected_flavor _test_fqins img_docs expected_flavor="$1" msg " ##### Testing execution of '$expected_flavor' images for arches $TESTARCHES #####" @@ -148,6 +148,11 @@ verify_built_images() { # Checked at beginning of script # shellcheck disable=SC2154 showrun test "$img_bbc" == "$CIRRUS_CHANGE_IN_REPO" + + msg "Testing image $_fqin:$test_tag docs label" + _fltr='.[].Config.Labels."org.opencontainers.image.documentation"' + img_docs=$(podman inspect $_fqin:$test_tag | jq -r -e "$_fltr") + showrun grep -F -q "README.md" <<<"$img_docs" done } diff --git a/cache_images/build-push_packaging.sh b/cache_images/build-push_packaging.sh index 790280a2..52805273 100644 --- a/cache_images/build-push_packaging.sh +++ b/cache_images/build-push_packaging.sh @@ -38,8 +38,10 @@ bigto $SUDO dnf install -y "${INSTALL_PACKAGES[@]}" # It was observed in F33, dnf install doesn't always get you the latest/greatest lilto $SUDO dnf update -y -# Re-install with the 'build-push' component -install_automation_tooling build-push +# Re-install would append to this, making a mess. +$SUDO rm -f /etc/automation_environment +# Re-install the latest version with the 'build-push' component +install_automation_tooling latest build-push # Install scripts into automation directory on $PATH cd $REPO_DIRPATH/build-push diff --git a/lib.sh b/lib.sh index 37444e5d..807d3c88 100644 --- a/lib.sh +++ b/lib.sh @@ -19,6 +19,7 @@ OS_REL_VER="$OS_RELEASE_ID-$OS_RELEASE_VER" # This location is checked by automation in other repos, please do not change. PACKAGE_DOWNLOAD_DIR=/var/cache/download +# N/B: This is managed by renovate INSTALL_AUTOMATION_VERSION="4.3.1" PUSH_LATEST="${PUSH_LATEST:-0}" @@ -49,12 +50,20 @@ if [[ "$UID" -ne 0 ]]; then fi install_automation_tooling() { + local version_arg + version_arg="$INSTALL_AUTOMATION_VERSION" + + if [[ "$1" == "latest" ]]; then + version_arg="latest" + shift + fi + # This script supports installing all current and previous versions local installer_url="https://raw.githubusercontent.com/containers/automation/master/bin/install_automation.sh" curl --silent --show-error --location \ --url "$installer_url" | \ $SUDO env INSTALL_PREFIX=/usr/share /bin/bash -s - \ - "$INSTALL_AUTOMATION_VERSION" "$@" + "$version_arg" "$@" # This defines AUTOMATION_LIB_PATH source /usr/share/automation/environment #shellcheck disable=SC1090