Add code coverage to readme #4
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
| name: test | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Install build dependencies from debian/control | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install --yes devscripts equivs ninja-build lcov | |
| sudo mk-build-deps -i -r -t "apt-get --yes" debian/control | |
| - name: Configure | |
| run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DUSE_STATIC_MPVQT=ON -DCOVERAGE=ON | |
| - name: Build | |
| run: cmake --build build | |
| - name: Run tests | |
| run: | | |
| cd build | |
| ctest --output-on-failure | |
| - name: Collect coverage | |
| run: | | |
| lcov --capture --directory build --output-file coverage.info \ | |
| --ignore-errors mismatch | |
| lcov --remove coverage.info \ | |
| '/usr/*' '*/external/*' '*/tests/*' '*/build/*' \ | |
| --output-file coverage.info \ | |
| --ignore-errors unused | |
| lcov --summary coverage.info > coverage_summary.txt 2>&1 | |
| - name: Comment coverage on PR | |
| if: github.event_name == 'pull_request' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| { | |
| echo "## Test Coverage" | |
| echo "" | |
| echo '```' | |
| cat coverage_summary.txt | |
| echo '```' | |
| } > comment_body.md | |
| gh pr comment "${{ github.event.pull_request.number }}" --body-file comment_body.md |