Skip to content

Commit 0306788

Browse files
committed
[ci/rust] bumps workflow
- runs workflow when - toolchain configuration changes - rustfmt configuration changes - limits workflow concurrency - no longer use actions-rs actions, which are outdated/archived, use plain run instead of actions - use actions-rust-lang/setup-rust-toolchain to use toolchain file - no longer check stable/beta/nightly but the pinned version, dependabot will bump/test to the next toolchain version - determine msrv - cargo fmt --check and clippy are run against version from toolchain file - cargo check build and test are run against both msrv and toolchain file - bumps actions/checkout
1 parent e90c112 commit 0306788

1 file changed

Lines changed: 68 additions & 26 deletions

File tree

.github/workflows/rust.yml

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
pull_request:
77
paths:
88
- '.github/workflows/rust.yml'
9+
- '.rustfmt.toml'
10+
- 'rust-toolchain.toml'
911
- 'Cargo.toml'
1012
- 'Cargo.lock'
1113
- '**.rs'
@@ -15,60 +17,100 @@ on:
1517
- wip/next
1618
paths:
1719
- '.github/workflows/rust.yml'
20+
- '.rustfmt.toml'
21+
- 'rust-toolchain.toml'
1822
- 'Cargo.toml'
1923
- 'Cargo.lock'
2024
- '**.rs'
2125

26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
28+
cancel-in-progress: true
29+
2230
env:
2331
CARGO_TERM_COLOR: always
2432
CARGO_TERM_VERBOSE: true
2533

2634
jobs:
2735

28-
test:
29-
name: ubuntu-${{ matrix.toolchain }}
36+
check:
37+
name: cargo fmt --check and clippy
3038
runs-on: ubuntu-latest
3139

32-
strategy:
33-
matrix:
34-
toolchain: [stable, beta, nightly]
35-
3640
steps:
3741

3842
- name: checkout
39-
uses: actions/checkout@v5
43+
uses: actions/checkout@v6
4044

4145
- name: set up rust toolchain
42-
uses: actions-rs/toolchain@v1
46+
uses: actions-rust-lang/setup-rust-toolchain@v1
4347
with:
44-
profile: minimal
45-
toolchain: ${{ matrix.toolchain }}
4648
components: clippy, rustfmt
49+
rustflags: ''
4750

48-
- name: cargo check
49-
uses: actions-rs/cargo@v1
50-
with:
51-
command: check
51+
- name: check formatting
52+
run: cargo fmt --check
5253

5354
- name: cargo clippy
54-
uses: actions-rs/cargo@v1
55+
run: cargo clippy
56+
57+
msrv:
58+
name: msrv
59+
runs-on: ubuntu-latest
60+
61+
outputs:
62+
msrv: ${{ steps.msrv.outputs.msrv }}
63+
64+
steps:
65+
66+
- name: checkout
67+
uses: actions/checkout@v6
68+
69+
- name: install cargo-msrv
70+
uses: taiki-e/install-action@v2
5571
with:
56-
command: clippy
72+
tool: cargo-msrv
5773

58-
- name: check formatting
59-
uses: actions-rs/cargo@v1
74+
- name: show cargo-msrv version
75+
run: cargo msrv --version
76+
77+
- name: get msrv
78+
run: |
79+
msrv=$(cargo msrv show --output-format minimal)
80+
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"
81+
id: msrv
82+
83+
- name: show msrv
84+
run: echo ${{ steps.msrv.outputs.msrv }}
85+
86+
test:
87+
name: cargo check, build and test
88+
runs-on: ubuntu-latest
89+
needs: msrv
90+
91+
strategy:
92+
matrix:
93+
toolchain:
94+
- null # this will use rust-toolchain.toml
95+
- ${{ needs.msrv.outputs.msrv }}
96+
97+
steps:
98+
99+
- name: checkout
100+
uses: actions/checkout@v6
101+
102+
- name: set up rust toolchain
103+
uses: actions-rust-lang/setup-rust-toolchain@v1
60104
with:
61-
command: fmt
62-
args: -- --check
105+
toolchain: ${{ matrix.toolchain }}
106+
107+
- name: cargo check
108+
run: cargo check
63109

64110
- name: cargo build
65-
uses: actions-rs/cargo@v1
66-
with:
67-
command: build
111+
run: cargo build
68112

69113
- name: cargo test
70-
uses: actions-rs/cargo@v1
71-
with:
72-
command: test
114+
run: cargo test
73115

74116
...

0 commit comments

Comments
 (0)