Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter committed Dec 19, 2024
1 parent 3c9c190 commit b731c97
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 34 deletions.
95 changes: 62 additions & 33 deletions .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- db/multi-platform-docker
tags:
- "*"

Expand All @@ -11,74 +12,102 @@ 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:
registry: ghcr.io
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
3 changes: 2 additions & 1 deletion .github/workflows/e2e-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/test/anvil-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b731c97

Please sign in to comment.