-
Notifications
You must be signed in to change notification settings - Fork 4
205 lines (175 loc) · 6.27 KB
/
Copy pathcommit.yaml
File metadata and controls
205 lines (175 loc) · 6.27 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Commit
on:
push:
branches:
- "**"
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CARGO_RAIL_TEST_MODE: commit
CARGO_INCREMENTAL: 0
permissions:
contents: read
checks: write
pull-requests: write
jobs:
# ==========================================================================
# Job 1: Planner (dogfooding cargo-rail-action v4)
# ==========================================================================
plan:
name: Plan
if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-latest
outputs:
build: ${{ steps.plan.outputs.build }}
test: ${{ steps.plan.outputs.test }}
docs: ${{ steps.plan.outputs.docs }}
infra: ${{ steps.plan.outputs.infra }}
base-ref: ${{ steps.plan.outputs.base-ref }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Build Plan
id: plan
uses: loadingalias/cargo-rail-action@95875a43ad5583b4d6a1dc65630afb0c2ecb6b30 # v4.1.3
with:
since: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
args: '--explain'
# ==========================================================================
# Job 2: MSRV enforcement (fast fail)
# ==========================================================================
msrv:
name: MSRV Check
needs: plan
if: needs.plan.outputs.build == 'true' || needs.plan.outputs.test == 'true' || needs.plan.outputs.infra == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Detect MSRV
id: msrv
shell: bash
run: |
msrv="$(python3 - <<'PY'
import pathlib, tomllib
data = tomllib.loads(pathlib.Path("Cargo.toml").read_text())
msrv = (
data.get("workspace", {}).get("package", {}).get("rust-version")
or data.get("package", {}).get("rust-version")
)
if isinstance(msrv, dict):
msrv = None
if not msrv:
raise SystemExit("No rust-version found in Cargo.toml")
print(msrv)
PY
)"
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"
echo "Using MSRV: $msrv"
- name: Install Rust MSRV Toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
with:
toolchain: ${{ steps.msrv.outputs.msrv }}
- name: Setup Rust Cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
shared-key: "cargo-rail-msrv-v1"
key: msrv-${{ steps.msrv.outputs.msrv }}
cache-on-failure: true
- name: Compile (MSRV)
run: cargo check --workspace --all-targets --all-features --locked
# ==========================================================================
# Job 3: CI Matrix
# ==========================================================================
ci:
name: CI (${{ matrix.target.name }})
needs: [msrv, plan]
if: needs.plan.outputs.build == 'true' || needs.plan.outputs.test == 'true' || needs.plan.outputs.infra == 'true'
runs-on: ${{ matrix.target.runner }}
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
target:
- name: x86_64-unknown-linux-gnu
runner: ubuntu-latest
cache-key: commit-linux-x64
- name: aarch64-unknown-linux-gnu
runner: ubuntu-24.04-arm
cache-key: commit-linux-arm64
- name: x86_64-pc-windows-msvc
runner: windows-latest
cache-key: commit-windows-x64
- name: aarch64-pc-windows-msvc
runner: windows-11-arm
cache-key: commit-windows-arm64
env:
RAIL_SINCE: ${{ needs.plan.outputs.base-ref }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup
uses: ./.github/actions/setup
with:
cache-key: ${{ matrix.target.cache-key }}
# Infra changes trigger full workspace; otherwise use change detection
- name: Quality Checks
run: just ci-check
- name: Build
if: needs.plan.outputs.infra == 'true'
run: just build-all
- name: Build (smart)
if: needs.plan.outputs.infra != 'true' && needs.plan.outputs.build == 'true'
run: just ci-build
- name: Tests
if: needs.plan.outputs.infra == 'true'
run: just test-all
- name: Tests (smart)
if: needs.plan.outputs.infra != 'true' && needs.plan.outputs.test == 'true'
run: just ci-test
- name: Upload JUnit Test Report
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: junit-report-${{ matrix.target.name }}
path: target/nextest/commit/junit.xml
retention-days: 7
if-no-files-found: ignore
- name: Detect JUnit Test Report
if: always()
id: junit
shell: bash
run: |
if [ -f target/nextest/commit/junit.xml ]; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish Test Report
if: always() && steps.junit.outputs.found == 'true'
uses: mikepenz/action-junit-report@74626db7353a25a20a72816467ebf035f674c5f8 # v6.2.0
with:
report_paths: 'target/nextest/commit/junit.xml'
check_name: 'Test Results (${{ matrix.target.name }})'
detailed_summary: true
include_passed: false
fail_on_failure: true
require_tests: true
annotate_only: false
summary: true