|
| 1 | +name: Code coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + mode: |
| 10 | + description: "Mode filter for era-compiler-tester" |
| 11 | + required: true |
| 12 | + default: "0.8" |
| 13 | + path: |
| 14 | + description: "Path filter for era-compiler-tester" |
| 15 | + required: true |
| 16 | + default: "tests/solidity/complex/defi" |
| 17 | + |
| 18 | +defaults: |
| 19 | + run: |
| 20 | + shell: bash -ex {0} |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: false |
| 25 | + |
| 26 | +env: |
| 27 | + PROFDATA_FILE: zksolc.profdata |
| 28 | + LCOV_FILE: codecov.lcov |
| 29 | + OUTPUT_HTML_DIR: COVERAGE |
| 30 | + |
| 31 | +jobs: |
| 32 | + run-with-coverage: |
| 33 | + runs-on: [ci-runner-compiler, Linux] |
| 34 | + container: |
| 35 | + image: ghcr.io/matter-labs/zksync-llvm-runner:latest |
| 36 | + options: -m 110g |
| 37 | + env: |
| 38 | + TARGET: x86_64-unknown-linux-gnu |
| 39 | + RUSTC_BOOTSTRAP: 1 |
| 40 | + LATEST_SOLC_VERSION: 0.8 |
| 41 | + DEFAULT_BENCHMARKS_PATH: tests/solidity/complex/defi |
| 42 | + steps: |
| 43 | + |
| 44 | + - name: Checkout compiler-tester |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + ref: 'main' |
| 48 | + repository: matter-labs/era-compiler-tester |
| 49 | + submodules: recursive |
| 50 | + |
| 51 | + - name: Checkout llvm |
| 52 | + uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + repository: matter-labs/era-compiler-llvm |
| 55 | + path: llvm |
| 56 | + |
| 57 | + - name: Build LLVM for tester |
| 58 | + uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1 |
| 59 | + with: |
| 60 | + clone-llvm: false |
| 61 | + |
| 62 | + - name: Build compiler-tester |
| 63 | + run: | |
| 64 | + cargo build --release --target ${TARGET} --bin 'compiler-tester' |
| 65 | + rm -rf target-llvm |
| 66 | +
|
| 67 | + - name: Build LLVM with coverage |
| 68 | + uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1 |
| 69 | + with: |
| 70 | + clone-llvm: false |
| 71 | + enable-coverage: true |
| 72 | + |
| 73 | + - name: Build compilers with coverage |
| 74 | + env: |
| 75 | + CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts |
| 76 | + RUSTFLAGS: "-C instrument-coverage" |
| 77 | + run: | |
| 78 | + cargo build --target ${TARGET} \ |
| 79 | + --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \ |
| 80 | + --target-dir './target-zksolc/' |
| 81 | + cargo build --target ${TARGET} \ |
| 82 | + --manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \ |
| 83 | + --target-dir './target-zkvyper/' |
| 84 | +
|
| 85 | + - name: Run tests with coverage for EraVM |
| 86 | + run: | |
| 87 | + ./target/${TARGET}/release/compiler-tester \ |
| 88 | + --zksolc "./target-zksolc/${TARGET}/debug/zksolc" \ |
| 89 | + --zkvyper "./target-zksolc/${TARGET}/debug/zkvyper" \ |
| 90 | + --path '${{ inputs.path || env.DEFAULT_BENCHMARKS_PATH }}' \ |
| 91 | + --mode '${{ inputs.mode || env.LATEST_SOLC_VERSION }}' \ |
| 92 | + --workflow build |
| 93 | +
|
| 94 | + - name: Generate coverage reports |
| 95 | + run: | |
| 96 | + llvm-profdata merge -sparse -o ${PROFDATA_FILE} *.profraw |
| 97 | + llvm-cov show --show-directory-coverage \ |
| 98 | + --format=html --output-dir=${OUTPUT_HTML_DIR} \ |
| 99 | + -instr-profile=${PROFDATA_FILE} ./target-zksolc/${TARGET}/debug/zksolc |
| 100 | + llvm-cov export --format=lcov -instr-profile=${PROFDATA_FILE} \ |
| 101 | + ./target-zksolc/${TARGET}/debug/zksolc > ./llvm/${LCOV_FILE} |
| 102 | +
|
| 103 | + - name: Upload coverage artifacts |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + with: |
| 106 | + name: 'Coverage HTML' |
| 107 | + path: ${{ env.OUTPUT_HTML_DIR}} |
| 108 | + |
| 109 | + - name: Upload coverage to Codecov |
| 110 | + uses: codecov/codecov-action@v4 |
| 111 | + with: |
| 112 | + working-directory: ${{ github.workspace }}/llvm # Mandatory if main repo is in different directory |
| 113 | + directory: ${{ github.workspace }} # Mandatory if main repo is in different directory |
| 114 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 115 | + file: ${{ env.LCOV_FILE }} |
| 116 | + slug: ${{ github.repository }} |
0 commit comments