pkgwatch/.forgejo/workflows/ci.yml
Austin Schaefer 13a1381bdf
All checks were successful
CI / build (push) Successful in 13m17s
CI / test (push) Successful in 3m59s
CI / coverage (push) Successful in 9m22s
CI / audit (push) Successful in 16s
Add shift-left quality gates: cognitive complexity, coverage, dependency fix
Adds two new gates to the existing format/lint/test/audit pipeline
(Makefile.toml `cargo make ci`, .forgejo/workflows/ci.yml):

- Cognitive complexity via clippy's nursery cognitive_complexity lint
  (clippy.toml, threshold 15), scoped to --bins so test code's naturally
  higher branch count doesn't get gated. Went with this over the closest
  real cyclomatic-complexity tool (rust-code-analysis-cli) because that
  crate hasn't shipped a release since Jan 2023.
- Test coverage via cargo-llvm-cov, chosen over cargo-tarpaulin for
  friendlier behavior in containerized/dind CI (no ptrace). Report-only
  for now (no --fail-under-lines) since a real threshold needs real usage
  data first — see below. main.rs is excluded: it's orchestration glue
  exercised by the real end-to-end `cargo run`, not unit tests.

Getting both gates running required writing pkgwatch's first tests
(previously zero). To make the GitHub-facing modules unit-testable
without hitting real github.com/api.github.com, added `GithubEndpoints`
(src/github.rs) so checker/fetcher/verifier take injectable base URLs,
and added mockito + tempfile as dev-dependencies. Result: 27 tests,
94% region / 96% line coverage excluding main.rs.

Also: cargo audit (now wired into `cargo make ci`) immediately caught a
real, currently-open advisory (RUSTSEC-2026-0285, published days ago) in
the transitive rustls dependency — bumped 0.23.44 -> 0.23.45 to clear it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 09:16:14 +02:00

126 lines
3.7 KiB
YAML

name: CI
on:
push:
branches: [master]
pull_request:
jobs:
build:
runs-on: rust-ci
steps:
- uses: actions/checkout@v4
- name: Cache cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Cache sccache compilation objects
uses: actions/cache@v4
with:
path: /root/.cache/sccache
# Not keyed to Cargo.lock: sccache caches individual compiler
# invocations by content hash, so it should accumulate across
# dependency bumps rather than reset like the target/ cache above.
key: sccache-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
# Cognitive complexity (clippy nursery lint — see clippy.toml for why
# not literal cyclomatic complexity), bin target only so test code's
# naturally higher complexity isn't gated on this.
- name: Complexity
run: cargo clippy --bins -- -D warnings -W clippy::cognitive_complexity
- name: Check release profile compiles
run: cargo check --release
test:
needs: build
runs-on: rust-ci
steps:
- uses: actions/checkout@v4
- name: Cache cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Cache sccache compilation objects
uses: actions/cache@v4
with:
path: /root/.cache/sccache
key: sccache-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-
- name: Test
run: cargo test
coverage:
needs: build
runs-on: rust-ci
steps:
- uses: actions/checkout@v4
- name: Cache cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Cache sccache compilation objects
uses: actions/cache@v4
with:
path: /root/.cache/sccache
key: sccache-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-
# Not baked into the rust-ci image (see docker/rust-ci in
# infrastructure) — install fresh each run rather than bumping the
# shared image just for this one project.
- name: Install cargo-llvm-cov
run: |
rustup component add llvm-tools-preview
command -v cargo-llvm-cov >/dev/null 2>&1 || cargo install cargo-llvm-cov --locked
# Reports coverage only — no --fail-under-lines yet. main.rs is
# excluded: thin orchestration glue exercised by the real end-to-end
# `cargo run` against live GitHub, not unit tests, so it's not a
# meaningful signal here. See Makefile.toml > coverage-report.
- name: Coverage
run: cargo llvm-cov --ignore-filename-regex 'main\.rs' --summary-only
audit:
needs: test
runs-on: rust-ci
steps:
- uses: actions/checkout@v4
- name: cargo audit
run: cargo audit