Skip to content

Commit 7e39dfa

Browse files
ci: weekly or manual code coverage measurements by integration tests
1 parent 9b0c83b commit 7e39dfa

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- main
77
pull_request:
8+
schedule:
9+
- cron: '0 0 * * 0' # Weekly on Sunday at 00:00
10+
workflow_dispatch:
811

912
defaults:
1013
run:
@@ -20,7 +23,9 @@ env:
2023
OUTPUT_HTML_DIR: COVERAGE
2124

2225
jobs:
26+
2327
run-with-coverage:
28+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
2429
runs-on: matterlabs-ci-runner-high-performance
2530
container:
2631
image: ghcr.io/matter-labs/zksync-llvm-runner:latest
@@ -106,3 +111,125 @@ jobs:
106111
token: ${{ secrets.CODECOV_TOKEN }}
107112
file: ${{ env.LCOV_FILE }}
108113
slug: ${{ github.repository }}
114+
115+
# Calculates full code coverage for LLVM
116+
# based on regression AND integration tests together
117+
# Runs for `main` branch by schedule or by request as it takes >3 hours to complete
118+
integration-tests-coverage:
119+
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
120+
runs-on: matterlabs-ci-runner-highdisk
121+
container:
122+
image: ghcr.io/matter-labs/zksync-llvm-runner:main
123+
env:
124+
BOOST_PREFIX: ${{ github.workspace }}/era-solidity/boost/lib
125+
SOLC_PREFIX: ${{ github.workspace }}/era-solidity/build
126+
TARGET: 'x86_64-unknown-linux-gnu'
127+
steps:
128+
129+
- name: Checkout compiler-tester
130+
uses: actions/checkout@v4
131+
with:
132+
ref: 'main'
133+
repository: matter-labs/era-compiler-tester
134+
submodules: recursive
135+
136+
# This step is required to checkout submodules
137+
# that are disabled in .gitmodules config
138+
- name: Checkout submodules
139+
run: |
140+
git config --global --add safe.directory '*'
141+
git submodule update --init --force --depth=1 --recursive --checkout
142+
143+
- name: Remove llvm submodule
144+
run: rm -rf llvm
145+
146+
- name: Checkout llvm
147+
uses: actions/checkout@v4
148+
with:
149+
path: llvm
150+
151+
- name: Build LLVM for tester
152+
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
153+
with:
154+
clone-llvm: false
155+
156+
- name: Build compiler-tester
157+
run: |
158+
cargo build --release --target ${TARGET} --bin 'compiler-tester'
159+
# Clean-up LLVM for the coverage build
160+
rm -rf target-llvm
161+
162+
- name: Building solc
163+
uses: matter-labs/era-compiler-ci/.github/actions/build-solc@v1
164+
with:
165+
cmake-build-type: 'Release'
166+
working-dir: 'era-solidity'
167+
upload-testing-binary: false
168+
169+
- name: Build LLVM with coverage
170+
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
171+
with:
172+
clone-llvm: 'false'
173+
enable-coverage: true
174+
enable-tests: true
175+
enable-assertions: 'false'
176+
ccache-key: ${{ format('llvm-{0}-{1}', runner.os, runner.arch) }}
177+
178+
- name: Build solx with coverage
179+
env:
180+
CARGO_CHECKOUT_DIR: /usr/local/cargo/git/checkouts
181+
RUSTFLAGS: "-C instrument-coverage"
182+
run: |
183+
cargo build --target ${TARGET} \
184+
--manifest-path ${CARGO_CHECKOUT_DIR}/solx-*/*/Cargo.toml \
185+
--target-dir './target-solx/'
186+
187+
- name: Running Lit tests
188+
run: |
189+
ninja -C './target-llvm/build-final' verify-llvm -v || true
190+
ninja -C './target-llvm/build-final' check-llvm-codegen-evm -v || true
191+
ninja -C './target-llvm/build-final' check-llvm-codegen-generic -v || true
192+
ninja -C './target-llvm/build-final' check-llvm-mc-evm -v || true
193+
ninja -C './target-llvm/build-final' check-llvm-unit -v || true
194+
llvm-profdata merge -sparse -o ${PROFDATA_FILE} ./target-llvm/build-final/profiles/*.profraw
195+
196+
- name: Run integration tests with coverage
197+
run: |
198+
TMP="${PROFDATA_FILE}.tmp"
199+
for TEST_PATH in tests/solidity/complex/* tests/solidity/simple/* tests/solidity/ethereum/*; do
200+
WORKDIR=$(basename ${TEST_PATH})
201+
mkdir -p "${GITHUB_WORKSPACE}/${WORKDIR}"
202+
./target/${TARGET}/release/compiler-tester \
203+
--target evm \
204+
--toolchain ir-llvm \
205+
--solx "./target-solx/${TARGET}/debug/solx" \
206+
--load-system-contracts ./system-contracts-stable-build \
207+
--path ${TEST_PATH} \
208+
--workflow build \
209+
--verbose
210+
211+
mv *.profraw "${GITHUB_WORKSPACE}/${WORKDIR}/" || true
212+
du -hs "${GITHUB_WORKSPACE}/${WORKDIR}"
213+
find ${GITHUB_WORKSPACE}/${WORKDIR} -type f -name '*.profraw' -print > profiles.lst
214+
if [[ -f "${PROFDATA_FILE}" ]]; then
215+
llvm-profdata merge -sparse -num-threads="$(nproc)" -o "${TMP}" "${PROFDATA_FILE}" @profiles.lst
216+
else
217+
llvm-profdata merge -sparse -num-threads="$(nproc)" -o "${TMP}" @profiles.lst
218+
fi
219+
mv -f "${TMP}" "${PROFDATA_FILE}"
220+
rm -rf "${GITHUB_WORKSPACE}/${WORKDIR}"
221+
done
222+
223+
- name: Generate coverage reports
224+
run: |
225+
llvm-cov show --show-directory-coverage \
226+
--format=html --output-dir=${OUTPUT_HTML_DIR} \
227+
-instr-profile=${PROFDATA_FILE} ./target-solx/${TARGET}/debug/solx
228+
llvm-cov export --format=lcov -instr-profile=${PROFDATA_FILE} \
229+
./target-solx/${TARGET}/debug/solx > ./llvm/${LCOV_FILE}
230+
231+
- name: Upload coverage artifacts
232+
uses: actions/upload-artifact@v4
233+
with:
234+
name: 'Coverage integration tests HTML'
235+
path: ${{ env.OUTPUT_HTML_DIR }}

0 commit comments

Comments
 (0)