Skip to content

Commit a3dcbe4

Browse files
committed
refactor: consolidate CI and pre-commit to use mise
1 parent 7c6598c commit a3dcbe4

3 files changed

Lines changed: 74 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,59 @@ on:
44
push:
55
pull_request:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
permissions:
812
contents: read
913

14+
env:
15+
MISE_VERSION: "2026.6.14"
16+
1017
jobs:
11-
test:
18+
ci:
19+
name: ${{ matrix.task }}
1220
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]
2025

21-
clippy:
22-
runs-on: ubuntu-latest
2326
steps:
2427
- name: Checkout repository
2528
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v4
26-
- name: Clippy
27-
run: cargo clippy --verbose
29+
with:
30+
fetch-depth: 1
31+
persist-credentials: false
2832

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') }}
3641

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 }}"

.pre-commit-config.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ repos:
55
name: fmt
66
language: system
77
files: '\.rs$'
8-
entry: cargo fmt -- --check
8+
entry: mise run fmt
9+
pass_filenames: false
910
- id: clippy
1011
name: clippy
1112
language: system
1213
files: '\.rs$'
13-
entry: cargo clippy --all-targets --all -- -D warnings
14+
entry: mise run clippy
1415
pass_filenames: false
1516
- id: test
1617
name: test
1718
language: system
1819
files: '\.rs$'
19-
entry: cargo test
20+
entry: mise run test
21+
pass_filenames: false
22+
- id: deny
23+
name: deny
24+
language: system
25+
files: '^(Cargo\.lock|Cargo\.toml|deny\.toml|mise\.toml)$'
26+
entry: mise run deny
2027
pass_filenames: false
21-
- repo: https://github.com/EmbarkStudios/cargo-deny
22-
rev: 0.14.24
23-
hooks:
24-
- id: cargo-deny
25-
args: ["--all-features", "check"]
2628
- repo: https://github.com/gitleaks/gitleaks
2729
rev: v8.18.4
2830
hooks:

mise.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tools]
2+
rust = { version = "1.96.0", components = "rustfmt,clippy" }
3+
4+
[tasks.fmt]
5+
description = "Check Rust formatting"
6+
run = "cargo fmt --all --check"
7+
8+
[tasks.clippy]
9+
description = "Lint all Rust targets"
10+
run = "cargo clippy --all-targets --all-features -- -D warnings"
11+
12+
[tasks.test]
13+
description = "Run all tests"
14+
run = "cargo test --all-features"
15+
16+
[tasks.deny]
17+
description = "Audit dependencies"
18+
tools = { "cargo:cargo-deny" = "0.19.9" }
19+
run = "cargo deny --all-features check"

0 commit comments

Comments
 (0)