docs: Update CLAUDE.local.md for v0.4.7 release session #6
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: Coverage | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| # Cancel outdated workflow runs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libpcap-dev pkg-config | |
| - name: Install cargo-tarpaulin | |
| run: cargo install cargo-tarpaulin | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v3 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-coverage-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Generate coverage report | |
| id: tarpaulin | |
| run: | | |
| # Run tarpaulin and capture output | |
| OUTPUT=$(cargo tarpaulin --workspace \ | |
| --timeout 600 \ | |
| --out Lcov --out Html --out Json \ | |
| --output-dir coverage \ | |
| --exclude-files "crates/prtip-cli/src/main.rs" 2>&1) | |
| # Display the output | |
| echo "$OUTPUT" | |
| # Extract coverage percentage from output (format: "XX.XX% coverage, N/M lines covered") | |
| COVERAGE=$(echo "$OUTPUT" | grep -oP '\d+\.\d+(?=% coverage)' | tail -1) | |
| if [ -z "$COVERAGE" ]; then | |
| echo "Error: Could not extract coverage percentage from tarpaulin output" | |
| exit 1 | |
| fi | |
| echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "Extracted coverage: $COVERAGE%" | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage/lcov.info | |
| flags: rust | |
| name: codecov-prtip | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| retention-days: 30 | |
| - name: Extract coverage percentage | |
| id: coverage | |
| run: | | |
| # Get coverage from tarpaulin step output | |
| COVERAGE=${{ steps.tarpaulin.outputs.coverage }} | |
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "Current coverage: $COVERAGE%" | |
| - name: Check coverage threshold | |
| run: | | |
| COVERAGE=${{ steps.coverage.outputs.percentage }} | |
| THRESHOLD=50.0 | |
| echo "Current coverage: $COVERAGE%" | |
| echo "Required threshold: $THRESHOLD%" | |
| # Use awk for floating point comparison (bc not always available) | |
| if awk -v cov="$COVERAGE" -v thr="$THRESHOLD" 'BEGIN {exit !(cov < thr)}'; then | |
| echo "❌ Coverage $COVERAGE% is below threshold $THRESHOLD%" | |
| echo "::error::Coverage regression detected. Current: $COVERAGE%, Required: $THRESHOLD%" | |
| exit 1 | |
| fi | |
| echo "✅ Coverage $COVERAGE% meets threshold $THRESHOLD%" | |
| echo "::notice::Coverage check passed: $COVERAGE% >= $THRESHOLD%" | |
| - name: Comment PR with coverage | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const coverage = '${{ steps.coverage.outputs.percentage }}'; | |
| const threshold = '50.0'; | |
| const passed = parseFloat(coverage) >= parseFloat(threshold); | |
| const emoji = passed ? '✅' : '❌'; | |
| const comment = `## ${emoji} Coverage Report | |
| **Current Coverage:** ${coverage}% | |
| **Threshold:** ${threshold}% | |
| **Status:** ${passed ? 'PASSED' : 'FAILED'} | |
| ${passed ? | |
| '✅ Coverage meets the minimum threshold.' : | |
| '❌ Coverage is below the minimum threshold. Please add more tests.'} | |
| 📊 [View detailed coverage report in artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| `; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |