1+ # This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
2+ # several checks:
3+ # - fmt: checks that the code is formatted according to rustfmt
4+ # - clippy: checks that the code does not contain any clippy warnings
5+ # - doc: checks that the code can be documented without errors
6+ # - hack: check combinations of feature flags
7+ # - msrv: check that the msrv specified in the crate is correct
8+ permissions :
9+ contents : read
10+ # This configuration allows maintainers of this repo to create a branch and pull request based on
11+ # the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
12+ # built once.
113on :
214 push :
315 branches : [main]
416 pull_request :
17+ # If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
18+ # we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
19+ concurrency :
20+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+ cancel-in-progress : true
522name : check
623jobs :
724 fmt :
@@ -12,96 +29,85 @@ jobs:
1229 with :
1330 submodules : true
1431 - name : Install stable
15- uses : actions-rs/ toolchain@v1
32+ uses : dtolnay/rust- toolchain@stable
1633 with :
17- profile : minimal
18- toolchain : stable
1934 components : rustfmt
2035 - name : cargo fmt --check
21- uses : actions-rs/cargo@v1
22- with :
23- command : fmt
24- args : --check
36+ run : cargo fmt --check
2537 clippy :
2638 runs-on : ubuntu-latest
2739 name : ${{ matrix.toolchain }} / clippy
40+ permissions :
41+ contents : read
42+ checks : write
2843 strategy :
2944 fail-fast : false
3045 matrix :
46+ # Get early warning of new lints which are regularly introduced in beta channels.
3147 toolchain : [stable, beta]
3248 steps :
3349 - uses : actions/checkout@v4
3450 with :
3551 submodules : true
3652 - name : Install ${{ matrix.toolchain }}
37- uses : actions-rs/ toolchain@v1
53+ uses : dtolnay/rust- toolchain@master
3854 with :
39- profile : minimal
4055 toolchain : ${{ matrix.toolchain }}
41- default : true
4256 components : clippy
4357 - name : cargo clippy
44- uses : actions-rs /clippy-check @v1
58+ uses : giraffate /clippy-action @v1
4559 with :
46- token : ${{ secrets.GITHUB_TOKEN }}
60+ reporter : ' github-pr-check'
61+ github_token : ${{ secrets.GITHUB_TOKEN }}
4762 doc :
63+ # run docs generation on nightly rather than stable. This enables features like
64+ # https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
65+ # API be documented as only available in some specific platforms.
4866 runs-on : ubuntu-latest
4967 name : nightly / doc
5068 steps :
5169 - uses : actions/checkout@v4
5270 with :
5371 submodules : true
5472 - name : Install nightly
55- uses : actions-rs/toolchain@v1
56- with :
57- profile : minimal
58- toolchain : nightly
59- default : true
73+ uses : dtolnay/rust-toolchain@nightly
6074 - name : cargo doc
61- uses : actions-rs/cargo@v1
62- with :
63- command : doc
64- args : --no-deps --all-features
75+ run : cargo doc --no-deps --all-features
6576 env :
6677 RUSTDOCFLAGS : --cfg docsrs
6778 hack :
79+ # cargo-hack checks combinations of feature flags to ensure that features are all additive
80+ # which is required for feature unification
6881 runs-on : ubuntu-latest
6982 name : ubuntu / stable / features
7083 steps :
7184 - uses : actions/checkout@v4
7285 with :
7386 submodules : true
7487 - name : Install stable
75- uses : actions-rs/toolchain@v1
76- with :
77- profile : minimal
78- toolchain : stable
88+ uses : dtolnay/rust-toolchain@stable
7989 - name : cargo install cargo-hack
8090 uses : taiki-e/install-action@cargo-hack
91+ # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
92+ # --feature-powerset runs for every combination of features
8193 - name : cargo hack
82- uses : actions-rs/cargo@v1
83- with :
84- command : hack
85- args : --feature-powerset check --lib --tests
94+ run : cargo hack --feature-powerset check
8695 msrv :
96+ # check that we can build using the minimal rust version that is specified by this crate
8797 runs-on : ubuntu-latest
8898 # we use a matrix here just because env can't be used in job names
8999 # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
90100 strategy :
91101 matrix :
92- msrv : [1.66.0] # for jobserver
102+ msrv : [" 1.66.0" ] # for jobserver
93103 name : ubuntu / ${{ matrix.msrv }}
94104 steps :
95105 - uses : actions/checkout@v4
96106 with :
97107 submodules : true
98- - name : Install ${{ matrix.toolchain }}
99- uses : actions-rs/ toolchain@v1
108+ - name : Install ${{ matrix.msrv }}
109+ uses : dtolnay/rust- toolchain@master
100110 with :
101- profile : minimal
102111 toolchain : ${{ matrix.msrv }}
103- default : true
104112 - name : cargo +${{ matrix.msrv }} check
105- uses : actions-rs/cargo@v1
106- with :
107- command : check
113+ run : cargo check
0 commit comments