name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions: {}
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: ${{ github.event_name == 'workflow_dispatch' && fromJSON('["ubuntu-latest","macos-latest","windows-latest"]') || fromJSON('["ubuntu-latest"]') }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: check-${{ matrix.os }}
- name: Run tests
run: cargo test --all-targets
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Format
run: cargo fmt --all -- --check
- name: Check for uncommitted changes
run: git diff --exit-code
doc:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: doc
- name: Check documentation
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --no-deps --document-private-items
typos:
name: Typos
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: crate-ci/typos@cf5f1c29a8ac336af8568821ec41919923b05a83
audit:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: taiki-e/install-action@9b29ffac42f36c4efe76140737435c61cfb92383 - run: cargo audit
deny:
name: Cargo Deny
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: EmbarkStudios/cargo-deny-action@3fd3802e88374d3fe9159b834c7714ec57d6c979
shear:
name: Unused Dependencies
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: taiki-e/install-action@b9da40722b5dc25d162879fdf6a098f2d71926cc - run: cargo shear
zizmor:
name: Actions Security
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 - run: uvx zizmor --min-confidence medium --format plain .
msrv:
name: MSRV (1.75)
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - name: Install pinned MSRV toolchain
run: |
rustup toolchain install 1.75.0 --profile minimal
rustup override set 1.75.0
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: msrv
- run: cargo check --all-targets
publish-dry-run:
name: Publish (dry run)
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: publish-dry-run
- run: cargo publish --dry-run
ci-ok:
name: CI
if: always()
needs: [check, doc, typos, audit, deny, shear, zizmor, msrv, publish-dry-run]
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: {}
steps:
- name: All checks passed
env:
RESULTS: ${{ toJSON(needs.*.result) }}
run: |
for result in $(echo "$RESULTS" | jq -r '.[]'); do
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
echo "::error::Job failed with result: $result"
exit 1
fi
done