Debian Codegraph @

.github/workflows/check.yml

raw symbols SCIP
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.
13 on:
14 push:
15 branches: [main]
16 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
22 name: check
23 jobs:
24 fmt:
25 runs-on: ubuntu-latest
26 name: stable / fmt
27 steps:
28 - uses: actions/checkout@v4
29 with:
30 submodules: true
31 - name: Install stable
32 uses: dtolnay/rust-toolchain@stable
33 with:
34 components: rustfmt
35 - name: cargo fmt --check
36 run: cargo fmt --check
37 clippy:
38 runs-on: ubuntu-latest
39 name: ${{ matrix.toolchain }} / clippy
40 permissions:
41 contents: read
42 checks: write
43 strategy:
44 fail-fast: false
45 matrix:
46 # Get early warning of new lints which are regularly introduced in beta channels.
47 toolchain: [stable, beta]
48 steps:
49 - uses: actions/checkout@v4
50 with:
51 submodules: true
52 - name: Install ${{ matrix.toolchain }}
53 uses: dtolnay/rust-toolchain@master
54 with:
55 toolchain: ${{ matrix.toolchain }}
56 components: clippy
57 - name: cargo clippy
58 uses: giraffate/clippy-action@v1
59 with:
60 reporter: 'github-pr-check'
61 github_token: ${{ secrets.GITHUB_TOKEN }}
62 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.
66 runs-on: ubuntu-latest
67 name: nightly / doc
68 steps:
69 - uses: actions/checkout@v4
70 with:
71 submodules: true
72 - name: Install nightly
73 uses: dtolnay/rust-toolchain@nightly
74 - name: cargo doc
75 run: cargo doc --no-deps --all-features
76 env:
77 RUSTDOCFLAGS: --cfg docsrs
78 hack:
79 # cargo-hack checks combinations of feature flags to ensure that features are all additive
80 # which is required for feature unification
81 runs-on: ubuntu-latest
82 name: ubuntu / stable / features
83 steps:
84 - uses: actions/checkout@v4
85 with:
86 submodules: true
87 - name: Install stable
88 uses: dtolnay/rust-toolchain@stable
89 - name: cargo install cargo-hack
90 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
93 - name: cargo hack
94 run: cargo hack --feature-powerset check
95 msrv:
96 # check that we can build using the minimal rust version that is specified by this crate
97 runs-on: ubuntu-latest
98 # we use a matrix here just because env can't be used in job names
99 # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
100 strategy:
101 matrix:
102 msrv: ["1.40.0"] # map_get_key_value
103 name: ubuntu / ${{ matrix.msrv }}
104 steps:
105 - uses: actions/checkout@v4
106 with:
107 submodules: true
108 - name: Install ${{ matrix.msrv }}
109 uses: dtolnay/rust-toolchain@master
110 with:
111 toolchain: ${{ matrix.msrv }}
112 - name: cargo +${{ matrix.msrv }} check
113 run: cargo check