Integrating with CI
On GitHub, the GitHub Action does coverage, the comparison with a pull request’s base, the comment and the gate in one step. The commands below are for other CI systems, or for doing it by hand.
See Exit codes for what each exit code means. The regression gate, the PR comment bot and badge generation have pages of their own.
Absolute threshold gate
- run: cargo llvm-cov --lcov --output-path lcov.info
- run: cargo crap --lcov lcov.info --fail-above --threshold 30GitHub Code Scanning (SARIF)
Upload --format sarif output to surface crappy functions in the
repository’s Security → Code scanning tab. The job needs
security-events: write.
self_score:
permissions:
security-events: write
steps:
- run: cargo llvm-cov --lcov --output-path lcov.info
- run: cargo crap --lcov lcov.info --format sarif --output crap.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: crap.sarif
category: cargo-crap
See SARIF output for what the document contains.