Add CI workflows for PR test coverage enforcement and Nix builds #12
Workflow file for this run
This file contains hidden or 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
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| test-coverage: | |
| name: Tests & Code Coverage | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v27 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - name: Install ALSA & MIDI | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y alsa-utils linux-modules-extra-$(uname -r) | |
| # No virmidi module on Actions TODO mock MIDI for this env | |
| # - name: Config Cachix TODO | |
| # uses: cachix/cachix-action@v15 | |
| # with: | |
| # name: devenv | |
| - name: Configure & build project | |
| run: | | |
| nix develop --command bash -c "cmake --build build -j$(nproc)" | |
| - name: Run tests | |
| run: | | |
| nix develop --command bash -c "cmake --build build --target tests" | |
| - name: Run main | |
| run: | | |
| nix develop --command bash -c "cmake --build build --target run" | |
| - name: Measure code coverage | |
| run: | | |
| nix develop --command bash -c "cmake --build build --target coverage" | |
| - name: Export coverage report totals as text | |
| run: | | |
| nix develop --command bash -c "llvm-cov report build/src/main -instr-profile=build/coverage.profdata -ignore-filename-regex='test/.*' > build/coverage.txt" | |
| cat build/coverage.txt | |
| - name: Verify functions coverage is (almost) 100% (MIDI tests impossible on CI) | |
| run: | | |
| grep TOTAL build/coverage.txt | awk '{ if ($7 + 0 > 90) exit 0; else exit 1 }' | |
| - name: Verify line coverage is at least 90% | |
| run: | | |
| grep TOTAL build/coverage.txt | awk '{ if ($10 + 0 > 90) exit 0; else exit 1 }' |