-
Notifications
You must be signed in to change notification settings - Fork 22
216 lines (183 loc) · 6.71 KB
/
Copy pathci.yml
File metadata and controls
216 lines (183 loc) · 6.71 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
name: CI
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
# Callable as a gate by release.yml, which passes the pinned release SHA as
# `ref` so the whole matrix runs against the exact commit being released
# (not the branch tip). When triggered by a PR, `ref` is empty and every
# checkout falls back to the triggering ref.
workflow_call:
inputs:
ref:
description: "Commit SHA / ref to check out. Empty = triggering ref."
required: false
type: string
default: ""
concurrency:
# Distinct group per release ref so a release-triggered run never cancels (or
# is cancelled by) a PR's CI. PR runs still coalesce per PR number.
group: ${{ github.workflow }}-${{ inputs.ref || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
rust:
name: Rust (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: cargo test
run: cargo test --workspace --all-targets
- name: cargo doc
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --workspace --no-deps
# cargo fmt and cargo clippy are intentionally not gated here yet —
# see the cleanup follow-up. Add them back once the repo is clean.
python:
name: Python (${{ matrix.os }}, ${{ matrix.python }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: py-${{ matrix.os }}-${{ matrix.python }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
# Create the venv and put its bin/Scripts dir on PATH so the
# subsequent steps work identically on Unix (.venv/bin) and
# Windows (.venv/Scripts).
- name: Create virtualenv
shell: bash
run: |
python -m venv .venv
# GITHUB_PATH entries must be native paths. In Git Bash on Windows
# $PWD is an MSYS path (/d/a/shell/shell) that the runner's Windows
# PATH cannot resolve, so the venv would be silently ignored and
# later steps would fall back to the host interpreter. Convert to a
# native Windows path with cygpath so .venv\Scripts is actually used.
if [ "$RUNNER_OS" == "Windows" ]; then
cygpath -w "$PWD/.venv/Scripts" >> "$GITHUB_PATH"
else
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
fi
- name: Install build deps
run: pip install maturin pytest
- name: Build and install wheel
run: maturin develop --release
- name: pytest
run: pytest tests/python -v
audit:
name: Security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: audit
- name: cargo install cargo-audit
run: cargo install --locked cargo-audit
- name: cargo audit
# Surfaces RustSec advisories in CI output. Not a hard gate yet —
# transitive deps via reqwest/rustls carry advisories we haven't
# triaged. Flip continue-on-error off once the dep tree is clean.
run: cargo audit
continue-on-error: true
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
- name: npm audit (production)
# package-lock.json is gitignored, so generate an ephemeral lockfile
# for the audit (npm audit requires one).
run: |
npm install --package-lock-only
npm audit --omit=dev
node:
name: Node.js (${{ matrix.os }}, Node ${{ matrix.node }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ["20", "22", "24"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: node-${{ matrix.os }}-${{ matrix.node }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
# The package.json build scripts use `$(npm run --silent host-triple)`
# command substitution. npm runs script bodies with its configured
# script-shell, which defaults to cmd.exe on Windows (no `$(...)`
# support). Point it at the Git Bash that ships on the windows-latest
# runner so the substitution works identically across platforms.
- name: Use bash as npm script-shell (Windows)
if: runner.os == 'Windows'
run: npm config set script-shell bash
- name: npm install
# package-lock.json is gitignored, so `npm ci` can't run; use install.
run: npm install
- name: napi build
run: npm run build:debug
- name: tsc typecheck (public .d.ts surface)
run: npm run typecheck
- name: npm test
run: npm test
# Single required status check. Branch protection can require just this one
# context ("CI Gate") instead of every matrix leg (Rust/Python/Node/audit),
# whose names change whenever the matrix changes. This job fails if any
# needed job failed or was cancelled, so it is a faithful aggregate gate.
gate:
name: CI Gate
if: always()
needs: [rust, python, audit, node]
runs-on: ubuntu-latest
steps:
- name: Verify all required jobs succeeded
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
echo "Needed job results: $RESULTS"
for result in $RESULTS; do
if [ "$result" != "success" ]; then
echo "::error::A required CI job did not succeed (result: $result)."
exit 1
fi
done
echo "All required CI jobs succeeded."