From 6738530c9856b8331048f4fed14867d5bce8dacc Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 23 Feb 2021 04:41:19 +0800 Subject: [PATCH] [cirque] Download `chip-cirque-device-base` from docker hub when available (#4940) * [cirque] Only build docker image when the image does not exists on dockerhub * Update test warpper * Add GITHUB_ACTION_RUN=1 for cirque bootstrap * Update help text --- .github/workflows/cirque.yaml | 4 +++- .../images/chip-cirque-device-base/build.sh | 21 +++++++++++++++---- scripts/tests/cirque_tests.sh | 8 ++++++- 3 files changed, 27 insertions(+), 6 deletions(-) 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 diff --git a/integrations/docker/images/chip-cirque-device-base/build.sh b/integrations/docker/images/chip-cirque-device-base/build.sh index 983d0288297075..edebd59f8dbcb3 100755 --- a/integrations/docker/images/chip-cirque-device-base/build.sh +++ b/integrations/docker/images/chip-cirque-device-base/build.sh @@ -40,10 +40,12 @@ 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 the expected image version is downloaded. + --no-cache passed as a docker build argument + --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 " exit 0 @@ -58,6 +60,17 @@ set -ex [[ -n $VERSION ]] || die "version cannot be empty" +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 + # 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..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 + + 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