From 7fbac42b93f4f3deb49da1612908dbf0605a420e Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 09:48:30 -0700 Subject: [PATCH 01/17] Remove previous publish-docker-images.bash script Signed-off-by: Anna Rift --- util/cron/publish-docker-images.bash | 79 ---------------------------- 1 file changed, 79 deletions(-) delete mode 100755 util/cron/publish-docker-images.bash diff --git a/util/cron/publish-docker-images.bash b/util/cron/publish-docker-images.bash deleted file mode 100755 index e532c8d1217b..000000000000 --- a/util/cron/publish-docker-images.bash +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash - -# This script will build the docker images for 'amd' and 'arm' platforms using buildx and publish the images to the docker registry - -# Check if the script is run with correct arguement if not fail -required_vars=(docker_repository image_version username password) -for var in ${required_vars[@]}; do - if [ -z "${!var}" ] ; then - echo "${var} must be set." - exit 1 - fi -done - -echo "RepositoryName: $docker_repository" -echo "imageVersion: $image_version" - -CWD=$(cd $(dirname $0) ; pwd) -source $CWD/common.bash -export CHPL_HOME=$(cd $CWD/../.. ; pwd) -log_info "Setting CHPL_HOME to: ${CHPL_HOME}" - -# build_publish will build multi platform chapel docker images, tags them, and pushes the images to the docker repository . - -build_publish(){ - -local registry="$1" -local imageName="$2" -local version="$3" - -# the below buildx command will build images for amd and arm, tags with the tags specified, and pushes it to the docker repository($registry) -docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $registry/$imageName:$version -t $registry/$imageName:latest - -if [ $? -ne 0 ] -then - echo "docker publish using buildx failed " - exit 1 -else - echo "docker publish using buildx succeeded " -fi - -} - -# Get the repository name and chapel version, Build chapel docker images and push to docker hub repository . -#build and publish chapel docker image -docker login -u $username -p $password -if [ $? -ne 0 ] -then - echo " Docker login failed " - exit 1 -else - echo "docker login succeeded " -fi - -cd $CHPL_HOME -build_publish $docker_repository chapel $image_version - -docker login -u $username -p $password -if [ $? -ne 0 ] -then - echo " Docker login failed " - exit 1 -else - echo "docker login succeeded " -fi -#build and publish chapel-gasnet docker image -cd $CHPL_HOME/util/packaging/docker/gasnet -build_publish $docker_repository chapel-gasnet $image_version - -docker login -u $username -p $password -if [ $? -ne 0 ] -then - echo " Docker login failed " - exit 1 -else - echo "docker login succeeded " -fi -#build and publish chapel-gasnet-smp docker image -cd $CHPL_HOME/util/packaging/docker/gasnet-smp -build_publish $docker_repository chapel-gasnet-smp $image_version From dd7a91d8259b80f82276612df6612382578f6a77 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 09:59:14 -0700 Subject: [PATCH 02/17] Update comments in test-docker.bash Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index d45f267f196f..de234bd1af2d 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -1,15 +1,18 @@ #!/usr/bin/env bash # -# This script will build, run, and verify chapel, gasnet, and gasnet-smp docker images. +# This script will build, (sanity) test, and push the chapel, chapel-gasnet, and +# chapel-gasnet-smp Docker images, using the `nightly` tag. +# +# Assumes Docker is already running on the system, logged into an account with +# appropriate permissions to push the images. CWD=$(cd $(dirname $0) ; pwd) source $CWD/common.bash export CHPL_HOME=$(cd $CWD/../.. ; pwd) log_info "Setting CHPL_HOME to: ${CHPL_HOME}" -# build_image function takes image name and docker script location as arguments. -# Builds the image with the name from arg$1, runs the container and execute the install and verify script located in the location $2. -build_image() { +# update_image takes image name and test script location as arguments. +update_image() { local imageName="$1" local script="$2" # Remove any existing image with the tag before building docker image @@ -53,16 +56,16 @@ $nightlypatch EOF } -# Build chapel Docker images +# Build and push Chapel Docker images cd $CHPL_HOME -build_image chapel/chapel:nightly ${CHPL_HOME}/util/cron/docker-chapel.bash +update_image chapel/chapel:nightly ${CHPL_HOME}/util/cron/docker-chapel.bash cd $CHPL_HOME/util/packaging/docker/gasnet dockerfile_nightly_patch -build_image chapel/chapel-gasnet:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash +update_image chapel/chapel-gasnet:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash cd $CHPL_HOME/util/packaging/docker/gasnet-smp dockerfile_nightly_patch -build_image chapel/chapel-gasnet-smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash +update_image chapel/chapel-gasnet-smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" From 8f56102971a900ba37bacd4e931a6e078ec77ad9 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:06:13 -0700 Subject: [PATCH 03/17] Refactor to only push after successful test Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index de234bd1af2d..fa3bbad60cc9 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -15,10 +15,12 @@ log_info "Setting CHPL_HOME to: ${CHPL_HOME}" update_image() { local imageName="$1" local script="$2" + # Remove any existing image with the tag before building docker image docker image rm --force $imageName - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $imageName + # Build image + docker buildx build --platform=linux/amd64,linux/arm64 . -t $imageName BUILD_RESULT=$? if [ $BUILD_RESULT -ne 0 ] then @@ -26,13 +28,17 @@ update_image() { exit 1 fi - containerid= docker image ls | grep $imageName | awk '{print$3}' + # Set up to test container cd ${CHPL_HOME}/util/cron echo 'writeln("Hello, world!");' > hello.chpl + # Run test script inside container docker run --rm -i $imageName < $script - CONTAINER_RUN=$? + + # Clean up after our scratch test script, whether it succeeded or not + rm hello.chpl + if [ $CONTAINER_RUN -ne 0 ] then echo "docker commands failed inside chapel $imageName container" @@ -40,6 +46,9 @@ update_image() { else echo "docker commands succeeded inside chapel $imageName container" fi + + # Push image after testing has succeeded + docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $imageName } # Patch the Dockerfile to build FROM the nightly image instead of latest. From c7966416a75741933c3b184c68a680c983e250aa Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:39:33 -0700 Subject: [PATCH 04/17] Implement release image mode via env var Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 99 +++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 28 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index fa3bbad60cc9..19bd5b3386e7 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -1,7 +1,8 @@ #!/usr/bin/env bash # # This script will build, (sanity) test, and push the chapel, chapel-gasnet, and -# chapel-gasnet-smp Docker images, using the `nightly` tag. +# chapel-gasnet-smp Docker images. Uses the 'nightly' tag by default, or +# 'latest' and a release version tag if specified. # # Assumes Docker is already running on the system, logged into an account with # appropriate permissions to push the images. @@ -10,14 +11,46 @@ CWD=$(cd $(dirname $0) ; pwd) source $CWD/common.bash export CHPL_HOME=$(cd $CWD/../.. ; pwd) log_info "Setting CHPL_HOME to: ${CHPL_HOME}" +export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" + +# BEGIN FUNCTIONS + +# Patch the Dockerfile to build FROM the nightly image instead of latest. +# Assumes the Dockerfile is available at ./Dockerfile. +# Arguments are forwarded to `patch` command. +dockerfile_nightly_patch() { + local patch_args="$@" -# update_image takes image name and test script location as arguments. + local nightlypatch=" +1c1 +< FROM chapel/chapel:latest +--- +> FROM chapel/chapel:nightly +" + + patch $patch_args ./Dockerfile << EOF +$nightlypatch +EOF +} + +# Build, test, and push a Docker image. +# Args: +# - image name without tag +# - test script location +# - release version tag to use (optional, just 'nightly' otherwise) update_image() { - local imageName="$1" + local baseImageName="$1" local script="$2" + local release_tag="$3" - # Remove any existing image with the tag before building docker image - docker image rm --force $imageName + # Use specified release version tag, or 'nightly' if not specified + local imageName="${baseImageName}:${release_tag:-nightly}" + + # Remove any existing image with the tag before building nightly docker image + if [ -n "$release_tag" ] + then + docker image rm --force $baseImageName + fi # Build image docker buildx build --platform=linux/amd64,linux/arm64 . -t $imageName @@ -49,32 +82,42 @@ update_image() { # Push image after testing has succeeded docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $imageName + # Also push as 'latest' tag if this is a release build + if [ -n "$release_tag" ] + then + # Use base image name (without tag) to use Docker's default tag + docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $baseImageName + fi } -# Patch the Dockerfile to build FROM the nightly image instead of latest. -# Assumes the Dockerfile is available at ./Dockerfile. -dockerfile_nightly_patch() { - local nightlypatch=" -1c1 -< FROM chapel/chapel:latest ---- -> FROM chapel/chapel:nightly -" - patch ./Dockerfile << EOF -$nightlypatch -EOF -} +# Build, test, and push all Chapel Docker images. +# Args: +# - release version tag to use (optional, just 'nightly' otherwise) +update_all_images() { + local release_tag="$1" -# Build and push Chapel Docker images -cd $CHPL_HOME -update_image chapel/chapel:nightly ${CHPL_HOME}/util/cron/docker-chapel.bash + cd $CHPL_HOME + update_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash release_tag -cd $CHPL_HOME/util/packaging/docker/gasnet -dockerfile_nightly_patch -update_image chapel/chapel-gasnet:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash + cd $CHPL_HOME/util/packaging/docker/gasnet + dockerfile_nightly_patch + update_image chapel/chapel-gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash release_tag + dockerfile_nightly_patch -R -cd $CHPL_HOME/util/packaging/docker/gasnet-smp -dockerfile_nightly_patch -update_image chapel/chapel-gasnet-smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash + cd $CHPL_HOME/util/packaging/docker/gasnet-smp + dockerfile_nightly_patch + update_image chapel/chapel-gasnet-smp ${CHPL_HOME}/util/cron/docker-gasnet.bash release_tag + dockerfile_nightly_patch -R +} +# END FUNCTIONS -export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" + +# Build and push nightly images +update_all_images + +# Build and push release images after ALL nightly builds have succeeded, if +# release tag was specified. +if [ -n "$RELEASE_VERSION" ] +then + update_all_images $RELEASE_VERSION +fi From 4f2dd82197e13cd2db67ebabc3a1b9baaa841299 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:49:25 -0700 Subject: [PATCH 05/17] Use release_tag variable rather than string literal Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 19bd5b3386e7..af0b7fc8f936 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -97,16 +97,16 @@ update_all_images() { local release_tag="$1" cd $CHPL_HOME - update_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash release_tag + update_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash "$release_tag" cd $CHPL_HOME/util/packaging/docker/gasnet dockerfile_nightly_patch - update_image chapel/chapel-gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash release_tag + update_image chapel/chapel-gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash "$release_tag" dockerfile_nightly_patch -R cd $CHPL_HOME/util/packaging/docker/gasnet-smp dockerfile_nightly_patch - update_image chapel/chapel-gasnet-smp ${CHPL_HOME}/util/cron/docker-gasnet.bash release_tag + update_image chapel/chapel-gasnet-smp ${CHPL_HOME}/util/cron/docker-gasnet.bash "$release_tag" dockerfile_nightly_patch -R } # END FUNCTIONS From 30e9514e35eb4c72b09b09d5649eab67aee08f01 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:52:10 -0700 Subject: [PATCH 06/17] Quote variables to prevent bash weirdness Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index af0b7fc8f936..de79a5590693 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -19,7 +19,7 @@ export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" # Assumes the Dockerfile is available at ./Dockerfile. # Arguments are forwarded to `patch` command. dockerfile_nightly_patch() { - local patch_args="$@" + local patch_args="$*" local nightlypatch=" 1c1 @@ -28,7 +28,7 @@ dockerfile_nightly_patch() { > FROM chapel/chapel:nightly " - patch $patch_args ./Dockerfile << EOF + patch "$patch_args" ./Dockerfile << EOF $nightlypatch EOF } @@ -49,11 +49,11 @@ update_image() { # Remove any existing image with the tag before building nightly docker image if [ -n "$release_tag" ] then - docker image rm --force $baseImageName + docker image rm --force "$baseImageName" fi # Build image - docker buildx build --platform=linux/amd64,linux/arm64 . -t $imageName + docker buildx build --platform=linux/amd64,linux/arm64 . -t "$imageName" BUILD_RESULT=$? if [ $BUILD_RESULT -ne 0 ] then @@ -62,11 +62,11 @@ update_image() { fi # Set up to test container - cd ${CHPL_HOME}/util/cron + cd "${CHPL_HOME}/util/cron" echo 'writeln("Hello, world!");' > hello.chpl # Run test script inside container - docker run --rm -i $imageName < $script + docker run --rm -i "$imageName" < "$script" CONTAINER_RUN=$? # Clean up after our scratch test script, whether it succeeded or not @@ -81,12 +81,12 @@ update_image() { fi # Push image after testing has succeeded - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $imageName + docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$imageName" # Also push as 'latest' tag if this is a release build if [ -n "$release_tag" ] then - # Use base image name (without tag) to use Docker's default tag - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t $baseImageName + # Use base image name (without tag) to use Docker's default tag 'latest' + docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$baseImageName" fi } @@ -96,17 +96,17 @@ update_image() { update_all_images() { local release_tag="$1" - cd $CHPL_HOME - update_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash "$release_tag" + cd "$CHPL_HOME" + update_image chapel/chapel "${CHPL_HOME}/util/cron/docker-chapel.bash" "$release_tag" - cd $CHPL_HOME/util/packaging/docker/gasnet + cd "$CHPL_HOME/util/packaging/docker/gasnet" dockerfile_nightly_patch - update_image chapel/chapel-gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash "$release_tag" + update_image chapel/chapel-gasnet "${CHPL_HOME}/util/cron/docker-gasnet.bash" "$release_tag" dockerfile_nightly_patch -R - cd $CHPL_HOME/util/packaging/docker/gasnet-smp + cd "$CHPL_HOME/util/packaging/docker/gasnet-smp" dockerfile_nightly_patch - update_image chapel/chapel-gasnet-smp ${CHPL_HOME}/util/cron/docker-gasnet.bash "$release_tag" + update_image chapel/chapel-gasnet-smp "${CHPL_HOME}/util/cron/docker-gasnet.bash" "$release_tag" dockerfile_nightly_patch -R } # END FUNCTIONS @@ -119,5 +119,5 @@ update_all_images # release tag was specified. if [ -n "$RELEASE_VERSION" ] then - update_all_images $RELEASE_VERSION + update_all_images "$RELEASE_VERSION" fi From 3c0adbc52daa41445aece20306aab32d06c9eadc Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:54:38 -0700 Subject: [PATCH 07/17] Add comment for patch reverses Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index de79a5590693..16e3dc53bdf3 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -102,11 +102,13 @@ update_all_images() { cd "$CHPL_HOME/util/packaging/docker/gasnet" dockerfile_nightly_patch update_image chapel/chapel-gasnet "${CHPL_HOME}/util/cron/docker-gasnet.bash" "$release_tag" + # Clean up after patch changes dockerfile_nightly_patch -R cd "$CHPL_HOME/util/packaging/docker/gasnet-smp" dockerfile_nightly_patch update_image chapel/chapel-gasnet-smp "${CHPL_HOME}/util/cron/docker-gasnet.bash" "$release_tag" + # Clean up after patch changes dockerfile_nightly_patch -R } # END FUNCTIONS From a73535e0fecde3eb5addf6fcfafe48f710340e7d Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 10:55:43 -0700 Subject: [PATCH 08/17] Clarify some comments Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 16e3dc53bdf3..b7c3eed4d745 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -6,6 +6,8 @@ # # Assumes Docker is already running on the system, logged into an account with # appropriate permissions to push the images. +# + CWD=$(cd $(dirname $0) ; pwd) source $CWD/common.bash @@ -37,7 +39,7 @@ EOF # Args: # - image name without tag # - test script location -# - release version tag to use (optional, just 'nightly' otherwise) +# - release version tag to use (optional, builds nightly otherwise) update_image() { local baseImageName="$1" local script="$2" @@ -92,7 +94,7 @@ update_image() { # Build, test, and push all Chapel Docker images. # Args: -# - release version tag to use (optional, just 'nightly' otherwise) +# - release version tag to use (optional, builds nightly otherwise) update_all_images() { local release_tag="$1" @@ -117,8 +119,8 @@ update_all_images() { # Build and push nightly images update_all_images -# Build and push release images after ALL nightly builds have succeeded, if -# release tag was specified. +# Build and push release-tagged images, if RELEASE_VERSION was specified. +# Runs after all nightly images, to abort if any fail. if [ -n "$RELEASE_VERSION" ] then update_all_images "$RELEASE_VERSION" From 15bf1d965d55bc66190ae86d96f64c867ccecefd Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 11:38:22 -0700 Subject: [PATCH 09/17] Add comment and logging for RELEASE_VERSION var Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index b7c3eed4d745..759e55b38ff0 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -7,6 +7,9 @@ # Assumes Docker is already running on the system, logged into an account with # appropriate permissions to push the images. # +# Expected environment variables: +# - RELEASE_VERSION (optional): If set, will also push the image tagged as +# 'latest' and this version. Should match version in release branch name. CWD=$(cd $(dirname $0) ; pwd) @@ -116,6 +119,13 @@ update_all_images() { # END FUNCTIONS +if [ -n "$RELEASE_VERSION" ] +then + log_info "Building and pushing nightly and release-tagged images for version: $RELEASE_VERSION" +else + log_info "Building and pushing nightly images" +fi + # Build and push nightly images update_all_images From f904a4b1a2936ab8af1591047f3bbe16df6f5c80 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 11:42:41 -0700 Subject: [PATCH 10/17] Abort if releasing not on release branch Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 759e55b38ff0..fb27246e2acb 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -122,6 +122,12 @@ update_all_images() { if [ -n "$RELEASE_VERSION" ] then log_info "Building and pushing nightly and release-tagged images for version: $RELEASE_VERSION" + local release_branch="release/$RELEASE_VERSION" + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$release_branch" ] + then + log_error "Not on expected release branch $release_branch for version $RELEASE_VERSION, aborting" + exit 1 + fi else log_info "Building and pushing nightly images" fi From da54de4a35b139342276afa346f12a0b796cf183 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 12:04:38 -0700 Subject: [PATCH 11/17] Remove incorrect use of local keyword Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index fb27246e2acb..e96d5a4a1f80 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -122,7 +122,7 @@ update_all_images() { if [ -n "$RELEASE_VERSION" ] then log_info "Building and pushing nightly and release-tagged images for version: $RELEASE_VERSION" - local release_branch="release/$RELEASE_VERSION" + release_branch="release/$RELEASE_VERSION" if [ "$(git rev-parse --abbrev-ref HEAD)" != "$release_branch" ] then log_error "Not on expected release branch $release_branch for version $RELEASE_VERSION, aborting" From b7681a320918b1e61d9967c25270fad6745d3d51 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 12:07:45 -0700 Subject: [PATCH 12/17] Add logging for start and end of each image Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index e96d5a4a1f80..3d351934ac1b 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -51,6 +51,8 @@ update_image() { # Use specified release version tag, or 'nightly' if not specified local imageName="${baseImageName}:${release_tag:-nightly}" + log_info "Starting $imageName..." + # Remove any existing image with the tag before building nightly docker image if [ -n "$release_tag" ] then @@ -93,6 +95,8 @@ update_image() { # Use base image name (without tag) to use Docker's default tag 'latest' docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$baseImageName" fi + + log_info "Completed $imageName" } # Build, test, and push all Chapel Docker images. From 825dd6d6543068cdde8257b0444505709cdedda4 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 12:10:50 -0700 Subject: [PATCH 13/17] Resume pushing (nightly) image before test Includes comment describing Docker limitation motivating this. Also correctly remove tagged image name pre-build. Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 3d351934ac1b..e80b11e53813 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -53,14 +53,20 @@ update_image() { log_info "Starting $imageName..." - # Remove any existing image with the tag before building nightly docker image + # Remove any existing image with the tag before building if [ -n "$release_tag" ] then - docker image rm --force "$baseImageName" + docker image rm --force "$imageName" fi - # Build image - docker buildx build --platform=linux/amd64,linux/arm64 . -t "$imageName" + # Build and push image + # Note: We push before testing due to a limitation of Docker + # (https://github.com/docker/buildx/issues/59) which prevents loading a + # multi-arch image without pushing. This means we may push a broken nightly + # image before erroring out; it's important that release pushes come after + # all nightly pushes so we can't push a broken release image. + # Anna, 2024-10-07 + docker buildx build --platform=linux/amd64,linux/arm64 --push . -t "$imageName" BUILD_RESULT=$? if [ $BUILD_RESULT -ne 0 ] then @@ -87,8 +93,6 @@ update_image() { echo "docker commands succeeded inside chapel $imageName container" fi - # Push image after testing has succeeded - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$imageName" # Also push as 'latest' tag if this is a release build if [ -n "$release_tag" ] then From ad510c559654bd122601fedf11aa4207784b042b Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 7 Oct 2024 12:28:36 -0700 Subject: [PATCH 14/17] Do 'latest' tag push immediately after release-tagged one To be more robust against unnecessary rebuilds Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index e80b11e53813..380d85903c69 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -68,6 +68,13 @@ update_image() { # Anna, 2024-10-07 docker buildx build --platform=linux/amd64,linux/arm64 --push . -t "$imageName" BUILD_RESULT=$? + # Also push as 'latest' tag if this is a release build + if [ -n "$release_tag" ] + then + # Use base image name (without tag) to use Docker's default tag 'latest' + docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$baseImageName" + fi + if [ $BUILD_RESULT -ne 0 ] then echo "docker build failed for $imageName image" @@ -93,13 +100,6 @@ update_image() { echo "docker commands succeeded inside chapel $imageName container" fi - # Also push as 'latest' tag if this is a release build - if [ -n "$release_tag" ] - then - # Use base image name (without tag) to use Docker's default tag 'latest' - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$baseImageName" - fi - log_info "Completed $imageName" } From 9bd6d2d03413d894ea98fac75d86c8da93542f5e Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 8 Oct 2024 10:20:42 -0700 Subject: [PATCH 15/17] Avoid cd in update_image Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 380d85903c69..f27a84e17422 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -81,15 +81,11 @@ update_image() { exit 1 fi - # Set up to test container - cd "${CHPL_HOME}/util/cron" - echo 'writeln("Hello, world!");' > hello.chpl - # Run test script inside container + echo 'writeln("Hello, world!");' > hello.chpl docker run --rm -i "$imageName" < "$script" CONTAINER_RUN=$? - - # Clean up after our scratch test script, whether it succeeded or not + # Clean up scratch chpl file for testing rm hello.chpl if [ $CONTAINER_RUN -ne 0 ] From cc3465c948d8d737e5d1aa27260599da6d234ded Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 8 Oct 2024 10:20:53 -0700 Subject: [PATCH 16/17] Fix arg order of 'latest' tag push Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index f27a84e17422..67a1060ffef8 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -72,7 +72,7 @@ update_image() { if [ -n "$release_tag" ] then # Use base image name (without tag) to use Docker's default tag 'latest' - docker buildx build --platform=linux/amd64,linux/arm64 . --push -t "$baseImageName" + docker buildx build --platform=linux/amd64,linux/arm64 --push . -t "$baseImageName" fi if [ $BUILD_RESULT -ne 0 ] From 3a3f38d941a14d7dfe950990496bf8a7f5995564 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 8 Oct 2024 14:17:24 -0700 Subject: [PATCH 17/17] Remove quoted empty args breaking patch Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 67a1060ffef8..2f2746e99bff 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -33,7 +33,7 @@ dockerfile_nightly_patch() { > FROM chapel/chapel:nightly " - patch "$patch_args" ./Dockerfile << EOF + patch $patch_args ./Dockerfile << EOF $nightlypatch EOF }