name: CI
on:
push:
branches: ["**"]
pull_request:
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
ci:
name: Check, Test, Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Install the pinned toolchain
run: rustup toolchain install
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: |
cargo fmt --all --check
cargo fmt --manifest-path fuzz/Cargo.toml --all --check
- name: cargo check
run: cargo check --locked
- name: Prepare a directory outside temp and home
shell: bash
run: |
set -eu
case "$(uname -s)" in
Linux)
base="${RUNNER_TOOL_CACHE:-/opt}"
dir="${base}/safe-chains-outside"
mkdir -p "$dir"
;;
Darwin)
dir="/usr/local/safe-chains-outside"
mkdir -p "$dir"
;;
*)
echo "no directory outside temp and home on $(uname -s)" >&2
exit 1
;;
esac
echo "SAFE_CHAINS_TEST_OUTSIDE_DIR=${dir}" >> "$GITHUB_ENV"
- name: cargo test
run: cargo test --locked
env:
SAFE_CHAINS_REQUIRE_OUTSIDE: "1"
- name: cargo test (gen-fuzz-corpus)
run: cargo test --locked --features fuzz-gen --bin gen-fuzz-corpus
- name: cargo clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: cargo doc
run: cargo doc --locked --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
- name: Verify COMMANDS.md is up to date
run: |
cargo run --locked -- --list-commands > COMMANDS.md.check
diff -u COMMANDS.md COMMANDS.md.check || {
echo "::error::COMMANDS.md is out of date. Run ./generate-docs.sh and commit."
exit 1
}
- uses: taiki-e/install-action@cargo-deny
- name: cargo deny check
run: cargo deny check
- uses: taiki-e/install-action@cargo-machete
- name: cargo machete
run: cargo machete
- name: shellcheck
run: git ls-files -z '*.sh' | xargs -0 shellcheck
msrv:
name: MSRV
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Install the declared minimum Rust
run: |
msrv=$(sed -n 's/^rust-version = "\(.*\)"/\1/p' Cargo.toml)
test -n "$msrv"
rustup toolchain install "$msrv" --profile minimal
echo "MSRV=$msrv" >> "$GITHUB_ENV"
# Every later step, rust-cache's key included, runs on the MSRV rather than installing
# the toolchain rust-toolchain.toml pins.
echo "RUSTUP_TOOLCHAIN=$msrv" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@v2
- name: cargo check on the MSRV
run: cargo +"$MSRV" check --locked