Skip to content

Commit 118170a

Browse files
authored
[CI] Add differential coverage workflow job (#9297)
Add a pull_request CI job that builds Binaryen with Clang source-based coverage instrumentation, runs lit and gtest, and reports differential coverage via coverage-diff.py. Surface the results on the workflow summary page via $GITHUB_STEP_SUMMARY (--markdown) and inline on the PR diff via GitHub workflow annotations (--github-annotations). Also update coverage-diff.py to use %8m.profraw online profile merging, respect GITHUB_BASE_REF, and keep .o objects when diffs include both headers and tool subdirectory sources.
1 parent 944ed73 commit 118170a

2 files changed

Lines changed: 362 additions & 11 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,42 @@ jobs:
332332
- name: test
333333
run: python check.py --binaryen-bin=out/bin
334334

335+
# Duplicates build-asan. Please keep in sync
336+
coverage:
337+
name: coverage
338+
if: ${{ github.event_name == 'pull_request' }}
339+
runs-on: ubuntu-26.04
340+
env:
341+
COMPILER_FLAGS: "-fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc"
342+
LLVM_VERSION: 21
343+
steps:
344+
- uses: actions/setup-python@v5
345+
with:
346+
python-version: '3.x'
347+
- uses: actions/checkout@v4
348+
with:
349+
submodules: true
350+
fetch-depth: 0
351+
- name: install tools
352+
run: sudo apt-get install ninja-build clang-${LLVM_VERSION} llvm-${LLVM_VERSION}
353+
- name: install v8
354+
run: |
355+
npm install jsvu -g
356+
jsvu --os=default --engines=v8
357+
- name: install Python dev dependencies
358+
run: pip3 install -r requirements-dev.txt
359+
- name: cmake
360+
run: |
361+
mkdir -p out
362+
cmake -S . -B out -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_C_COMPILER=clang-${LLVM_VERSION} -DCMAKE_CXX_COMPILER=clang++-${LLVM_VERSION} -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS"
363+
- name: build
364+
run: cmake --build out
365+
- name: coverage-diff
366+
run: |
367+
MERGE_BASE=$(git merge-base "origin/$GITHUB_BASE_REF" HEAD)
368+
./scripts/experimental/coverage-diff.py --base "$MERGE_BASE" -B out --lit test/lit --gtest -a --github-annotations
369+
./scripts/experimental/coverage-diff.py --base "$MERGE_BASE" -B out -a --markdown >> "$GITHUB_STEP_SUMMARY"
370+
335371
# Build the .js outputs using emcc
336372
build-emscripten:
337373
name: emscripten

0 commit comments

Comments
 (0)