Skip to content

ci: add coverage measurements workflow #5

ci: add coverage measurements workflow

ci: add coverage measurements workflow #5

Workflow file for this run

name: Code coverage
on:
pull_request:
workflow_dispatch:
inputs:
mode:
description: "Mode filter for era-compiler-tester"
required: true
default: "0.8.26"
path:
description: "Path filter for era-compiler-tester"
required: true
default: "tests/solidity/complex/defi"
defaults:
run:
shell: bash -ex {0}
concurrency:
group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
run-with-coverage:
runs-on: [ci-runner-compiler, Linux]
container:
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
uses: actions/checkout@v4
with:
ref: 'main'
repository: matter-labs/era-compiler-tester
submodules: recursive
- name: Checkout llvm
uses: actions/checkout@v4
with:
repository: matter-labs/era-compiler-llvm
path: llvm
- name: Build LLVM for tester
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
with:
clone-llvm: false
- name: Build compiler-tester
run: |
cargo build --release --target ${TARGET} --bin 'compiler-tester'
rm -rf target-llvm
- name: Build LLVM with coverage
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
with:
clone-llvm: false
enable-coverage: true
- name: Build compilers with coverage
env:
CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts
RUSTFLAGS: "-C instrument-coverage"
run: |
cargo build --target ${TARGET} \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-solidity-*/*/Cargo.toml \
--target-dir './target-zksolc/'
cargo build --target ${TARGET} \
--manifest-path ${CARGO_CHECKOUT_DIR}/era-compiler-vyper-*/*/Cargo.toml \
--target-dir './target-zkvyper/'
- name: Run tests with coverage
run: |
./target/${TARGET}/release/compiler-tester \
--zksolc "./target-zksolc/${TARGET}/debug/zksolc" \
--zkvyper "./target-zksolc/${TARGET}/debug/zkvyper" \
--path '${{ inputs.path || 'tests/solidity/complex/defi' }}' \
--mode '${{ inputs.mode || '0.8.26' }}' \
--workflow build
- name: Generate coverage reports
run: |
llvm-profdata merge -sparse -o zksolc.profdata *.profraw
llvm-cov show --show-directory-coverage --format=html --output-dir=COVERAGE -instr-profile=zksolc.profdata ./target-zksolc/${TARGET}/debug/zksolc
llvm-cov export --format=lcov -instr-profile=default.profdata ./target-zksolc/${TARGET}/debug/zksolc > lcov.info
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: 'Coverage HTML'
path: COVERAGE
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
slug: ${{ github.repository }}