-
Notifications
You must be signed in to change notification settings - Fork 0
298 lines (258 loc) · 8.71 KB
/
ci.yml
File metadata and controls
298 lines (258 loc) · 8.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
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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect changed paths
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
python: ${{ steps.filter.outputs.python }}
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Filter paths
id: filter
uses: dorny/paths-filter@v4
with:
filters: |
rust:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '.github/workflows/ci.yml'
python:
- 'py_src/**'
- 'tests/**'
- 'pyproject.toml'
- 'uv.lock'
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
lint:
name: Lint & Static Analysis
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
# Skip caching ~/.cargo/bin/ — rustup 1.28's multicall binary
# interacts badly with this action's cache-clean step and ends up
# restoring a `cargo` that responds as `rustup-init`. Proxies are
# reinstalled on every run by dtolnay/rust-toolchain.
# See: https://github.com/Swatinem/rust-cache/issues/16
cache-bin: false
# Bump to evict any v0-* caches that already contain the corrupted bin dir.
prefix-key: v1-rust-bin-fix
- name: Check Rust formatting
run: cargo fmt --all --check
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.10.12"
cache-dependency-glob: pyproject.toml
- name: Install Python dependencies
run: uv sync --extra dev --extra oauth
- name: Lint Python with Ruff
run: uv run ruff check py_src/ tests/
- name: Check Python formatting with Ruff
run: uv run ruff format --check py_src/ tests/
- name: Type-check Python with mypy
run: uv run mypy py_src/taskito/ tests/ --no-incremental
rust-test:
name: Rust Tests (SQLite)
needs: changes
if: needs.changes.outputs.rust == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
cache-bin: false
prefix-key: v1-rust-bin-fix
- name: Run Rust test suite
run: cargo test --workspace
env:
LD_LIBRARY_PATH: ${{ env.pythonLocation }}/lib
- name: Check build with native-async features
run: cargo check --workspace --features native-async
rust-test-postgres:
name: Rust Tests (PostgreSQL)
needs: changes
if: needs.changes.outputs.rust == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test
POSTGRES_DB: taskito_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
cache-bin: false
prefix-key: v1-rust-bin-fix
- name: Run Rust test suite (PostgreSQL backend)
run: cargo test --workspace --features postgres
env:
LD_LIBRARY_PATH: ${{ env.pythonLocation }}/lib
TASKITO_POSTGRES_TEST_URL: postgres://postgres:test@localhost:5432/taskito_test
rust-test-redis:
name: Rust Tests (Redis)
needs: changes
if: needs.changes.outputs.rust == 'true' || github.event_name == 'push'
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
save-if: false
cache-bin: false
prefix-key: v1-rust-bin-fix
- name: Run Rust test suite (Redis backend)
run: cargo test --workspace --features redis
env:
LD_LIBRARY_PATH: ${{ env.pythonLocation }}/lib
TASKITO_REDIS_TEST_URL: redis://localhost:6379/15
test:
name: Python Tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
needs: [lint, changes]
if: needs.changes.outputs.python == 'true' || github.event_name == 'push'
runs-on: ${{ matrix.os }}
env:
# setup-python on macOS upgrades certifi via pip; pip's HTTP cache
# occasionally fails to deserialize across runner image versions and
# surfaces as a noisy "Cache entry deserialization failed" annotation.
# Disabling pip's cache eliminates the warning at zero cost (we use uv
# for actual package installs).
PIP_NO_CACHE_DIR: "1"
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: "3.13"
- os: macos-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.13"
- os: windows-latest
python-version: "3.10"
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ matrix.os != 'ubuntu-latest' }}
cache-bin: false
prefix-key: v1-rust-bin-fix
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.10.12"
cache-dependency-glob: pyproject.toml
- name: Install Python dependencies
run: uv sync --extra dev --extra oauth
- name: Build native extension with maturin
uses: PyO3/maturin-action@v1
with:
command: develop
args: --release --features extension-module,postgres,redis,native-async,workflows
- name: Run Python test suite
# The pytest_unconfigure hook in tests/conftest.py calls
# ``os._exit(0)`` on a clean run to bypass CPython finalization and
# avoid the PyO3 daemon-thread SIGABRT we used to paper over here.
run: uv run python -m pytest tests/ -v --junitxml=test-results.xml
ci-status:
name: CI status
if: always()
needs: [lint, rust-test, rust-test-postgres, rust-test-redis, test]
runs-on: ubuntu-latest
steps:
- name: Check that no required job failed
run: |
results='${{ toJson(needs) }}'
echo "$results"
fail=$(echo "$results" | python3 -c "
import json, sys
data = json.load(sys.stdin)
bad = [k for k, v in data.items() if v['result'] not in ('success', 'skipped')]
print(','.join(bad))
")
if [ -n "$fail" ]; then
echo "::error::Failing or cancelled jobs: $fail"
exit 1
fi