Skip to content

ci: test optimizations #4

ci: test optimizations

ci: test optimizations #4

name: Build contracts
# ===========================================================================
# Build contracts workflow
#
# Builds l1, l2, system and da contracts and uploads them as artifacts.
# Artifact contains a commit hash of the contracts submodule
# by which the contracts are identified to be downloaded in PR testing.
# If no contracts were changed, the workflow is skipped.
# If contracts were changed, the new version of contracts will be published.
# It also allows manual triggering of the workflow with a specific contracts
# commit to allow testing of different prebuilt contracts versions.
# ===========================================================================
# Set proper subset of permissions
permissions:
contents: read
pull-requests: write
# Define the events that triggers the workflow
on:
push:
branches:
- main
workflow_dispatch:
inputs:
commit:
type: string
description: SHA commit for build
required: false
pull_request: # TODO: remove after testing
# Do not cancel runs, put new merges in queue
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false
jobs:
# =================================================
# Aux job to check if contracts were changed
#
# Checks if contracts were changed.
# Saves the commit hash of the contracts submodule
# if contracts required to be rebuild.
# =================================================
check-contracts:
runs-on: ubuntu-latest
outputs:
release_required: ${{ steps.changed-files.outputs.any_changed }}
commit: ${{ steps.contracts-commit.outputs.commit }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: '1'
- name: Check contracts changes
id: changed-files
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
with:
fetch_additional_submodule_history: true
files: |
contracts
contracts/**
- name: Define contracts commit
# if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: contracts-commit
run: echo "commit=$(cd contracts && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
# ===================================================================
# Rebuild contracts job
#
# Rebuilds contracts if they were changed.
# Uploads the artifacts with contracts to be downloaded by PR tests.
# ===================================================================
prebuild-contracts:
needs: check-contracts
runs-on: matterlabs-ci-runner-highmem-long
if: ${{ needs.check-contracts.outputs.commit != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "false"
- name: Clean-up contracts
run: rm -rf contracts
# Special setup if we need to prebuild contracts for a specific commit
- name: Checkout contracts
uses: actions/checkout@v4
with:
repository: 'matter-labs/era-contracts'
ref: ${{ inputs.commit || needs.check-release.outputs.commit }}
path: contracts
submodules: "recursive"
- name: Setup runner
uses: matter-labs/zksync-ci-common/.github/actions/runner-setup@aba-ci-optimize
with:
enable_cache: false
- name: Build contracts
run: zkstack dev contracts
- name: Prepare artifacts
working-directory: contracts
run: |
for DIR in l1-contracts l2-contracts system-contracts da-contracts; do
rm -rf ./${DIR}/node_modules
tar -czvf ${DIR}.tar.gz ./${DIR}
done
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: |
contracts/l1-contracts.tar.gz
contracts/l2-contracts.tar.gz
contracts/system-contracts.tar.gz
contracts/da-contracts.tar.gz
name: contracts-${{ inputs.commit || needs.check-release.outputs.commit }}