Continuous Integration

Use a GitHub Action to integrate anvil-zksync into your CI/CD environment.

A GitHub Action is available for integrating anvil-zksync into your CI/CD environments. This action offers high configurability and streamlines the process of testing your applications in an automated way.

You can find the GitHub Action available in the marketplace.

In CI tests, use 127.0.0.1 as the URL in hardhat.config.ts or for the provider to avoid 'Cannot connect to network' errors.

Configuration Options

OptionDescriptionRequiredDefaultOptions
modeOperation mode.Norunrun, fork
networkNetwork selection.No--
forkAtHeightBlock height to fork at.No--
portListening port.No8011-
showCallsCall debug visibility.Nononenone, user, system, all
showStorageLogsStorage log visibility.Nononenone, read, write, all
showVmDetailsVM details visibility.Nononenone, all
showGasDetailsGas details visibility.Nononenone, all
resolveHashesEnable hash resolution.Nofalse-
logLog filter level.Noinfodebug, info, warn, error
logFilePathPath for the log file.Noanvil-zksync.log-
targetTarget architecture.Nox86_64-unknown-linux-gnux86_64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin
versionVersion of anvil-zksync.Nolatest-

Examples

The following are examples of configuration for your GitHub Action.

Quickstart

name: Run anvil-zksync Action

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run anvil-zksync
        uses: dutterbutter/anvil-zksync-action@v1

Advanced

With configuration options:

name: Run anvil-zksync Action

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run anvil-zksync
        uses: dutterbutter/anvil-zksync-action@v1
        with:
          mode: "run"
          showCalls: "user"
          showStorageLogs: "read"
          showVmDetails: "all"
          showGasDetails: "all"
          resolveHashes: "true"
          log: "info"
          logFilePath: "anvil-zksync.log"
          target: "x86_64-unknown-linux-gnu"

With upload log file to artifacts:

name: Run anvil-zksync Action

on:
  pull_request:
    branches: [main]
  workflow_dispatch:
jobs:
  test:
    name: unit-tests
    strategy:
      matrix:
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3

      - name: Run anvil-zksync
        uses: dutterbutter/anvil-zksync-action@v1
        with:
          mode: "fork"
          network: "mainnet"
          forkAtHeight: "1855248"
          showCalls: "user"
          showStorageLogs: "read"
          showVmDetails: "all"
          showGasDetails: "all"
          resolveHashes: "true"
          log: "info"
          logFilePath: "anvil-zksync.log"
          target: "x86_64-unknown-linux-gnu"
          releaseTag: "latest"

      - name: Install Dependencies
        run: yarn install

      - name: Run Tests
        run: |
          yarn test:contracts

      - name: Upload anvil-zksync log
        uses: actions/upload-artifact@v3
        with:
          name: anvil-zksync-log
          path: anvil-zksync.log

With Fork:

name: Run anvil-zksync Action

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run anvil-zksync
        uses: dutterbutter/anvil-zksync-action@v1
        with:
          mode: "fork"
          network: "mainnet"
          forkAtHeight: "1855248"
          showCalls: "user"
          showStorageLogs: "read"
          showVmDetails: "all"
          showGasDetails: "all"
          resolveHashes: "true"
          log: "info"
          logFilePath: "anvil-zksync.log"
          target: "x86_64-unknown-linux-gnu"
          releaseTag: "latest"

Made with ❤️ by the ZKsync Community