Skip to content

Merge pull request #83 from AcademySoftwareFoundation/fix-scripts-she… #43

Merge pull request #83 from AcademySoftwareFoundation/fix-scripts-she…

Merge pull request #83 from AcademySoftwareFoundation/fix-scripts-she… #43

Workflow file for this run

name: Coverage Job
on:
push:
branches: main
jobs:
test-coverage:
name: Test coverage
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# Install and set LLVM and Clang respectively
- run: sudo apt-get update && sudo apt-get install llvm
- run: sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 50
# Configure and build test binary
- run: cmake --preset unix -D CMAKE_CXX_FLAGS='-fprofile-instr-generate -fcoverage-mapping'
- run: cmake --build --preset unix --target tests
# Run instrumented test binary and gather coverage data
- run: LLVM_PROFILE_FILE='build/coverage.profraw' build/src/tests/tests
- run: llvm-profdata merge --sparse --output build/coverage.profdata build/coverage.profraw
- run: llvm-cov export --instr-profile build/coverage.profdata build/src/tests/tests include > coverage.json
- run: llvm-cov show --instr-profile build/coverage.profdata --format html --output-dir coverage-report build/src/tests/tests include
# Extract the total function coverage percentage
- run: sudo apt-get update && sudo apt-get install jq
- run: echo "COVERAGE=$(jq '.data[0].totals.functions.percent' coverage.json | xargs printf '%.0f\n')" >> $GITHUB_ENV
# Upload json data for coverage badge
- uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: c64d4efeaa4f0760255cc54cdadce85c
filename: test.json
label: Coverage
message: ${{ env.COVERAGE }}%
valColorRange: ${{ env.COVERAGE }}
minColorRange: 0
maxColorRange: 100
# Upload coverage report artifact
- uses: actions/upload-artifact@v4
with: {name: coverage-report, path: "coverage-report"}