name: CI
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 0 * * 0'
permissions:
contents: read
jobs:
test:
name: Format, lint, test (stable)
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Setup Rust
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 with:
toolchain: stable
components: rustfmt, clippy
- run: cargo fmt --check
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test
- name: Core library without CLI dependencies
run: |
cargo build --lib --no-default-features
cargo clippy --lib --no-default-features -- -D warnings
cargo test --no-default-features
RUSTDOCFLAGS='-D warnings' cargo doc --no-default-features --no-deps
if cargo tree --no-default-features --edges normal --prefix none | grep -E '^(clap|clap_complete|env_logger) '; then
echo "CLI-only dependency found in the core library graph"
exit 1
fi
msrv:
name: Build (MSRV 1.96)
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Setup Rust
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 with:
toolchain: "1.96"
- run: cargo build
audit:
name: Dependency security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Audit dependencies
uses: actions-rust-lang/audit@72c09e02f132669d52284a3323acdb503cfc1a24
pin-check:
name: Actions pinned to SHA
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Require all actions to be pinned to a full commit SHA
run: |
set -euo pipefail
# Every `uses:` (except local ./ actions) must be pinned to a 40-char commit SHA.
# dist's generated release.yml is hand-pinned post-generation; this guards against a
# regeneration silently reverting it to mutable tags.
unpinned="$(grep -rEn '^[[:space:]]*-?[[:space:]]*uses:[[:space:]]' .github/workflows \
| grep -vE 'uses:[[:space:]]*\./' \
| grep -vE 'uses:[[:space:]]*[^@]+@[0-9a-f]{40}([[:space:]]|"|$)' || true)"
if [ -n "$unpinned" ]; then
echo "::error::These actions are not pinned to a full commit SHA:"
echo "$unpinned"
echo "Pin like: uses: owner/repo@<40-char-sha> # vX"
exit 1
fi
echo "All workflow actions are SHA-pinned."