From c45741ca82205d95af9efb9845214e37881b65e6 Mon Sep 17 00:00:00 2001 From: jfldde <168934971+jfldde@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:40:56 +0000 Subject: [PATCH] CI: Cache docker image (#1470) --- .github/workflows/checks.yml | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fb7546d68..ba0b28640 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,6 +59,7 @@ env: CARGO_TERM_COLOR: always RUSTFLAGS: -D warnings FOUNDRY_PROFILE: ci + TEST_BITCOIN_DOCKER: "bitcoin/bitcoin:28.0" # Automatically cancels a job if a new commit if pushed to the same PR, branch, or tag. # Source: @@ -178,6 +179,7 @@ jobs: command: check coverage: + needs: docker-setup runs-on: ubicloud-standard-16 if: github.event.pull_request.draft == false steps: @@ -198,6 +200,16 @@ jobs: with: key: "eth-tests-1c23e3c" path: crates/evm/ethereum-tests + + - name: Restore cached Docker image + uses: actions/cache@v3 + with: + path: /tmp/docker + key: ${{ runner.os }}-docker-${{ env.TEST_BITCOIN_DOCKER }} + + - name: Load Docker image + run: docker load < /tmp/docker/bitcoin.tar + - name: Run coverage run: make coverage env: @@ -339,6 +351,7 @@ jobs: run: make check-no-std nextest: + needs: docker-setup name: nextest runs-on: ubicloud-standard-16 timeout-minutes: 60 @@ -366,11 +379,21 @@ jobs: with: key: "eth-tests-1c23e3c" path: crates/evm/ethereum-tests + + - name: Restore cached Docker image + uses: actions/cache@v3 + with: + path: /tmp/docker + key: ${{ runner.os }}-docker-${{ env.TEST_BITCOIN_DOCKER }} + + - name: Load Docker image + run: docker load < /tmp/docker/bitcoin.tar + - name: Run nextest run: make test env: RUST_BACKTRACE: 1 - RISC0_DEV_MODE: 1 # This is needed to generate mock proofs and verify them + RISC0_DEV_MODE: 1 # This is needed to generate mock proofs and verify them TEST_BITCOIN_DOCKER: 1 CI_TEST_MODE: 1 CITREA_E2E_TEST_BINARY: ${{ github.workspace }}/target/debug/citrea @@ -457,3 +480,34 @@ jobs: with: expected_da_id: ${{ vars.EXPECTED_BITCOIN_DA_ID }} action: check_binary + + docker-setup: + runs-on: ubicloud-standard-2 + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Cache Docker images + id: cache-docker + uses: actions/cache@v3 + with: + path: /tmp/docker + key: ${{ runner.os }}-docker-${{ env.TEST_BITCOIN_DOCKER }} + + - name: Pull Docker image + if: steps.cache-docker.outputs.cache-hit != 'true' + run: | + docker pull ${{ env.TEST_BITCOIN_DOCKER }} + mkdir -p /tmp/docker + docker save ${{ env.TEST_BITCOIN_DOCKER }} > /tmp/docker/bitcoin.tar + + - name: Load Docker image from cache + if: steps.cache-docker.outputs.cache-hit == 'true' + run: | + docker load < /tmp/docker/bitcoin.tar