From 9cbf20f85fa944766d935fd950a0277e87a4d937 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Tue, 22 Oct 2024 21:33:06 -0500 Subject: [PATCH] chore: add short lived cache key --- .github/workflows/e2e-test2.yml | 79 +++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/.github/workflows/e2e-test2.yml b/.github/workflows/e2e-test2.yml index 71114b9144d..ef82d211263 100644 --- a/.github/workflows/e2e-test2.yml +++ b/.github/workflows/e2e-test2.yml @@ -30,6 +30,9 @@ jobs: fail-fast: false steps: + - id: vars + run: echo "short_sha=${GITHUB_SHA:0:7}" >> $GITHUB_ENV + - uses: actions/checkout@v4 - name: Install Nix @@ -53,7 +56,8 @@ jobs: target .buckd buck-out/cache - key: buck2-${{ runner.os }}-${{ matrix.target }} + key: b2-${{ matrix.target }}-${{ env.short_sha }} + enableCrossOsArchive: true tests: name: execute via bats @@ -62,6 +66,16 @@ jobs: needs: build steps: + - id: vars + run: echo "short_sha=${GITHUB_SHA:0:7}" >> $GITHUB_ENV + + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + root-reserve-mb: 15360 + temp-reserve-mb: 12288 + remove-dotnet: "true" + - uses: actions/checkout@v4 - name: Install Nix @@ -70,18 +84,57 @@ jobs: - name: Run the Magic Nix Cache uses: DeterminateSystems/magic-nix-cache-action@v8 - - uses: actions/cache/restore@v4 - with: - path: | - ~/.buck2 - buck-out - .buck-cache - prebuilt - installed - target - .buckd - buck-out/cache - key: buck2-${{ runner.os }}- + - name: Restore cache with retry + run: | + for i in {1..3}; do + gh extension install actions/gh-actions-cache + + KEYS=$(gh actions-cache list -B main -L 100 | grep -o 'b2-.*') + for key in $KEYS; do + gh actions-cache restore $key && break + sleep 2 + done + + if [ $? -eq 0 ]; then + break + fi + + echo "Attempt $i failed, retrying..." + sleep 5 + done + env: + GH_TOKEN: ${{ github.token }} + + # - uses: actions/cache/restore@v4 + # with: + # path: | + # ~/.buck2 + # buck-out + # .buck-cache + # prebuilt + # installed + # target + # .buckd + # buck-out/cache + # key: | + # b2-//core/api-${{ env.short_sha }} + # b2-//core/api-ws-server-${{ env.short_sha }} + # b2-//core/api-trigger-${{ env.short_sha }} + # b2-//core/api-exporter-${{ env.short_sha }} + # b2-//apps/dashboard-${{ env.short_sha }} + # b2-//apps/consent-${{ env.short_sha }} + # b2-//apps/pay-${{ env.short_sha }} + # b2-//apps/admin-panel-${{ env.short_sha }} + # b2-//apps/map-${{ env.short_sha }} + # b2-//apps/voucher-${{ env.short_sha }} + # b2-//core/api-keys-${{ env.short_sha }} + # b2-//core/notifications-${{ env.short_sha }} + # b2-//bats/helpers/callback:run-${{ env.short_sha }} + # b2-//bats/helpers/subscriber:run-${{ env.short_sha }} + # b2-//bats/helpers/totp:generate-${{ env.short_sha }} + # restore-keys: | + # b2- + # fail-on-cache-miss: true - name: Run bats tests run: |