-
Notifications
You must be signed in to change notification settings - Fork 0
270 lines (256 loc) · 11 KB
/
Copy pathci.yml
File metadata and controls
270 lines (256 loc) · 11 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
# Build, lint, and run the full test suite (unit/component + integration)
# on both first-class platforms. Windows is included so the Windows Service
# and Event Log code is compiled, linted, and tested too.
test:
name: test & clippy (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: clippy
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Clippy (all targets, warnings denied)
run: cargo clippy --all-targets --locked -- -D warnings
# The plugin SDK is behind an off-by-default `plugins` feature, so the
# default steps never compile it. Lint and test it explicitly on both
# platforms so the feature-gated module and its core call sites cannot
# bitrot. The default steps stay too, proving the stock build is unchanged.
- name: Clippy (plugins feature, warnings denied)
run: cargo clippy --all-targets --locked --features plugins -- -D warnings
- name: Test (lib, bins, integration, examples)
run: cargo test --all-targets --locked
env:
# On Windows, require the ProgramData DACL tests to actually run: they
# skip on a non-elevated account, so without this a runner that cannot
# apply the DACL could report green while never verifying it. Empty on
# Linux (the tests are Windows-only), where it has no effect.
ALIGHIERI_REQUIRE_DACL_TESTS: ${{ matrix.os == 'windows-latest' && '1' || '' }}
- name: Test (plugins feature)
run: cargo test --all-targets --locked --features plugins
env:
ALIGHIERI_REQUIRE_DACL_TESTS: ${{ matrix.os == 'windows-latest' && '1' || '' }}
- name: Doctests
run: cargo test --doc --locked
# Cross-compile the extra ARM64 release targets so the release matrix is
# validated on every change, not only when a tag is pushed. Build-only: the
# x86_64 GitHub runners cannot execute these binaries.
cross-build:
name: cross-build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
- os: windows-latest
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install aarch64 cross toolchain (Linux)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.linker }}
# Linker for cargo, and CC so cc-rs build scripts (e.g. ring) use the
# cross compiler instead of the host toolchain.
{
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc"
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc"
} >> "$GITHUB_ENV"
- name: Cross-compile (release, build-only)
run: cargo build --release --locked --target ${{ matrix.target }}
# Formatting is platform-independent, so check it once.
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# Lint the Linux management scripts and run their bundled self-tests (the
# installer's path-normalisation and hardened-path warning logic). shellcheck
# is preinstalled on the GitHub-hosted Ubuntu runners.
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Lint shell scripts
run: shellcheck scripts/*.sh
- name: Run installer self-tests
run: bash scripts/alighieri.sh __selftest
# Verify the crate still builds on its declared minimum supported Rust
# version (Cargo.toml `rust-version`). Clippy and rustfmt stay on the stable
# job above: their output drifts across releases, so pinning them here would
# freeze tooling at the MSRV instead of tracking current stable.
msrv:
name: build on MSRV (1.88)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust 1.88
uses: dtolnay/rust-toolchain@98e1b82157cd469e843cb7f524c1313b4ad9492c # 1.88.0
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build all targets on the MSRV toolchain
run: cargo build --all-targets --locked
# Verify the feature-gated plugin SDK (and its extra dependency,
# async-trait) also builds on the MSRV toolchain.
- name: Build with the plugins feature on the MSRV toolchain
run: cargo build --all-targets --locked --features plugins
# Exercise the exact source archive that crates.io will receive. This catches
# allowlist mistakes, missing docs/examples, and dependencies on repository
# files that are not present after Cargo extracts the `.crate` archive.
package:
name: crates.io package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build all-feature documentation (warnings denied)
run: cargo doc --all-features --no-deps --locked
env:
RUSTDOCFLAGS: -D warnings
- name: Check package contents
shell: bash
run: |
set -euo pipefail
package_list="$RUNNER_TEMP/alighieri-package-files.txt"
cargo package --list --locked > "$package_list"
required=(
Cargo.toml
Cargo.lock
src/lib.rs
src/main.rs
README.md
CHANGELOG.md
LICENSE
LICENSING.md
doc/alighieri.conf
doc/plugin-sdk.md
scripts/alighieri.sh
scripts/install-linux.sh
)
for path in "${required[@]}"; do
if ! grep -Fqx "$path" "$package_list"; then
echo "::error::Required package file is missing: $path"
exit 1
fi
done
forbidden='^(\.github|\.agents|\.codex|target)/|^(\.dockerignore|Dockerfile)$'
if grep -En "$forbidden" "$package_list"; then
echo "::error::The package contains repository-only files"
exit 1
fi
- name: Build and extract package
shell: bash
run: |
set -euo pipefail
cargo package --locked
package_version="$(
python3 -c \
'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["version"])'
)"
crate_file="target/package/alighieri-$package_version.crate"
if [[ ! -f "$crate_file" ]]; then
echo "::error::cargo package did not produce $crate_file"
exit 1
fi
extract_root="$RUNNER_TEMP/alighieri-package"
mkdir -p "$extract_root"
tar -xzf "$crate_file" -C "$extract_root"
crate_dir="$(find "$extract_root" -mindepth 1 -maxdepth 1 -type d -name 'alighieri-*' -print -quit)"
if [[ -z "$crate_dir" ]]; then
echo "::error::Could not locate the extracted alighieri package"
exit 1
fi
echo "CRATE_DIR=$crate_dir" >> "$GITHUB_ENV"
- name: Test extracted package (default features)
run: cargo test --manifest-path "$CRATE_DIR/Cargo.toml" --all-targets --locked
- name: Test extracted package (all features)
run: cargo test --manifest-path "$CRATE_DIR/Cargo.toml" --all-targets --all-features --locked
- name: Install and smoke-test extracted binary
shell: bash
run: |
set -euo pipefail
install_root="$RUNNER_TEMP/alighieri-install"
cargo install --path "$CRATE_DIR" --locked --root "$install_root"
"$install_root/bin/alighieri" --version
"$install_root/bin/alighieri" --help
"$install_root/bin/alighieri" --check "$CRATE_DIR/doc/alighieri.conf"
# There is no registry baseline until the manual 0.4.0 publication. Probe for
# that exact version so this job is harmless before the first release and
# automatically becomes a required compatibility check afterwards.
semver:
name: public API semver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Check whether the 0.4.0 registry baseline exists
id: baseline
shell: bash
run: |
set -euo pipefail
response="$RUNNER_TEMP/alighieri-0.4.0.json"
status="$(
curl --silent --show-error --location \
--retry 3 --retry-all-errors \
--header "User-Agent: Wiresock-Foundation/alighieri CI" \
--output "$response" --write-out '%{http_code}' \
https://crates.io/api/v1/crates/alighieri/0.4.0
)"
case "$status" in
200)
echo "available=true" >> "$GITHUB_OUTPUT"
;;
404)
echo "available=false" >> "$GITHUB_OUTPUT"
echo "alighieri 0.4.0 is not published yet; skipping the semver baseline check"
;;
*)
cat "$response"
echo "::error::crates.io returned HTTP $status while checking the semver baseline"
exit 1
;;
esac
- name: Check public API compatibility
if: steps.baseline.outputs.available == 'true'
uses: obi1kenobi/cargo-semver-checks-action@6b69fcf40e9b5fb17adeb57e4b6ecd020649a239 # v2
with:
package: alighieri
feature-group: all-features