102 lines
5.2 KiB
Markdown
102 lines
5.2 KiB
Markdown
# rust_autobadges
|
|
|
|

|
|

|
|

|
|
|
|
Runs cargo-tarpaulin to generate coverage and automatically create a badges/ folder with the generated coverage.svg, test.svg and version.svg
|
|
|
|
## Dependency security and policy
|
|
|
|
CI pins `cargo-audit` 0.22.2 and `cargo-deny` 0.20.2. Run the same supply-chain gates locally from the repository root:
|
|
|
|
```sh
|
|
cargo audit --deny warnings
|
|
cargo deny check
|
|
```
|
|
|
|
Both commands require network access so they can refresh RustSec advisory and crates.io registry data. A failed refresh is an error; CI does not silently accept stale data.
|
|
|
|
`cargo audit` checks the tracked `Cargo.lock` for RustSec vulnerabilities, unmaintained or unsound advisories, and yanked packages. It is limited to advisories present in RustSec and cannot detect undisclosed vulnerabilities or assess source-code behavior.
|
|
|
|
`cargo deny` enforces `deny.toml`: only the licenses used by the current dependency graph are allowed (with a confidence threshold of 0.8), wildcard requirements are denied, duplicate versions are reported as warnings, unknown registries and Git sources are denied, crates.io is the only allowed registry, and no Git sources are allowed. It builds the graph with all features enabled. Advisory ignores, crate bans, duplicate skips, license exceptions, and license clarifications start empty. The tool validates dependency metadata and known advisories; it is not a source-code or runtime scanner.
|
|
|
|
No other hardening tools are in scope for these CI gates.
|
|
|
|
## CI coverage badges
|
|
|
|
CI pins `cargo-tarpaulin` 0.37.5 and uses the tracked `tarpaulin.toml`. Run the exact coverage gate locally with:
|
|
|
|
```sh
|
|
cargo tarpaulin
|
|
```
|
|
|
|
The configuration uses locked dependencies, all features and targets, LLVM coverage, and an enforced 1.5% line-coverage floor. The measured JSON summary is temporary at `coverage/tarpaulin-report.json`; `rust_autobadges` reads its overall `coverage` value to generate the coverage badge, then CI removes it.
|
|
|
|
The release binary generates all three badges itself:
|
|
|
|
```sh
|
|
target/release/rust_autobadges badge version
|
|
target/release/rust_autobadges badge test --value passing
|
|
target/release/rust_autobadges badge coverage --summary coverage/tarpaulin-report.json
|
|
```
|
|
|
|
The version badge defaults to the authoritative package version compiled from `Cargo.toml`. Jenkins archives exactly `coverage/version.svg`, `coverage/test.svg`, and `coverage/coverage.svg`. On the `main` branch, cleanup publishes them under `/mnt/assets/coverage/Dandaedre/rust_autobadges/main/`; other branches only archive their generated badges. The Jenkins job must be multibranch so `BRANCH_NAME` can safely gate publication.
|
|
|
|
The public asset server should mount the publication directory read-only, disable directory listings, serve SVG with a restrictive content security policy, and revalidate these mutable URLs or give them a short cache lifetime.
|
|
|
|
# Usage
|
|
|
|
```
|
|
Usage: rust_autobadges [OPTIONS] [COMMAND]
|
|
|
|
Commands:
|
|
badge Render one CI badge without running tests or coverage
|
|
help Print this message or the help of the given subcommand(s)
|
|
|
|
Options:
|
|
-s, --skip-clean
|
|
Skip the cargo clean that tarpaulin would run, see tarpaulin --skip-clean for more documentation
|
|
-t, --no-test
|
|
Dont generate the test:failing/passing badge
|
|
-c, --no-coverage
|
|
Don't run the coverage and dont generate the coverage:(percent) badge
|
|
-v, --no-version
|
|
Don't run the version tag check and dont generage the version:(number) badge
|
|
--version-color <VERSION_COLOR>
|
|
The color used to use on the version badge [default: orange]
|
|
--failing-color <FAILING_COLOR>
|
|
The color used to indicate failure on the test badges [default: red]
|
|
--success-color <SUCCESS_COLOR>
|
|
The color used to indicate success on the badges [default: green]
|
|
--high-coverage-color <HIGH_COVERAGE_COLOR>
|
|
The color used on a high coverage [default: green]
|
|
--mid-coverage-color <MID_COVERAGE_COLOR>
|
|
The color used on a mid coverage [default: orange]
|
|
--low-coverage-color <LOW_COVERAGE_COLOR>
|
|
The color used on a low coverage [default: red]
|
|
--high-coverage-percent <HIGH_COVERAGE_PERCENT>
|
|
The percent indicating a high coverage [default: 1]
|
|
--mid-coverage-percent <MID_COVERAGE_PERCENT>
|
|
The percent indicating a mid coverage [default: 0.8]
|
|
-o, --output <OUTPUT>
|
|
The output directory where all the badges will be saved [default: badges]
|
|
-h, --help
|
|
Print help
|
|
-V, --version
|
|
Print version
|
|
```
|
|
|
|
# Future Features
|
|
* Only run tests
|
|
* Clean the badges folder
|
|
* Have a better indication of the actions of tarpaulin run
|
|
* (optionnal) Save info of the previous run to allow a progress bar
|
|
|
|
# TODO
|
|
* Better error handling
|
|
* Structs to allow centralisation of pb/error handling/.close()
|
|
* Better alignment
|
|
* (consideration) A config file to avoid passing so many arguments and have a better CI
|
|
* Having a coverage above 0% ? (even if testing something that runs tests require some smart)
|