From 67cfdbfe11614db30af994644fd70c4c494930f1 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Fri, 9 Aug 2024 16:11:06 +0100 Subject: [PATCH] ci: support eravm and evm execution targets (#84) --- .github/workflows/ccache-regen.yml | 2 +- .github/workflows/sanitizers.yml | 22 ++++++------- .github/workflows/tests.yaml | 44 +++++++++++++++++++++++-- solidity_adapter/src/index/test_file.rs | 10 +++--- solidity_adapter/src/test/mod.rs | 5 +-- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ccache-regen.yml b/.github/workflows/ccache-regen.yml index 91470fce..168ec0e4 100644 --- a/.github/workflows/ccache-regen.yml +++ b/.github/workflows/ccache-regen.yml @@ -14,7 +14,7 @@ jobs: ccache-regen: runs-on: [ci-runner-compiler, Linux] container: - image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest + image: ghcr.io/matter-labs/zksync-llvm-runner:latest options: -m 110g steps: diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 5f018726..487580a8 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -32,10 +32,11 @@ jobs: run-with-sanitizers: runs-on: [ci-runner-compiler, Linux] container: - image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest + image: ghcr.io/matter-labs/zksync-llvm-runner:latest options: -m 110g env: TARGET: x86_64-unknown-linux-gnu + RUSTC_BOOTSTRAP: 1 steps: - name: Checkout compiler-tester @@ -49,33 +50,30 @@ jobs: sanitizer: ${{ inputs.llvm-sanitizer }} enable-assertions: true - - name: Install rustc nightly - run: | - rustup install nightly-${TARGET} - rustup component add rust-src --toolchain nightly-${TARGET} - - name: Build compiler-tester env: RUSTFLAGS: "-Z sanitizer=${{ inputs.rust-sanitizer }}" - run: cargo +nightly build --release --target ${TARGET} -Zbuild-std --bin 'compiler-tester' + run: | + rustup component add rust-src --toolchain "$(rustc --version | cut -d ' ' -f2)-${TARGET}" + cargo build --target ${TARGET} -Zbuild-std --bin 'compiler-tester' - name: Build zksolc and zkvyper env: CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts RUSTFLAGS: "-Z sanitizer=${{ inputs.rust-sanitizer }}" run: | - cargo +nightly build --release --target ${TARGET} -Zbuild-std \ + cargo build --target ${TARGET} -Zbuild-std \ --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \ --target-dir './target-zksolc/' - cargo +nightly build --release --target ${TARGET} -Zbuild-std \ + cargo build --target ${TARGET} -Zbuild-std \ --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \ --target-dir './target-zkvyper/' - name: Run tests with sanitizers run: | set -x - ./target/${TARGET}/release/compiler-tester \ - --zksolc "./target-zksolc/${TARGET}/release/zksolc" \ - --zkvyper "./target-zkvyper/${TARGET}/release/zkvyper" \ + ./target/${TARGET}/debug/compiler-tester \ + --zksolc "./target-zksolc/${TARGET}/debug/zksolc" \ + --zkvyper "./target-zkvyper/${TARGET}/debug/zkvyper" \ --path '${{ inputs.path }}' --mode '${{ inputs.mode }}' diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2cf75310..f0f2ba9e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -45,14 +45,13 @@ jobs: cargo-check: runs-on: [ci-runner-compiler, Linux] container: - image: ghcr.io/matter-labs/llvm_runner/ubuntu22-llvm17:latest + image: ghcr.io/matter-labs/zksync-llvm-runner:latest steps: - uses: actions/checkout@v4 - name: Build LLVM uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1 with: - enable-tests: true enable-assertions: true ccache-key-type: static @@ -61,22 +60,62 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} + + # Define target for integration tests and benchmarks + # based on PR title labels + target-machine: + runs-on: ubuntu-latest + outputs: + evm: ${{ steps.evm.outputs.machine }} + eravm: ${{ steps.eravm.outputs.machine }} + default: ${{ steps.default.outputs.machine }} + steps: + + - name: Check for EraVM target + id: eravm + if: contains(github.event.pull_request.title, '(EraVM)') + run: echo "machine=EraVM" | tee -a "${GITHUB_OUTPUT}" + + - name: Check for EVM target + id: evm + if: contains(github.event.pull_request.title, '(EVM)') + run: echo "machine=EVM" | tee -a "${GITHUB_OUTPUT}" + + - name: Check for default target + id: default + shell: bash -ex {0} + run: | + if [[ "${{ join(steps.*.outputs.*) }}" == "" ]]; then + echo "machine=default" | tee -a "${GITHUB_OUTPUT}" + fi + # Integration tests workflow call from the era-compiler-ci repository # This is a common part of the integration tests workflow for all repositories # If you would like to make a change to the integration tests workflow, please do it in the era-compiler-ci repository integration-tests: + needs: target-machine uses: matter-labs/era-compiler-ci/.github/workflows/integration-tests.yaml@v1 secrets: inherit + strategy: + fail-fast: false + matrix: + target: ${{ needs.target-machine.outputs.* }} with: compiler-tester-repo: ${{ github.event.pull_request.head.repo.full_name }} # required to properly test forks ccache-key-type: static + target-machine: ${{ matrix.target }} # Benchmarks workflow call from the era-compiler-ci repository # This is a common part of the benchmarks workflow for all repositories # If you would like to make a change to the benchmarks workflow, please do it in the era-compiler-ci repository benchmarks: + needs: target-machine uses: matter-labs/era-compiler-ci/.github/workflows/benchmarks.yml@v1 secrets: inherit + strategy: + fail-fast: false + matrix: + target: ${{ needs.target-machine.outputs.* }} with: compiler_tester_reference_branch: ${{ github.event.inputs.compiler_tester_reference_branch || 'main' }} compiler_tester_candidate_branch: ${{ github.event.inputs.compiler_tester_candidate_branch || '' }} @@ -86,6 +125,7 @@ jobs: compiler_llvm_benchmark_path: ${{ github.event.inputs.compiler_llvm_benchmark_path || '' }} compiler-tester-repo: ${{ github.event.pull_request.head.repo.full_name }} ccache-key-type: static + target-machine: ${{ matrix.target }} # Special job that allows some of the jobs to be skipped or failed # requiring others to be successful diff --git a/solidity_adapter/src/index/test_file.rs b/solidity_adapter/src/index/test_file.rs index 84deaec7..70d21897 100644 --- a/solidity_adapter/src/index/test_file.rs +++ b/solidity_adapter/src/index/test_file.rs @@ -44,8 +44,9 @@ impl TryFrom<&Path> for TestFile { let mut file = fs::File::open(value)?; let mut data = String::new(); - file.read_to_string(&mut data) - .map_err(|error| anyhow::anyhow!("Failed to read test file (2, {:?}): {}", file, error))?; + file.read_to_string(&mut data).map_err(|error| { + anyhow::anyhow!("Failed to read test file (2, {:?}): {}", file, error) + })?; let hash = Self::md5(data.as_str()); @@ -72,8 +73,9 @@ impl TestFile { .ok_or_else(|| anyhow::anyhow!("Test file hash is None: {:?}", path))?; let mut file = fs::File::open(path)?; let mut data = String::new(); - file.read_to_string(&mut data) - .map_err(|error| anyhow::anyhow!("Failed to read test file (3, {:?}): {}", file, error))?; + file.read_to_string(&mut data).map_err(|error| { + anyhow::anyhow!("Failed to read test file (3, {:?}): {}", file, error) + })?; let actual_hash = Self::md5(data.as_str()); Ok(!saved_hash.eq(&actual_hash)) } diff --git a/solidity_adapter/src/test/mod.rs b/solidity_adapter/src/test/mod.rs index 145d0884..f20a5248 100644 --- a/solidity_adapter/src/test/mod.rs +++ b/solidity_adapter/src/test/mod.rs @@ -35,8 +35,9 @@ impl TryFrom<&Path> for Test { let mut file = fs::File::open(path)?; let mut data = String::new(); - file.read_to_string(&mut data) - .map_err(|error| anyhow::anyhow!("Failed to read test file (1, {:?}): {}", file, error))?; + file.read_to_string(&mut data).map_err(|error| { + anyhow::anyhow!("Failed to read test file (1, {:?}): {}", file, error) + })?; let comment_start = if path .extension()