Repository navigation
97 lines (90 loc) · 3.73 KB
/
Copy pathci.yml
File metadata and controls
97 lines (90 loc) · 3.73 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: CI
# Until this existed nothing built, tested or linted on push. That is how a
# test lost its `#[test]` attribute and went unnoticed, how `clippy` accumulated
# 189 warnings across 153 sites, and how `cargo fmt` drifted on 296 files.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
# One run per branch. A new push cancels the one still grinding on the commit
# it replaced, so iterating quickly costs one run rather than a queue of them.
# Scoped by ref, so a PR and main never cancel each other.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
# Fail on warnings everywhere, not just where clippy is invoked: an unused
# import or an unreachable statement is the shape most of today's real
# findings took.
RUSTFLAGS: -D warnings
jobs:
test:
name: Test (${{ matrix.features.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Both configurations, deliberately. `cargo clippy --fix` once removed a
# `mut` that only the `smtp` build needs -- the push it guards is behind
# `#[cfg(feature = "smtp")]`, so a default-features build compiled and
# every test passed while `--features smtp` would not compile at all.
# That is the configuration the production node runs.
features:
- name: default
crate: --workspace
flags: ''
- name: smtp
crate: -p rustock-cli
flags: --features smtp
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.1
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --locked ${{ matrix.features.crate }} ${{ matrix.features.flags }}
- name: Test
run: cargo test --locked ${{ matrix.features.crate }} ${{ matrix.features.flags }}
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.1
with:
components: clippy
- uses: Swatinem/rust-cache@v2
# --all-targets covers tests, benches and examples. The one genuine bug
# clippy found -- `tip.max(N).min(N)`, always the constant -- was in an
# example, which a bare `cargo clippy` would not have linted.
- name: Clippy (workspace)
run: cargo clippy --locked --workspace --all-targets -- -D warnings
- name: Clippy (smtp)
run: cargo clippy --locked -p rustock-cli --all-targets --features smtp -- -D warnings
# Not gating yet: the tree is not rustfmt-clean (296 files at the time this
# workflow was added), and formatting it is a separate, deliberate commit
# rather than something to fold into an unrelated change. Reported so the
# number is visible and shrinking rather than silently growing.
fmt:
name: Rustfmt (advisory)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.93.1
with:
components: rustfmt
# Reports, never fails. A red check that is expected to be red is worse
# than no check: this repository already has a permanently-failing
# cargo-deny job that everyone has learned to scroll past, and a second
# one would make a real failure easier to miss. Promote this to gating
# (drop the "|| true" and the continue-on-error above) once the
# formatting commit lands.
- name: Report formatting drift
run: |
files=$(cargo fmt --all --check 2>/dev/null | grep -c "^Diff in" || true)
echo "::notice::${files} file(s) differ from rustfmt"
echo "### Rustfmt: ${files} file(s) differ" >> "$GITHUB_STEP_SUMMARY"