fix: Fix gcc warning #896
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ | |
ccache \ | |
gcc-12 \ | |
g++-12 \ | |
lld \ | |
${PKGCONF:-} \ | |
cmake \ | |
make \ | |
lcov \ | |
gcovr | |
- name: 📜 Setup ccache | |
uses: hendrikmuhs/ccache-action@v1 | |
with: | |
key: ${{ runner.os }}-tests-${{ github.run_id }} | |
restore-keys: ${{ runner.os }}-tests | |
max-size: 1G | |
- 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 \ | |
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
.. | |
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 -r . build --xml coverage_report.xml --verbose | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage_report.xml |