From c6d5891326184b267761aad08f099372811416ee Mon Sep 17 00:00:00 2001 From: Song Guo Date: Fri, 19 Feb 2021 14:36:27 +0800 Subject: [PATCH 1/4] [cirque] Only build docker image when the image does not exists on dockerhub --- .../images/chip-cirque-device-base/build.sh | 16 ++++++++++++---- scripts/tests/cirque_tests.sh | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/integrations/docker/images/chip-cirque-device-base/build.sh b/integrations/docker/images/chip-cirque-device-base/build.sh index 983d0288297075..6b2716600bbbcf 100755 --- a/integrations/docker/images/chip-cirque-device-base/build.sh +++ b/integrations/docker/images/chip-cirque-device-base/build.sh @@ -40,10 +40,11 @@ VERSION=${DOCKER_BUILD_VERSION:-$(cat version)} Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD Options: - --no-cache passed as a docker build argument - --latest update latest to the current built version (\"$VERSION\") - --push push image(s) to docker.io (requires docker login for \"$ORG\") - --help get this message + --try-download try to download latest image from dockerhub and skip whole build procedure if success + --no-cache passed as a docker build argument + --latest update latest to the current built version (\"$VERSION\") + --push push image(s) to docker.io (requires docker login for \"$ORG\") + --help get this message " exit 0 @@ -58,6 +59,13 @@ set -ex [[ -n $VERSION ]] || die "version cannot be empty" +if [[ ${*/--try-download//} != "${*}" ]]; then + docker pull "$ORG"/"$IMAGE":"$VERSION" + if [[ $? -eq 0 ]]; then + exit 0 + fi +fi + # go find and build any CHIP images this image is "FROM" awk -F/ '/^FROM connectedhomeip/ {print $2}' Dockerfile | while read -r dep; do dep=${dep%:*} diff --git a/scripts/tests/cirque_tests.sh b/scripts/tests/cirque_tests.sh index eebcf2a87d9ea7..756caab4d30077 100755 --- a/scripts/tests/cirque_tests.sh +++ b/scripts/tests/cirque_tests.sh @@ -83,7 +83,7 @@ function cirquetest_bootstrap() { cd "$REPO_DIR"/third_party/cirque/repo pip3 install pycodestyle==2.5.0 wheel make NO_GRPC=1 install -j - "$REPO_DIR"/integrations/docker/images/chip-cirque-device-base/build.sh + "$REPO_DIR"/integrations/docker/images/chip-cirque-device-base/build.sh --try-download __cirquetest_build_ot pip3 install -r requirements_nogrpc.txt From c2012cb9af39c7d18930bda8c6bf60143eeab85c Mon Sep 17 00:00:00 2001 From: Song Guo Date: Fri, 19 Feb 2021 14:46:24 +0800 Subject: [PATCH 2/4] Update test warpper --- .../docker/images/chip-cirque-device-base/build.sh | 4 ++++ scripts/tests/cirque_tests.sh | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/integrations/docker/images/chip-cirque-device-base/build.sh b/integrations/docker/images/chip-cirque-device-base/build.sh index 6b2716600bbbcf..8cf3c0019ebbd8 100755 --- a/integrations/docker/images/chip-cirque-device-base/build.sh +++ b/integrations/docker/images/chip-cirque-device-base/build.sh @@ -62,6 +62,10 @@ set -ex if [[ ${*/--try-download//} != "${*}" ]]; then docker pull "$ORG"/"$IMAGE":"$VERSION" if [[ $? -eq 0 ]]; then + # tag it as latest for this version, note: this should only be used on CI + [[ ${*/--latest//} != "${*}" ]] && { + docker tag "$ORG"/"$IMAGE":"$VERSION" "$ORG"/"$IMAGE":latest + } exit 0 fi fi diff --git a/scripts/tests/cirque_tests.sh b/scripts/tests/cirque_tests.sh index 756caab4d30077..c7e1cdfa96f013 100755 --- a/scripts/tests/cirque_tests.sh +++ b/scripts/tests/cirque_tests.sh @@ -83,7 +83,13 @@ function cirquetest_bootstrap() { cd "$REPO_DIR"/third_party/cirque/repo pip3 install pycodestyle==2.5.0 wheel make NO_GRPC=1 install -j - "$REPO_DIR"/integrations/docker/images/chip-cirque-device-base/build.sh --try-download + + if [[ "x$GITHUB_ACTION_RUN" = "x1" ]]; then + "$REPO_DIR"/integrations/docker/images/chip-cirque-device-base/build.sh --try-download --latest + else + "$REPO_DIR"/integrations/docker/images/chip-cirque-device-base/build.sh --try-download + fi + __cirquetest_build_ot pip3 install -r requirements_nogrpc.txt From 78e9fb4afe44b98ea7a115252235435549ab134f Mon Sep 17 00:00:00 2001 From: Song Guo Date: Fri, 19 Feb 2021 22:00:49 +0800 Subject: [PATCH 3/4] Add GITHUB_ACTION_RUN=1 for cirque bootstrap --- .github/workflows/cirque.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index 14fb875b0b139f..a60779945007d3 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -43,7 +43,9 @@ jobs: submodules: true - name: Bootstrap run: | - integrations/docker/images/chip-build-cirque/run.sh scripts/tests/cirque_tests.sh bootstrap + integrations/docker/images/chip-build-cirque/run.sh \ + --env GITHUB_ACTION_RUN=1 \ + -- scripts/tests/cirque_tests.sh bootstrap - name: Artifact suffix id: outsuffix uses: haya14busa/action-cond@v1.0.0 From 268b0c639394a118fd0fadd0c00d885860200fa5 Mon Sep 17 00:00:00 2001 From: Song Guo Date: Fri, 19 Feb 2021 22:04:42 +0800 Subject: [PATCH 4/4] Update help text --- integrations/docker/images/chip-cirque-device-base/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-cirque-device-base/build.sh b/integrations/docker/images/chip-cirque-device-base/build.sh index 8cf3c0019ebbd8..edebd59f8dbcb3 100755 --- a/integrations/docker/images/chip-cirque-device-base/build.sh +++ b/integrations/docker/images/chip-cirque-device-base/build.sh @@ -40,9 +40,10 @@ VERSION=${DOCKER_BUILD_VERSION:-$(cat version)} Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD Options: - --try-download try to download latest image from dockerhub and skip whole build procedure if success + --try-download try to download latest image from dockerhub and skip whole + build procedure if the expected image version is downloaded. --no-cache passed as a docker build argument - --latest update latest to the current built version (\"$VERSION\") + --latest update latest to the current built (or downloaded) version (\"$VERSION\") --push push image(s) to docker.io (requires docker login for \"$ORG\") --help get this message