| 1 |
on: |
| 2 |
push: |
| 3 |
branches: [ main ] |
| 4 |
pull_request: |
| 5 |
merge_group: |
| 6 |
|
| 7 |
name: CI |
| 8 |
|
| 9 |
jobs: |
| 10 |
ci: |
| 11 |
runs-on: ubuntu-latest |
| 12 |
strategy: |
| 13 |
fail-fast: false |
| 14 |
matrix: |
| 15 |
rust: |
| 16 |
- 1.36.0 # MSRV |
| 17 |
- stable |
| 18 |
- beta |
| 19 |
- nightly |
| 20 |
features: |
| 21 |
- "" |
| 22 |
- "serde" |
| 23 |
|
| 24 |
steps: |
| 25 |
- name: Checkout |
| 26 |
uses: actions/checkout@v4 |
| 27 |
|
| 28 |
- name: Cache the registry |
| 29 |
uses: actions/cache@v4 |
| 30 |
if: startsWith(matrix.rust, '1') |
| 31 |
with: |
| 32 |
path: ~/.cargo/registry/index |
| 33 |
key: cargo-${{ matrix.rust }}-git-index |
| 34 |
|
| 35 |
- name: Set up Rust |
| 36 |
uses: dtolnay/rust-toolchain@master |
| 37 |
with: |
| 38 |
toolchain: ${{ matrix.rust }} |
| 39 |
|
| 40 |
- name: MSRV dependencies |
| 41 |
if: matrix.rust == '1.36.0' |
| 42 |
run: | |
| 43 |
cargo generate-lockfile |
| 44 |
cargo update -p serde_json --precise 1.0.99 |
| 45 |
cargo update -p serde --precise 1.0.156 |
| 46 |
cargo update -p quote --precise 1.0.30 |
| 47 |
cargo update -p proc-macro2 --precise 1.0.65 |
| 48 |
|
| 49 |
- name: Build (no_std) |
| 50 |
run: cargo build --no-default-features |
| 51 |
|
| 52 |
- name: Build |
| 53 |
run: cargo build --features "${{ matrix.features }}" |
| 54 |
|
| 55 |
- name: Test |
| 56 |
run: cargo test --features "${{ matrix.features }}" |
| 57 |
|
| 58 |
- name: Doc |
| 59 |
run: cargo doc --features "${{ matrix.features }}" |
| 60 |
|
| 61 |
clippy: |
| 62 |
name: Rustfmt and Clippy |
| 63 |
runs-on: ubuntu-latest |
| 64 |
steps: |
| 65 |
- name: Checkout |
| 66 |
uses: actions/checkout@v4 |
| 67 |
|
| 68 |
- name: Set up nightly Rust |
| 69 |
uses: dtolnay/rust-toolchain@nightly |
| 70 |
with: |
| 71 |
components: rustfmt, clippy |
| 72 |
|
| 73 |
- name: Rustfmt |
| 74 |
run: cargo fmt --all -- --check |
| 75 |
|
| 76 |
- name: Clippy |
| 77 |
run: cargo clippy # -- -D warnings |
| 78 |
|
| 79 |
# One job that "summarizes" the success state of this pipeline. This can then be added to branch |
| 80 |
# protection, rather than having to add each job separately. |
| 81 |
success: |
| 82 |
name: Success |
| 83 |
runs-on: ubuntu-latest |
| 84 |
needs: [ci, clippy] |
| 85 |
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency |
| 86 |
# failed" as success. So we have to do some contortions to ensure the job fails if any of its |
| 87 |
# dependencies fails. |
| 88 |
if: always() # make sure this is never "skipped" |
| 89 |
steps: |
| 90 |
# Manually check the status of all dependencies. `if: failure()` does not work. |
| 91 |
- name: check if any dependency failed |
| 92 |
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' |