From e8575f649ae21ed463aacc27c8dbafd2e7244af7 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Thu, 1 Aug 2024 17:01:06 +0200 Subject: [PATCH] Test uber cache --- .github/workflows/build_and_test.yml | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4c678ca4..aa5cb1d0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -26,9 +26,25 @@ jobs: with: auto-commit: "true" + build-cache-check: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - uses: actions/cache@v4 + id: cache + with: + path: path/to/dependencies + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} + lookup-only: true + build-test: runs-on: ubuntu-latest - needs: pre-commit + needs: build-cache-check + if: ! needs.build-cache-check.outputs.cache-hit steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -70,13 +86,12 @@ jobs: run: | docker save -o /tmp/alfresco-docker-images.tar $(docker images --format "{{.Repository}}:{{.Tag}}" | grep alfresco) - - name: Upload images as artifact - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + - name: Save docker archive + id: cache-save + uses: actions/cache/save@v4 with: - name: docker-images path: /tmp/alfresco-docker-images.tar - retention-days: 1 - compression-level: 0 + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} compose-test: name: compose-test ${{ matrix.docker-compose-file }} @@ -88,12 +103,12 @@ jobs: steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 - - - name: Download artifacts - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + + - name: Restore cache + uses: actions/cache/restore@v4 with: - path: /tmp - name: docker-images + path: /tmp/alfresco-docker-images.tar + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} - name: Load Docker images run: |