Skip to content

Commit

Permalink
Merge pull request containers#304 from cevich/fix_jq_null_iteration
Browse files Browse the repository at this point in the history
Latest common automation library on build-push VM
  • Loading branch information
cevich authored Sep 26, 2023
2 parents b86aea0 + 99a28fa commit 5b9f617
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion IMG_SFX
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20230920t195830z-f38f37d13
20230921t145748z-f38f37d13
17 changes: 16 additions & 1 deletion build-push/bin/containers_build_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,6 +124,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
Expand All @@ -139,10 +149,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[email protected]"
)

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.
Expand Down
9 changes: 8 additions & 1 deletion build-push/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,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 #####"
Expand Down Expand Up @@ -146,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
}

Expand Down
6 changes: 4 additions & 2 deletions cache_images/build-push_packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b9f617

Please sign in to comment.