|
4 | 4 | push: |
5 | 5 | pull_request: |
6 | 6 |
|
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: true |
| 10 | + |
7 | 11 | permissions: |
8 | 12 | contents: read |
9 | 13 |
|
| 14 | +env: |
| 15 | + MISE_VERSION: "2026.6.14" |
| 16 | + |
10 | 17 | jobs: |
11 | | - test: |
| 18 | + ci: |
| 19 | + name: ${{ matrix.task }} |
12 | 20 | runs-on: ubuntu-latest |
13 | | - steps: |
14 | | - - name: Checkout repository |
15 | | - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4 |
16 | | - - name: Build and test |
17 | | - run: cargo build --verbose |
18 | | - - name: Run tests |
19 | | - run: cargo test --verbose |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + task: [fmt, clippy, test, deny] |
20 | 25 |
|
21 | | - clippy: |
22 | | - runs-on: ubuntu-latest |
23 | 26 | steps: |
24 | 27 | - name: Checkout repository |
25 | 28 | uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4 |
26 | | - - name: Clippy |
27 | | - run: cargo clippy --verbose |
| 29 | + with: |
| 30 | + fetch-depth: 1 |
| 31 | + persist-credentials: false |
28 | 32 |
|
29 | | - fmt: |
30 | | - runs-on: ubuntu-latest |
31 | | - steps: |
32 | | - - name: Checkout repository |
33 | | - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4 |
34 | | - - name: Check formatting |
35 | | - run: cargo fmt --all --check |
| 33 | + - name: Cache Rust toolchain |
| 34 | + id: cache_rust_toolchain |
| 35 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + ~/.cargo/bin/ |
| 39 | + ~/.rustup/toolchains/ |
| 40 | + key: rust-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/mise.toml', '**/mise.lock' ,'**/mise.*.toml' ,'**/mise.*.lock') }} |
36 | 41 |
|
37 | | - cargo-deny: |
38 | | - runs-on: ubuntu-latest |
39 | | - steps: |
40 | | - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4 |
41 | | - - uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe # v2 |
| 42 | + - name: Install mise |
| 43 | + id: install_mise |
| 44 | + uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0 |
| 45 | + with: |
| 46 | + version: "${{ env.MISE_VERSION }}" |
| 47 | + |
| 48 | + # If `mise` cache was restored, but the actions cache for cargo binaries was busted (or missing), |
| 49 | + # then force reinstall of the Rust toolchains, so that the subsequent Rust actions do not fail. |
| 50 | + # The downloaded binaries will also be persisted in the actions cache at the end of the workflow. |
| 51 | + # |
| 52 | + # See https://github.com/jdx/mise-action/issues/215#issuecomment-4753881336 |
| 53 | + - name: Force reinstall Rust toolchain |
| 54 | + if: ${{ steps.install_mise.outputs.cache-hit == 'true' && steps.cache_rust_toolchain.outputs.cache-hit != 'true' }} |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + mise install --force rust |
| 58 | +
|
| 59 | + - name: Run ${{ matrix.task }} |
| 60 | + run: mise run "$MATRIX_TASK" |
| 61 | + env: |
| 62 | + MATRIX_TASK: "${{ matrix.task }}" |
0 commit comments