From b731c97f764ab70b0836a6e8bb1e9842ac759fe4 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 19 Dec 2024 11:37:14 -0600 Subject: [PATCH] debug --- .github/workflows/build-push-docker.yml | 95 ++++++++++++++++--------- .github/workflows/e2e-docker.yml | 3 +- e2e-tests/test/anvil-apis.test.ts | 3 + 3 files changed, 67 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yml index 8a339362..03503729 100644 --- a/.github/workflows/build-push-docker.yml +++ b/.github/workflows/build-push-docker.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - db/multi-platform-docker tags: - "*" @@ -11,38 +12,81 @@ concurrency: cancel-in-progress: true jobs: - build-push-image: - name: Build and push Docker image - runs-on: [matterlabs-ci-runner] - strategy: - matrix: - platform: [linux/amd64, linux/arm64] + set-tags: + name: Set Docker Tags + runs-on: ubuntu-latest + outputs: + base_tag: ${{ steps.set_tag.outputs.base_tag }} steps: - uses: actions/checkout@v4 - - name: Set git SHA + - name: Set Git SHA id: git_sha run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Set Docker tag - id: docker_tag + - name: Determine Base Tag + id: set_tag run: | ts=$(date +%s%N | cut -b1-13) if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - echo "tag=${{ steps.git_sha.outputs.sha_short }}-${ts}" >> $GITHUB_OUTPUT + echo "base_tag=${{ steps.git_sha.outputs.sha_short }}-${ts}" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == "refs/heads/db/multi-platform-docker" ]]; then + echo "base_tag=${{ steps.git_sha.outputs.sha_short }}-${ts}" >> $GITHUB_OUTPUT elif [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + echo "base_tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT elif [[ "${{ github.event_name }}" == "pull_request" ]]; then - echo "tag=none" >> $GITHUB_OUTPUT + echo "base_tag=none" >> $GITHUB_OUTPUT else - echo "Unsupported event ${GITHUB_EVENT_NAME} or ref ${GITHUB_REF}, only refs/heads/, refs/tags/ and pull_request are supported." + echo "Unsupported event ${GITHUB_EVENT_NAME} or ref ${GITHUB_REF}. Only refs/heads/main, refs/tags/*, and pull_request are supported." exit 1 fi + # 2. Build and Push Docker Images for Each Architecture + build-push-image: + name: Build and Push Docker Image for ${{ matrix.arch }} + runs-on: [matterlabs-ci-runner-high-performance] + needs: set-tags + strategy: + matrix: + include: + - platform: linux/amd64 + arch: amd64 + - platform: linux/arm64 + arch: arm64 + steps: + - uses: actions/checkout@v4 + + - name: Set Base Docker Tag + run: echo "BASE_TAG=${{ needs.set-tags.outputs.base_tag }}" >> $GITHUB_ENV + + - name: Set Repository Owner + run: echo "REPO_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV + + - name: Set Full Docker Tags + id: full_tags + run: | + base_tag="${{ env.BASE_TAG }}" + arch="${{ matrix.arch }}" + repo_owner="${{ env.REPO_OWNER }}" + if [[ "$base_tag" == "none" ]]; then + echo "tags=none" >> $GITHUB_OUTPUT + exit 0 + fi + + full_tags="us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${base_tag}-${arch} + ghcr.io/${repo_owner}/anvil-zksync:${base_tag}-${arch} + us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${base_tag} + + ghcr.io/${repo_owner}/anvil-zksync:${base_tag} + us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:latest + ghcr.io/${repo_owner}/anvil-zksync:latest" + + echo "tags=${full_tags}" >> $GITHUB_OUTPUT + - name: Login to GAR run: | gcloud auth configure-docker us-docker.pkg.dev -q - + - name: Login to GHCR uses: docker/login-action@v3 with: @@ -50,35 +94,20 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx + - name: Set Up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Cache Docker Layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: buildx-cache-${{ github.sha }} - restore-keys: | - buildx-cache- - - name: Build and push Docker image id: docker_build uses: docker/build-push-action@v6 with: context: . - push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} + push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/db/multi-platform-docker' || startsWith(github.ref, 'refs/tags/')) }} platforms: ${{ matrix.platform }} cache-from: type=gha cache-to: type=gha,mode=max - tags: | - us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:${{ steps.docker_tag.outputs.tag }} - us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync:latest - ghcr.io/${{ github.repository_owner }}/anvil-zksync:${{ steps.docker_tag.outputs.tag }} - ghcr.io/${{ github.repository_owner }}/anvil-zksync:latest + tags: ${{ steps.full_tags.outputs.tags }} - name: Print image digest to summary run: | - echo "Image tag: ${{ steps.docker_tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "Image tags: ${{ steps.full_tags.outputs.tags }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/e2e-docker.yml b/.github/workflows/e2e-docker.yml index 78e0eb2e..68b8a4b9 100644 --- a/.github/workflows/e2e-docker.yml +++ b/.github/workflows/e2e-docker.yml @@ -67,10 +67,11 @@ jobs: - name: Compile contracts and run e2e tests working-directory: ./e2e-tests + env: + ANVIL_LOG_PATH: "${{ github.workspace }}/logs/anvil-zksync.log" run: | echo "Compiling contracts and running e2e tests..." yarn hardhat compile - export ANVIL_LOG_PATH=/logs/anvil-zksync.log yarn test - name: Stop Docker container diff --git a/e2e-tests/test/anvil-apis.test.ts b/e2e-tests/test/anvil-apis.test.ts index 07af0d7a..58ddcca5 100644 --- a/e2e-tests/test/anvil-apis.test.ts +++ b/e2e-tests/test/anvil-apis.test.ts @@ -93,6 +93,9 @@ describe("anvil_setLoggingEnabled", function () { it("Should disable and enable logging", async function () { const logFilePath = process.env.ANVIL_LOG_PATH || path.resolve("../anvil-zksync.log"); + console.log(`ANVIL_LOG_PATH: ${process.env.ANVIL_LOG_PATH}`); + console.log(`Using logFilePath: ${logFilePath}`); + // Arrange const wallet = new Wallet(RichAccounts[0].PrivateKey, provider); const userWallet = Wallet.createRandom().connect(provider);