further improve our test coverage by testing the oauth2 world further #157
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
| # This workflow runs code coverage using cargo-llvm-cov + cargo-nextest and uploads as GitHub artifact | |
| # No external services required | |
| name: Coverage | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Add llvm-tools component | |
| run: rustup component add llvm-tools-preview | |
| - name: Install cargo-llvm-cov and cargo-nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-llvm-cov,nextest | |
| - name: Collect coverage data | |
| run: | | |
| cargo llvm-cov nextest \ | |
| --workspace \ | |
| --exclude loadtest \ | |
| --exclude migration \ | |
| --profile ci \ | |
| --no-report | |
| - name: Generate coverage reports | |
| run: | | |
| cargo llvm-cov report --lcov --output-path lcov.info | |
| cargo llvm-cov report --html --output-dir target/coverage/html | |
| - name: Extract coverage percentage | |
| id: coverage | |
| run: | | |
| COVERAGE=$(cargo llvm-cov report --summary-only | grep -oP '\d+\.\d+(?=%)' | tail -1) | |
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "Coverage: $COVERAGE%" | |
| - name: Upload HTML coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html-${{ github.sha }} | |
| path: target/coverage/html/ | |
| - name: Upload LCOV coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-lcov-${{ github.sha }} | |
| path: lcov.info | |
| - name: Comment coverage on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const coverage = '${{ steps.coverage.outputs.percentage }}'; | |
| const comment = `## Coverage Report | |
| **Current Coverage: ${coverage}%** | |
| 📊 [View detailed HTML report](../../actions/runs/${{ github.run_id }}) | |
| Target: 60-80% coverage`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |