1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Quality Gate
on:
push:
branches:
- '**'
pull_request:
branches:
- main
- 'release/**'
permissions:
contents: read
concurrency:
group: quality-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
quality:
name: make check
runs-on: ubuntu-latest
steps:
- name: Checkout
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Install Rust
# dtolnay/rust-toolchain master (the generic action; the version branches
# such as `1.14` hardcode that Rust release and reject a `toolchain` input)
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772
id: toolchain
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache Rust dependencies
# actions/cache v6.1.0
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-quality-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-quality-${{ steps.toolchain.outputs.cachekey }}-
- name: Install make
run: sudo apt-get update && sudo apt-get install -y make
# This is the whole gate. It is the same single command a contributor
# runs locally, so CI and local development cannot diverge: the matrix,
# the strict lints, the banned-pattern scan, the README check and the
# audit are all defined once, in the Makefile.
- name: Run the quality gate
run: make check
# `make check` must be read-only. If any target mutated a tracked file,
# the gate would be able to "pass" by editing the worktree instead of
# reporting — which is exactly what `make fmt` in the format job and
# `cargo fix` in pre-push used to do.
- name: Assert the gate changed nothing
run: |
if ! git diff --quiet; then
echo "The quality gate modified tracked files:"
git --no-pager diff --stat
exit 1
fi
echo "OK: the gate is read-only"