From 94ffc18c78202f0a4a2eaa6d6a389486fae2eeec Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 23 Jul 2024 13:40:09 -0700 Subject: [PATCH 1/6] Push and pull 'nightly' Docker images in nightly test job Also adjusts the gasnet and gasnet-smp Dockerfiles to build off of the Chapel base image's nightly tag (rather than latest) so they use the just-built result. Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index c3aaffa1a914..4f5b2af937a1 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -18,7 +18,7 @@ local imageName="$1" local script="$2" # Remove any existing image with the tag before building docker image docker image rm --force $imageName -docker build --load . -t $imageName +docker build --push . -t $imageName containerid= docker image ls | grep $imageName | awk '{print$3}' cd ${CHPL_HOME}/util/cron echo 'writeln("Hello, world!");' > hello.chpl @@ -36,14 +36,29 @@ fi } -# Build chapel docker image. +# Patch the Dockerfile to build FROM the nightly image instead of latest +dockerfile_nightly_patch() { + local patch=" +1c1 +< FROM chapel/chapel:latest +--- +> FROM chapel/chapel:nightly +" + patch Dockerfile << EOF +$dockerfile_nightly_patch +EOF +} + +# Build chapel Docker images cd $CHPL_HOME -build_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash +build_image chapel/chapel:nightly ${CHPL_HOME}/util/cron/docker-chapel.bash cd $CHPL_HOME/util/packaging/docker/gasnet -build_image chapel/chapel_gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash +dockerfile_nightly_patch +build_image chapel/chapel_gasnet:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash cd $CHPL_HOME/util/packaging/docker/gasnet-smp -build_image chapel/chapel_gasnet_smp ${CHPL_HOME}/util/cron/docker-gasnet.bash +dockerfile_nightly_patch +build_image chapel/chapel_gasnet_smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" From 42c090104acb36f000a04235ed45bc86114060ac Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 23 Jul 2024 13:50:49 -0700 Subject: [PATCH 2/6] Fix indentation and trim trailing whitespace Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 46 ++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 4f5b2af937a1..8fe873a7ba05 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# This script will build, run, and verify chapel, gasnet, and gasnet-smp docker images. +# This script will build, run, and verify chapel, gasnet, and gasnet-smp docker images. CWD=$(cd $(dirname $0) ; pwd) source $CWD/common.bash @@ -9,31 +9,29 @@ export CHPL_HOME=$(cd $CWD/../.. ; pwd) log_info "Setting CHPL_HOME to: ${CHPL_HOME}" start_docker - + # 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(){ - -local imageName="$1" -local script="$2" -# Remove any existing image with the tag before building docker image -docker image rm --force $imageName -docker build --push . -t $imageName -containerid= docker image ls | grep $imageName | awk '{print$3}' -cd ${CHPL_HOME}/util/cron -echo 'writeln("Hello, world!");' > hello.chpl - -docker run --rm -i $imageName < $script - -CONTAINER_RUN=$? -if [ $CONTAINER_RUN -ne 0 ] -then - echo "docker commands failed inside chapel $imageName container" - exit 1 -else - echo "docker commands succeeded inside chapel $imageName container" -fi - +build_image() { + local imageName="$1" + local script="$2" + # Remove any existing image with the tag before building docker image + docker image rm --force $imageName + docker build --push . -t $imageName + containerid= docker image ls | grep $imageName | awk '{print$3}' + cd ${CHPL_HOME}/util/cron + echo 'writeln("Hello, world!");' > hello.chpl + + docker run --rm -i $imageName < $script + + CONTAINER_RUN=$? + if [ $CONTAINER_RUN -ne 0 ] + then + echo "docker commands failed inside chapel $imageName container" + exit 1 + else + echo "docker commands succeeded inside chapel $imageName container" + fi } # Patch the Dockerfile to build FROM the nightly image instead of latest From dea6b75165f0a3628b7681626d442461554b7d8a Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 23 Jul 2024 13:51:51 -0700 Subject: [PATCH 3/6] Fix patchfile text variable name Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 8fe873a7ba05..f917abb555bc 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -36,14 +36,14 @@ build_image() { # Patch the Dockerfile to build FROM the nightly image instead of latest dockerfile_nightly_patch() { - local patch=" + local nightlypatch=" 1c1 < FROM chapel/chapel:latest --- > FROM chapel/chapel:nightly " patch Dockerfile << EOF -$dockerfile_nightly_patch +$nightlypatch EOF } From e92c1b15ed0ef3fd7d4a7f0c75f25cb673bc411c Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Tue, 23 Jul 2024 13:55:28 -0700 Subject: [PATCH 4/6] Specify Dockerfile to patch is in current dir Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index f917abb555bc..4a7d11c49571 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -34,7 +34,8 @@ build_image() { fi } -# Patch the Dockerfile to build FROM the nightly image instead of latest +# 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 @@ -42,7 +43,7 @@ dockerfile_nightly_patch() { --- > FROM chapel/chapel:nightly " - patch Dockerfile << EOF + patch ./Dockerfile << EOF $nightlypatch EOF } From 7f2301081029de890140ff674da5d82102eb042f Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Wed, 24 Jul 2024 08:38:31 -0700 Subject: [PATCH 5/6] Fix chapel-gasnet and chapel-gasnet-smp repo names Dashes not underscores... Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 4a7d11c49571..1d3af7f79dd3 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -54,10 +54,10 @@ build_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 +build_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 +build_image chapel/chapel-gasnet-smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker" From e2b1613872ebbbf7e3872704f154f7c054e384f8 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Wed, 24 Jul 2024 08:48:45 -0700 Subject: [PATCH 6/6] Explicitly exit with error for failed image build Signed-off-by: Anna Rift --- util/cron/test-docker.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/cron/test-docker.bash b/util/cron/test-docker.bash index 1d3af7f79dd3..8d99a2ec6317 100755 --- a/util/cron/test-docker.bash +++ b/util/cron/test-docker.bash @@ -17,7 +17,15 @@ build_image() { local script="$2" # Remove any existing image with the tag before building docker image docker image rm --force $imageName + docker build --push . -t $imageName + BUILD_RESULT=$? + if [ $BUILD_RESULT -ne 0 ] + then + echo "docker build failed for $imageName image" + exit 1 + fi + containerid= docker image ls | grep $imageName | awk '{print$3}' cd ${CHPL_HOME}/util/cron echo 'writeln("Hello, world!");' > hello.chpl