Skip to content

test: Add code coverage support with CodeCov #877

test: Add code coverage support with CodeCov

test: Add code coverage support with CodeCov #877

Workflow file for this run

name: "Unit Tests"
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
jobs:
tests:
name: 🧪 Unit Tests
runs-on: ubuntu-22.04
env:
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: read
contents: read
security-events: write
steps:
- name: 🧰 Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: ⬇️ Install dependencies
run: |
sudo apt update
sudo apt install -y \
build-essential \
gcc-12 \
g++-12 \
lld \
${PKGCONF:-} \
cmake \
make \
lcov \
gcovr
- name: 🛠️ Build
run: |
mkdir -p build
cd build
CC=gcc-12 CXX=g++-12 cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-O0 -fuse-ld=lld --coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=all" \
-DCMAKE_CXX_FLAGS="-O0 -fuse-ld=lld --coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=all" \
-DLIBPL_ENABLE_TESTS=ON \
..
make -j4 pattern_language_tests plcli
- name: 🧪 Perform plcli Integration Tests
run: |
python tests/integration/integration.py build/cli/plcli
- name: 🧪 Perform Unit Tests
run: |
cd build
ctest --output-on-failure
- name: ✉️ Run ImHex-Patterns tests
if: ${{ env.DISPATCH_TOKEN != '' }}
uses: mvasigh/dispatch-action@main
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repo: ImHex-Patterns
owner: WerWolv
event_type: run_tests
# Generate report from all gcov .gcda files
- name: 🧪 Generate coverage report
run: |
gcovr --gcov-executable /usr/bin/gcov-12 -e lib/ -r . build --xml coverage_report.xml --verbose
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage_report.xml