From 8790240f95211b586df6ac5a9a0c1d948b425aa7 Mon Sep 17 00:00:00 2001 From: Artem Makhortov <13339874+artmakh@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:26:22 +0700 Subject: [PATCH] fix(ci): Conditional to build contracts in new CI (#3106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Do not build contracts if not needed in new CI ## Why ❔ Speed up CI ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --- .github/workflows/ci.yml | 5 ++++ .../new-build-contract-verifier-template.yml | 25 ++++++------------- .github/workflows/new-build-core-template.yml | 25 ++++++------------- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47ae3c517517..2f29fe98f0e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,9 @@ jobs: - '!prover/extract-setup-data-keys.sh' - 'docker/prover*/**' - '.github/workflows/build-prover-template.yml' + - '.github/workflows/new-build-prover-template.yml' + - '.github/workflows/build-witness-generator-template.yml' + - '.github/workflows/new-build-witness-generator-template.yml' - '.github/workflows/ci-prover-reusable.yml' - 'docker-compose-runner-nightly.yml' - '!**/*.md' @@ -53,7 +56,9 @@ jobs: - 'docker/external-node/**' - 'docker/server/**' - '.github/workflows/build-core-template.yml' + - '.github/workflows/new-build-core-template.yml' - '.github/workflows/build-contract-verifier-template.yml' + - '.github/workflows/new-build-contract-verifier-template.yml' - '.github/workflows/ci-core-reusable.yml' - '.github/workflows/ci-core-lint-reusable.yml' - 'Cargo.toml' diff --git a/.github/workflows/new-build-contract-verifier-template.yml b/.github/workflows/new-build-contract-verifier-template.yml index b5286782fad7..9b23cda6f02a 100644 --- a/.github/workflows/new-build-contract-verifier-template.yml +++ b/.github/workflows/new-build-contract-verifier-template.yml @@ -74,36 +74,30 @@ jobs: tar -C ./contracts -zxf system-contracts.tar.gz - name: Install Apt dependencies + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config - name: Install Node + if: env.BUILD_CONTRACTS == 'true' uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 20 cache: 'npm' - name: Install Yarn + if: env.BUILD_CONTRACTS == 'true' run: npm install -g yarn - name: Setup rust + if: env.BUILD_CONTRACTS == 'true' uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0 with: toolchain: nightly-2024-08-01 - - name: Install cargo-nextest from crates.io - uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1 - with: - crate: cargo-nextest - - - name: Install sqlx-cli from crates.io - uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1 - with: - crate: sqlx-cli - tag: 0.8.1 - - name: Install foundry-zksync + if: env.BUILD_CONTRACTS == 'true' run: | mkdir ./foundry-zksync curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz @@ -112,6 +106,7 @@ jobs: echo "$PWD/foundry-zksync" >> $GITHUB_PATH - name: Pre-download compilers + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | # Download needed versions of vyper compiler @@ -129,18 +124,14 @@ jobs: chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}" done - - name: init - shell: bash - run: | - mkdir -p ./volumes/postgres - docker compose up -d postgres - - name: Install zkstack + if: env.BUILD_CONTRACTS == 'true' run: | ./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup zkstackup --local || true - name: build contracts + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | cp etc/tokens/{test,localhost}.json diff --git a/.github/workflows/new-build-core-template.yml b/.github/workflows/new-build-core-template.yml index e8a41a7e0646..c4aeb9180fda 100644 --- a/.github/workflows/new-build-core-template.yml +++ b/.github/workflows/new-build-core-template.yml @@ -79,36 +79,30 @@ jobs: tar -C ./contracts -zxf system-contracts.tar.gz - name: Install Apt dependencies + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config - name: Install Node + if: env.BUILD_CONTRACTS == 'true' uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 20 cache: 'npm' - name: Install Yarn + if: env.BUILD_CONTRACTS == 'true' run: npm install -g yarn - name: Setup rust + if: env.BUILD_CONTRACTS == 'true' uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0 with: toolchain: nightly-2024-08-01 - - name: Install cargo-nextest from crates.io - uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1 - with: - crate: cargo-nextest - - - name: Install sqlx-cli from crates.io - uses: baptiste0928/cargo-install@904927dbe77864e0f2281519fe9d5bd097a220b3 # v3.1.1 - with: - crate: sqlx-cli - tag: 0.8.1 - - name: Install foundry-zksync + if: env.BUILD_CONTRACTS == 'true' run: | mkdir ./foundry-zksync curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz @@ -117,6 +111,7 @@ jobs: echo "$PWD/foundry-zksync" >> $GITHUB_PATH - name: Pre-download compilers + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | # Download needed versions of vyper compiler @@ -134,18 +129,14 @@ jobs: chmod +x "./hardhat-nodejs/compilers-v2/$compiler/${compiler}-v${version}" done - - name: init - shell: bash - run: | - mkdir -p ./volumes/postgres - docker compose up -d postgres - - name: Install zkstack + if: env.BUILD_CONTRACTS == 'true' run: | ./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup zkstackup --local || true - name: build contracts + if: env.BUILD_CONTRACTS == 'true' shell: bash run: | cp etc/tokens/{test,localhost}.json