| 1 |
name: Unit Tests |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: |
| 5 |
- main |
| 6 |
pull_request: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
types: |
| 10 |
- opened |
| 11 |
- synchronize |
| 12 |
- reopened |
| 13 |
|
| 14 |
jobs: |
| 15 |
test-ubuntu: |
| 16 |
name: Test and Coverage Reports |
| 17 |
runs-on: ubuntu-latest |
| 18 |
permissions: |
| 19 |
contents: read |
| 20 |
checks: write |
| 21 |
pull-requests: write |
| 22 |
steps: |
| 23 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 24 |
- name: Install dependencies |
| 25 |
run: | |
| 26 |
sudo apt-get update |
| 27 |
sudo apt-get install --assume-yes --no-install-recommends \ |
| 28 |
check \ |
| 29 |
gcovr \ |
| 30 |
meson \ |
| 31 |
ninja-build |
| 32 |
- name: Configure |
| 33 |
run: | |
| 34 |
meson setup build \ |
| 35 |
-Db_coverage=true \ |
| 36 |
-Denable-tests=true |
| 37 |
- name: Build |
| 38 |
run: meson compile -C build |
| 39 |
- name: Run unit tests |
| 40 |
run: meson test -C build |
| 41 |
- name: Run code coverage |
| 42 |
run: ninja coverage -C build |
| 43 |
- name: Publish test report |
| 44 |
uses: mikepenz/action-junit-report@49b2ca06f62aa7ef83ae6769a2179271e160d8e4 # v6.3.1 |
| 45 |
if: success() || failure() |
| 46 |
with: |
| 47 |
report_paths: build/meson-logs/testlog.junit.xml |
| 48 |
include_passed: true |
| 49 |
- name: Report code coverage |
| 50 |
uses: threeal/gcovr-action@64cb417ed6f143cafe1c69611922672002f460bb # v1.2.0 |
| 51 |
with: |
| 52 |
excludes: 'tests/.*' |
| 53 |
github-token: ${{ secrets.GITHUB_TOKEN }} |
| 54 |
xml-out: build/meson-logs/coverage.xml |
| 55 |
- uses: 5monkeys/cobertura-action@ee5787cc56634acddedc51f21c7947985531e6eb # v14 |
| 56 |
with: |
| 57 |
path: build/meson-logs/coverage.xml |
| 58 |
fail_below_threshold: true |
| 59 |
minimum_coverage: 50 |
| 60 |
show_line: true |
| 61 |
show_branch: true |