From 01e46bec302dd5e1a089ff51e9970b79e15e6586 Mon Sep 17 00:00:00 2001 From: Daniel Kotik Date: Sat, 29 Jun 2024 23:51:41 +0200 Subject: [PATCH 1/5] Be explicit about the fetch depth --- .github/workflows/cpu-tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index 48f0a456c..8c12200ec 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -35,6 +35,8 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 + with: + fetch-depth: '1' - name: Set environment variables run: | @@ -155,6 +157,8 @@ jobs: - name: Check out repository (mala) uses: actions/checkout@v4 + with: + fetch-depth: '1' - name: Install mala package # Exec all commands inside the mala-cpu container @@ -231,6 +235,8 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 + with: + fetch-depth: '1' - name: "Prepare environment: Restore cache" if: env.DOCKER_TAG != 'latest' From b579fbf0f1d2377939b76f019d6006e9a5a5769b Mon Sep 17 00:00:00 2001 From: Daniel Kotik Date: Wed, 3 Jul 2024 18:03:51 +0200 Subject: [PATCH 2/5] Calculate short commit SHA via parameter expansion: It is not necessary to clone the source code just to calculate the short commit SHA. We can fall back on the GitHub default environment variable GITHUB_SHA and calculate the short form via bash parameter expansion. --- .github/workflows/cpu-tests.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index 8c12200ec..5022c1dc6 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -233,11 +233,6 @@ jobs: ((contains(github.ref_name, 'develop') || contains(github.ref_name, 'master')) && needs.build-docker-image-cpu.outputs.docker-tag != 'latest') || startsWith(github.ref, 'refs/tags/') steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: '1' - - name: "Prepare environment: Restore cache" if: env.DOCKER_TAG != 'latest' uses: actions/cache@v4 @@ -258,7 +253,8 @@ jobs: run: | # Execute on change of Docker image if [[ "$DOCKER_TAG" != 'latest' ]]; then - GIT_SHA=${GITHUB_REF_NAME}-$(git rev-parse --short "$GITHUB_SHA") + GITHUB_SHORT_SHA=${GITHUB_SHA:0:7} + GIT_SHA=${GITHUB_REF_NAME}-${GITHUB_SHORT_SHA} echo "GIT_SHA=$GIT_SHA" docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:latest From 20a91769ab85b3744618775d1ac32156229aa265 Mon Sep 17 00:00:00 2001 From: Daniel Kotik Date: Wed, 3 Jul 2024 21:25:43 +0200 Subject: [PATCH 3/5] Suppress verbose output from docker pull/load --- .github/workflows/cpu-tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index 5022c1dc6..6dd715a7a 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -64,7 +64,7 @@ jobs: fi - name: Pull latest image from container registry - run: docker pull $IMAGE_REPO/$IMAGE_NAME || true + run: docker pull $IMAGE_REPO/$IMAGE_NAME --quiet || true - name: Build temporary Docker image run: | @@ -133,12 +133,12 @@ jobs: - name: "Prepare environment: Load Docker image from cache" if: env.DOCKER_TAG != 'latest' - run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz + run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz --quiet - name: "Prepare environment: Pull latest image from container registry" if: env.DOCKER_TAG == 'latest' run: | - docker pull $IMAGE_REPO/$IMAGE_NAME:latest + docker pull $IMAGE_REPO/$IMAGE_NAME:latest --quiet docker image tag $IMAGE_REPO/$IMAGE_NAME:latest $IMAGE_NAME:latest - name: "Prepare environment: Run Docker container" @@ -243,11 +243,11 @@ jobs: - name: "Prepare environment: Load Docker image from cache" if: env.DOCKER_TAG != 'latest' - run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz + run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz --quiet - name: "Prepare environment: Pull latest image from container registry" if: env.DOCKER_TAG == 'latest' - run: docker pull $IMAGE_REPO/$IMAGE_NAME:latest + run: docker pull $IMAGE_REPO/$IMAGE_NAME:latest --quiet - name: Tag Docker image run: | From b64fb14891503c9e59fa9a73ff2d7c1492b793c1 Mon Sep 17 00:00:00 2001 From: Daniel Kotik Date: Wed, 3 Jul 2024 21:26:16 +0200 Subject: [PATCH 4/5] Suppress detailed layer status while pushing images: The `--quiet` is too quiet, we still want to see the tags/digests pushed. --- .github/workflows/cpu-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index 6dd715a7a..a3436e27e 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -274,4 +274,4 @@ jobs: run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push Docker image - run: docker push $IMAGE_REPO/$IMAGE_NAME --all-tags + run: docker push $IMAGE_REPO/$IMAGE_NAME --all-tags | grep -v -E 'Waiting|Layer already|Preparing|Pushed' From 92eb513a9d4a0918e7a83bb6e16216dd4e931982 Mon Sep 17 00:00:00 2001 From: Daniel Kotik Date: Wed, 3 Jul 2024 22:49:51 +0200 Subject: [PATCH 5/5] Refactor a bit --- .github/workflows/cpu-tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cpu-tests.yml b/.github/workflows/cpu-tests.yml index a3436e27e..780ed9a6a 100644 --- a/.github/workflows/cpu-tests.yml +++ b/.github/workflows/cpu-tests.yml @@ -253,12 +253,9 @@ jobs: run: | # Execute on change of Docker image if [[ "$DOCKER_TAG" != 'latest' ]]; then - GITHUB_SHORT_SHA=${GITHUB_SHA:0:7} - GIT_SHA=${GITHUB_REF_NAME}-${GITHUB_SHORT_SHA} - echo "GIT_SHA=$GIT_SHA" docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:latest - docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:$GIT_SHA + docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:${GITHUB_REF_NAME}-${GITHUB_SHA:0:7} fi # Execute on push of git tag