From bb8d98757b98a7c9fa3d42c9e0de3e905c2828d3 Mon Sep 17 00:00:00 2001 From: Anton Baliasnikov Date: Mon, 29 Jul 2024 10:30:34 +0100 Subject: [PATCH] feat: support target, sanitizer, and coverage parameters --- .github/actions/build-llvm/action.yml | 24 +++++++++++++++++++++--- .github/workflows/benchmarks.yml | 16 +++++++++++++--- .github/workflows/integration-tests.yaml | 18 ++++++++++++++---- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.github/actions/build-llvm/action.yml b/.github/actions/build-llvm/action.yml index afd2448..4faa1ed 100644 --- a/.github/actions/build-llvm/action.yml +++ b/.github/actions/build-llvm/action.yml @@ -16,6 +16,18 @@ inputs: description: "Enable assertions." required: false default: 'true' + enable-coverage: + description: "Enable coverage." + required: false + default: 'false' + sanitizer: + description: 'A sanitizer to build LLVM with. Possible values are Address, Memory, MemoryWithOrigins, Undefined, Thread, DataFlow, and Address;Undefined' + required: false + default: '' + default-target-triple: + description: 'Default target to triple build LLVM for. Possible values are `eravm`, `evm`, or leave empty for default target.' + required: false + default: '' extra-args: description: 'Extra CMake arguments to compile LLVM.' required: false @@ -35,7 +47,7 @@ inputs: llvm-builder-version: description: 'Version of the LLVM builder to use.' required: false - default: '1.0.26' + default: '1.0.29' ccache-key: description: 'Github Actions cache key for CCache.' required: false @@ -122,6 +134,7 @@ runs: - name: Build LLVM shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }} env: + VERBOSE: 1 CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_NOHASHDIR: "true" CCACHE_COMPILERCHECK: "content" @@ -131,6 +144,11 @@ runs: [ "${{ inputs.build-type }}" = "debug" ] && DEBUG_ARG="--debug" [ "${{ inputs.enable-tests }}" = "true" ] && ENABLE_TESTS="--enable-tests" [ "${{ inputs.enable-assertions }}" = "true" ] && ENABLE_ASSERTIONS="--enable-assertions" + [ "${{ inputs.enable-coverage }}" = "true" ] && ENABLE_COVERAGE="--enable-coverage" [ "${{ inputs.extra-args }}" != "" ] && EXTRA_ARGS="--extra-args ${{ inputs.extra-args }}" - zksync-llvm build --target-env ${{ inputs.target-env }} \ - --use-ccache ${{ inputs.builder-extra-args }} ${DEBUG_ARG} ${ENABLE_TESTS} ${ENABLE_ASSERTIONS} ${EXTRA_ARGS} + [ "${{ inputs.sanitizer }}" != "" ] && SANITIZER="--sanitizer ${{ inputs.sanitizer }}" + if [[ -n "${{ inputs.default-target-triple }}" && "${{ inputs.default-target-triple }}" != "default" ]]; then + DEFAULT_TARGET="--default-target ${{ inputs.default-target-triple }}" + fi + zksync-llvm build --target-env ${{ inputs.target-env }} ${DEFAULT_TARGET} \ + --use-ccache ${{ inputs.builder-extra-args }} ${DEBUG_ARG} ${ENABLE_TESTS} ${ENABLE_ASSERTIONS} ${ENABLE_COVERAGE} ${SANITIZER} ${EXTRA_ARGS} diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ec57fa4..b7b57ab 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -63,14 +63,20 @@ on: required: false default: '' description: 'custom solc version to use for benchmarks' + target-machine: + type: string + required: false + default: '' + description: 'Target machine passed via `--target` for era-compiler-tester. Available arguments: `EraVM`, `EVM`, `EVMInterpreter`. Use `default` or `` to skip `--target` parameter.' jobs: + benchmarks: strategy: fail-fast: false matrix: type: ["reference", "candidate"] - name: ${{ matrix.type }} + name: ${{ inputs.target-machine}} ${{ matrix.type }} runs-on: matterlabs-ci-runner container: image: matterlabs/llvm_runner:ubuntu22-llvm17-latest @@ -146,8 +152,12 @@ jobs: echo $(./solc-bin/solc-${{ inputs.custom-solc-version}} --version) - name: Run benchmarks + shell: bash -ex {0} run: | - ./target/release/compiler-tester \ + if [[ -n "${{ inputs.target-machine }}" && "${{ inputs.target-machine }}" != "default" ]]; then + TARGET="--target ${{ inputs.target-machine }}" + fi + ./target/release/compiler-tester ${TARGET} \ --zksolc './target-zksolc/release/zksolc' \ --zkvyper './target-zkvyper/release/zkvyper' \ --path=${{ inputs.compiler_llvm_benchmark_path || '' }} \ @@ -189,7 +199,7 @@ jobs: - name: Posting the LLVM benchmark results to the summary run: | - printf "Benchmark results:\n" | tee -a $GITHUB_STEP_SUMMARY + printf "Benchmark results ${{ inputs.target-machine }}:\n" | tee -a $GITHUB_STEP_SUMMARY echo '```' | tee -a $GITHUB_STEP_SUMMARY cat result.txt | tee -a $GITHUB_STEP_SUMMARY echo '```' | tee -a $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 45e084c..3b35238 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -16,6 +16,11 @@ on: required: false default: '' description: 'Path filter for integration tests execution. For example: `tests/solidity/`.' + target-machine: + type: string + required: false + default: '' + description: 'Target machine passed via `--target` for era-compiler-tester. Available arguments: `EraVM`, `EVM`, `EVMInterpreter`. Use `default` or `` to skip `--target` parameter.' extra-args: type: string required: false @@ -53,12 +58,14 @@ on: description: 'Compiler LLVM repository to use. Required for forks testing.' jobs: - run-integration-tests: + + integration-tests: runs-on: ci-runner-compiler timeout-minutes: 720 container: image: matterlabs/llvm_runner:ubuntu22-llvm17-latest options: -m 110g + name: Integration Tests ${{ inputs.target-machine || 'default' }} steps: - name: Checkout compiler-tester @@ -82,7 +89,6 @@ jobs: - name: Build LLVM uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@main with: - extra-args: "\\-DLLVM_ENABLE_WERROR=On \\-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" enable-tests: true enable-assertions: true clone-llvm: ${{ inputs.llvm-ref == '' && 'true' || 'false' }} @@ -122,9 +128,12 @@ jobs: echo $(./solc-bin/solc-${{ inputs.custom-solc-version}} --version) - name: Run integration tests + shell: bash -ex {0} run: | - set -x - ./target/release/compiler-tester \ + if [[ -n "${{ inputs.target-machine }}" && "${{ inputs.target-machine }}" != "default" ]]; then + TARGET="--target ${{ inputs.target-machine }}" + fi + ./target/release/compiler-tester ${TARGET} \ --zksolc './target-zksolc/release/zksolc' \ --zkvyper './target-zkvyper/release/zkvyper' \ --path '${{ inputs.path }}' ${{ inputs.extra-args }} @@ -133,6 +142,7 @@ jobs: uses: 8398a7/action-slack@v3 if: (failure() || success()) && (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) with: + job_name: Integration Tests ${{ inputs.target-machine || 'default' }} status: ${{ job.status }} fields: repo,commit,author,action,eventName,ref,workflow,job,took,pullRequest env: