-
Notifications
You must be signed in to change notification settings - Fork 35
300 lines (287 loc) Β· 10.4 KB
/
Copy pathci.yml
File metadata and controls
300 lines (287 loc) Β· 10.4 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
merge_group:
types: [checks_requested]
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: "--cfg=ci_run"
MIRIFLAGS: '-Zmiri-permissive-provenance'
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CLIPPY_FLAGS: "-D warnings -A clippy::needless-range-loop -A clippy::uninlined-format-args"
# Supported python version range
PYTHON_MIN_VERSION: 3.9
PYTHON_MAX_VERSION: 3.13
jobs:
# Computes if changes where made to each group of files, so we can run only the necessary checks.
#
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
changes:
name: Compute file changes
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
#
# Always returns true if running on the default branch, to ensure all changes are thoroughly checked.
outputs:
quizx: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.quizx }}
pybindings: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.pybindings }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
quizx:
- .github/workflows/ci.yml
- 'quizx/**'
- 'circuits/**'
- 'Cargo.toml'
pybindings:
- .github/workflows/ci.yml
- 'quizx/**'
- 'pybindings/**'
- 'Cargo.toml'
- 'pyproject.toml'
# Rust formatting check
rust-fmt:
name: π¦ Rust formatting
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' || needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Check rust formatting (workspace)
run: cargo fmt --all -- --check
# Rust clippy check
rust-clippy:
name: π¦ Rust clippy
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' || needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Run clippy (workspace)
run: cargo clippy --workspace --all-targets --all-features -- ${{ env.CLIPPY_FLAGS }}
# Rust documentation for quizx
rust-doc-quizx:
name: π¦ Rust documentation (quizx)
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Build docs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-Dwarnings"
# Python type checking with mypy
python-mypy:
name: π Python type checking
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install the project libraries
run: uv sync --frozen
- name: Type check python with mypy
run: uv run mypy pybindings
# Python formatting with ruff
python-ruff-format:
name: π Python formatting
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install the project libraries
run: uv sync --frozen
- name: Check python formatting with ruff
run: uv run ruff format --check
# Python linting with ruff
python-ruff-lint:
name: π Python linting
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install the project libraries
run: uv sync --frozen
- name: Lint python with ruff
run: uv run ruff check
test-quizx-stable:
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' }}
runs-on: ubuntu-latest
name: π¦ Test quizx (Rust stable)
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 'stable'
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- name: Build QuiZX binary with no features
run: cargo build --verbose --workspace --no-default-features --bin quizx
- name: Build with no features
run: cargo test --verbose --workspace --no-default-features --no-run -p quizx
- name: Tests with no features
run: cargo test --verbose --workspace --no-default-features -p quizx
test-quizx-other:
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
rust: ['1.81', beta, nightly]
name: π¦ Test quizx (Rust ${{ matrix.rust }})
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Build QuiZX binary with all features
run: cargo build --verbose --all-features --bin quizx
- name: Build with all features
run: cargo test --verbose --all-features --no-run -p quizx
- name: Tests with all features
run: cargo test --verbose --all-features -p quizx
test-pybindings:
name: π Build and Test quizx_pybindings
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install poetry
run: pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Build pyo3 bindings for minimum supported python version
run: uv run --python ${{ env.PYTHON_MIN_VERSION }} maturin develop
- name: Test pyo3 bindings for minimum supported python version
run: uv run --python ${{ env.PYTHON_MIN_VERSION }} pytest
- name: Build pyo3 bindings for latest supported python version
run: uv run --python ${{ env.PYTHON_MAX_VERSION }} maturin develop
- name: Test pyo3 bindings for latest supported python version
run: uv run --python ${{ env.PYTHON_MAX_VERSION }} pytest
# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
required-checks:
name: Required checks π
needs: [changes, rust-fmt, rust-clippy, rust-doc-quizx, python-mypy, python-ruff-format, python-ruff-lint, test-quizx-stable, test-pybindings]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
# This condition should simply be `if: failure() || cancelled()`,
# but there seems to be a bug in the github workflow runner.
#
# See https://github.com/orgs/community/discussions/80788
if: |
needs.changes.result == 'failure' || needs.changes.result == 'cancelled' ||
needs.rust-fmt.result == 'failure' || needs.rust-fmt.result == 'cancelled' ||
needs.rust-clippy.result == 'failure' || needs.rust-clippy.result == 'cancelled' ||
needs.rust-doc-quizx.result == 'failure' || needs.rust-doc-quizx.result == 'cancelled' ||
needs.python-mypy.result == 'failure' || needs.python-mypy.result == 'cancelled' ||
needs.python-ruff-format.result == 'failure' || needs.python-ruff-format.result == 'cancelled' ||
needs.python-ruff-lint.result == 'failure' || needs.python-ruff-lint.result == 'cancelled' ||
needs.test-quizx-stable.result == 'failure' || needs.test-quizx-stable.result == 'cancelled' ||
needs.test-pybindings.result == 'failure' || needs.test-pybindings.result == 'cancelled'
run: |
echo "Required checks failed"
echo "Please check the logs for more information"
exit 1
- name: Pass if required checks passed
run: |
echo "All required checks passed"