diff --git a/.github/workflows/cargo-ci.yml b/.github/workflows/cargo-ci.yml new file mode 100644 index 0000000..8a4522e --- /dev/null +++ b/.github/workflows/cargo-ci.yml @@ -0,0 +1,51 @@ +name: Cargo CI + +# Gates the Rust containment proxy: format, lint, tests, and a dependency audit. +# Every action is pinned to a full commit SHA, not a tag, so a compromised or +# retagged action cannot slip new code into CI. + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Install Rust toolchain (stable, with rustfmt + clippy) + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable + with: + toolchain: stable + components: rustfmt, clippy + + - name: Cache cargo build + uses: Swatinem/rust-cache@aa7c1c80a07a27a84c0aa76d0cef0aad3830e330 # v2.7.8 + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Clippy (deny warnings) + run: cargo clippy --all-targets -- -D warnings + + - name: Tests + # Single-threaded so the deterministic IO tests (audit/nonce) do not race. + run: cargo test --all -- --test-threads=1 + + audit: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Security audit + uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }}