Code Coverage #1381
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: Code Coverage | |
| on: | |
| # Coverage is an on-demand, information-only report, not a PR gate. | |
| # Run it manually from the Actions tab against any branch (including a | |
| # PR branch); the nightly run keeps a fresh artifact and catches rot. | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 6 * * *' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| tree: [legacy, refactor] | |
| config: | |
| - name: base | |
| flags: "" | |
| - name: dma | |
| flags: "DMA=1" | |
| - name: threadsafe | |
| flags: "THREADSAFE=1" | |
| - name: she | |
| flags: "SHE=1" | |
| - name: auth | |
| flags: "AUTH=1" | |
| - name: nocrypto | |
| flags: "NOCRYPTO=1" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install gcovr | |
| # Pin a modern gcovr via pipx; the apt-shipped 7.0 on ubuntu-noble | |
| # cannot parse gcc 13's gcov output with block IDs >= 10000 (fixed | |
| # upstream in gcovr 7.1, see gcovr PR #883). | |
| run: pipx install 'gcovr==8.6' | |
| - name: Checkout wolfssl | |
| uses: ./.github/actions/checkout-wolfssl | |
| - name: Build, run, and emit tracefile (${{ matrix.tree }} ${{ matrix.config.name }}) | |
| # legacy and refactor trees differ only in the test dir and the | |
| # relative path back to the wolfssl checkout; both emit paths | |
| # rooted at the repo, so their tracefiles compare apples-to-apples. | |
| run: | | |
| if [ "${{ matrix.tree }}" = "legacy" ]; then | |
| dir=test; wolfssl=../wolfssl | |
| else | |
| dir=test-refactor/posix; wolfssl=../../wolfssl | |
| fi | |
| cd "$dir" | |
| make coverage-json \ | |
| OUT=$GITHUB_WORKSPACE/cov-json/${{ matrix.tree }}-${{ matrix.config.name }}.json \ | |
| WOLFSSL_DIR=$wolfssl ${{ matrix.config.flags }} | |
| - name: Upload tracefile | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tracefile-${{ matrix.tree }}-${{ matrix.config.name }} | |
| path: cov-json/${{ matrix.tree }}-${{ matrix.config.name }}.json | |
| retention-days: 7 | |
| report: | |
| needs: coverage | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install gcovr | |
| run: pipx install 'gcovr==8.6' | |
| - name: Download tracefiles | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: tracefile-* | |
| path: cov-json | |
| merge-multiple: true | |
| - name: Build HTML reports | |
| run: | | |
| # nullglob so an empty match returns 0 files instead of the | |
| # literal pattern, which would slip past the guard below. | |
| shopt -s nullglob | |
| for tree in legacy refactor; do | |
| files=(cov-json/$tree-*.json) | |
| if [ ${#files[@]} -eq 0 ]; then | |
| echo "No $tree tracefiles found to merge" >&2 | |
| exit 1 | |
| fi | |
| args=() | |
| for f in "${files[@]}"; do | |
| args+=(--add-tracefile "$f") | |
| done | |
| mkdir -p coverage-$tree | |
| gcovr "${args[@]}" \ | |
| --html-details coverage-$tree/index.html \ | |
| --print-summary | |
| done | |
| - name: Upload legacy coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage-legacy/ | |
| retention-days: 30 | |
| - name: Upload refactor coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-refactor-report | |
| path: coverage-refactor/ | |
| retention-days: 30 | |
| compare: | |
| needs: coverage | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download tracefiles | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: tracefile-* | |
| path: cov-json | |
| merge-multiple: true | |
| - name: Compare legacy vs refactor coverage | |
| run: | | |
| python3 tools/coverage-compare/compare_tracefiles.py cov-json compare | |
| cat compare/summary.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Upload coverage comparison | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-comparison | |
| path: compare/ | |
| retention-days: 30 |