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@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
components: rustfmt, clippy
- name: Install pinned protoc without system changes
run: |
curl -fsSL https://github.com/protocolbuffers/protobuf/releases/download/v36.2/protoc-36.2-linux-x86_64.zip -o "$RUNNER_TEMP/protoc.zip"
echo '121f6c7afe1d4d0e3ea6aab9432038599250134cbf4474cb1167d2c7decd4278 '"$RUNNER_TEMP/protoc.zip" | sha256sum --check
unzip -q "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc"
echo "$RUNNER_TEMP/protoc/bin" >> "$GITHUB_PATH"
- 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@e2a55d2ffb04f378e9626c28d38b36d230d1e12f 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."