|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: true |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +env: |
| 15 | + # Lint levels live in `[lints]` in Cargo.toml so local and CI runs agree; |
| 16 | + # don't add a blanket RUSTFLAGS here. |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + |
| 19 | +jobs: |
| 20 | + rust: |
| 21 | + name: Rust |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v7 |
| 25 | + with: |
| 26 | + # This job executes repository code (cargo build/test); don't persist |
| 27 | + # the token in git config. |
| 28 | + persist-credentials: false |
| 29 | + submodules: true |
| 30 | + |
| 31 | + - uses: dtolnay/rust-toolchain@stable |
| 32 | + with: |
| 33 | + components: rustfmt, clippy |
| 34 | + |
| 35 | + - uses: Swatinem/rust-cache@v2 |
| 36 | + |
| 37 | + - name: Check formatting |
| 38 | + run: cargo fmt --all -- --check |
| 39 | + |
| 40 | + - name: Clippy |
| 41 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 42 | + |
| 43 | + - name: Build |
| 44 | + run: cargo build --all-targets --all-features |
| 45 | + |
| 46 | + - name: Test |
| 47 | + run: cargo test --all-features |
| 48 | + |
| 49 | + - name: Test default features |
| 50 | + run: cargo test |
| 51 | + |
| 52 | + docs: |
| 53 | + name: Docs |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v7 |
| 57 | + with: |
| 58 | + persist-credentials: false |
| 59 | + submodules: true |
| 60 | + |
| 61 | + - uses: dtolnay/rust-toolchain@stable |
| 62 | + |
| 63 | + - uses: Swatinem/rust-cache@v2 |
| 64 | + |
| 65 | + - name: Build documentation |
| 66 | + env: |
| 67 | + RUSTDOCFLAGS: -D warnings |
| 68 | + run: cargo doc --no-deps --all-features |
| 69 | + |
| 70 | + msrv: |
| 71 | + name: Minimum supported Rust version |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v7 |
| 75 | + with: |
| 76 | + persist-credentials: false |
| 77 | + submodules: true |
| 78 | + |
| 79 | + - name: Read rust-version from Cargo.toml |
| 80 | + id: msrv |
| 81 | + run: | |
| 82 | + set -euo pipefail |
| 83 | + msrv="$(cargo metadata --format-version 1 --no-deps \ |
| 84 | + | jq -r '.packages[0].rust_version')" |
| 85 | + if [[ -z "$msrv" || "$msrv" == "null" ]]; then |
| 86 | + echo "package.rust-version is not set in Cargo.toml" >&2 |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + echo "version=$msrv" >> "$GITHUB_OUTPUT" |
| 90 | +
|
| 91 | + - uses: dtolnay/rust-toolchain@master |
| 92 | + with: |
| 93 | + toolchain: ${{ steps.msrv.outputs.version }} |
| 94 | + |
| 95 | + - uses: Swatinem/rust-cache@v2 |
| 96 | + |
| 97 | + - name: Build with the declared MSRV |
| 98 | + run: cargo build --all-targets --all-features |
| 99 | + |
| 100 | + supply-chain: |
| 101 | + name: Supply chain |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v7 |
| 105 | + with: |
| 106 | + persist-credentials: false |
| 107 | + submodules: true |
| 108 | + |
| 109 | + - name: Check advisories, licenses, bans, and sources |
| 110 | + uses: EmbarkStudios/cargo-deny-action@v2 |
| 111 | + with: |
| 112 | + command: check all |
0 commit comments