-
Notifications
You must be signed in to change notification settings - Fork 12
543 lines (445 loc) · 17.7 KB
/
Copy pathci.yml
File metadata and controls
543 lines (445 loc) · 17.7 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
python:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
env:
UV_PYTHON: ${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install core dependencies
run: uv sync --extra dev
- name: Check core import without DAX extra
run: |
uv run python - <<'PY'
import sys
from sidemantic import Dimension, Metric, Model
assert Model.__name__ == "Model"
assert Dimension.__name__ == "Dimension"
assert Metric.__name__ == "Metric"
assert "sidemantic_dax" not in sys.modules
PY
- name: Install DAX dependencies
run: uv sync --extra dev --extra dax
- name: Install browser test runtime
run: uv run python -m playwright install --with-deps chromium
- name: Check version consistency
run: |
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
INIT_VERSION=$(grep '^__version__ = ' sidemantic/__init__.py | sed 's/__version__ = "\(.*\)"/\1/')
if [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ]; then
echo "Version mismatch: pyproject.toml=$PYPROJECT_VERSION, __init__.py=$INIT_VERSION"
exit 1
fi
echo "Version check passed: $PYPROJECT_VERSION"
- name: Run ruff check
run: uv run ruff check . --exclude docs/_extensions --exclude sidemantic-duckdb/extension-ci-tools --exclude sidemantic-duckdb/scripts --exclude sidemantic-duckdb/duckdb --exclude sidemantic/adapters/malloy_grammar --exclude sidemantic/adapters/holistics_grammar
- name: Run ruff format check
run: uv run ruff format --check . --exclude docs/_extensions --exclude sidemantic-duckdb/extension-ci-tools --exclude sidemantic-duckdb/scripts --exclude sidemantic-duckdb/duckdb --exclude sidemantic/adapters/malloy_grammar --exclude sidemantic/adapters/holistics_grammar
- name: Check public API types
run: |
uv run mypy
uv run mypy --config-file tests/typing/mypy.ini tests/typing/package_consumer.py
- name: Check typed package marker
run: |
uv build --wheel
unzip -l dist/*.whl | grep -q 'sidemantic/py.typed'
- name: Run tests
run: uv run pytest -v --cov-fail-under=76
- name: Run installed-wheel DAX smoke
run: |
uv build crates/dax-pyo3 --out-dir /tmp/sidemantic-dax-dist
uv build --out-dir /tmp/sidemantic-dist
SIDEMANTIC_WHEEL=$(realpath "$(find /tmp/sidemantic-dist -name 'sidemantic-[0-9]*.whl' -print -quit)")
cd /tmp
uv run --no-project --find-links /tmp/sidemantic-dax-dist --with "${SIDEMANTIC_WHEEL}[dax]" -- python - <<'PY'
import sidemantic_dax
sidemantic_dax.parse_expression("1")
PY
dependency-compatibility:
name: Dependencies (${{ matrix.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: minimum direct
python-version: "3.11"
resolution: lowest-direct
- name: unlocked latest
python-version: "3.14"
resolution: highest
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Resolve ${{ matrix.name }} dependencies
run: >-
uv sync
--extra dev
--extra dax
--extra charts
--extra widget
--extra lsp
--extra workbench
--upgrade
--resolution ${{ matrix.resolution }}
- name: Exercise maintained Python surfaces
run: >-
uv run --no-sync pytest
tests/core
tests/lsp
tests/widget
tests/test_charts.py
tests/test_core_imports.py
tests/test_project.py
-q
-o addopts="-m 'not integration'"
base-install-cli:
name: Base Install CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Smoke base CLI install
run: |
set -euo pipefail
tmpdir="$(mktemp -d)"
mkdir -p "$tmpdir/models"
cat > "$tmpdir/models/models.yml" <<'YAML'
models:
- name: orders
table: orders
primary_key: id
dimensions:
- name: status
type: categorical
metrics:
- name: order_count
agg: count
YAML
uv run --no-project --with . sidemantic --version
uv run --no-project --with . sidemantic validate "$tmpdir/models"
uv run --no-project --with . sidemantic query "SELECT order_count, status FROM orders" --models "$tmpdir/models" --dry-run
set +e
timeout 10s uv run --no-project --with . sidemantic serve "$tmpdir/models" >"$tmpdir/serve.out" 2>"$tmpdir/serve.err"
serve_status=$?
set -e
if [ "$serve_status" -eq 0 ]; then
echo "base install unexpectedly ran sidemantic serve without the serve extra"
exit 1
fi
if [ "$serve_status" -eq 124 ]; then
echo "base install unexpectedly started sidemantic serve without the serve extra"
cat "$tmpdir/serve.out"
cat "$tmpdir/serve.err" >&2
exit 1
fi
grep -q "sidemantic\\[api\\]" "$tmpdir/serve.err"
update-schema:
name: Update JSON Schema
needs: python
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: uv sync --extra dev --extra dax
- name: Generate and commit schema if needed
run: |
uv run python scripts/generate_schema.py
if ! git diff --exit-code sidemantic-schema.json; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add sidemantic-schema.json
git commit -m "Auto-update JSON schema"
git push
fi
native-compat:
name: Native Compatibility
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync --extra dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: sidemantic-rs
- name: Run Python native fixtures
run: uv run pytest tests/native_compat -v
- name: Install DuckDB ADBC driver
run: |
curl -L https://github.com/duckdb/duckdb/releases/download/v1.5.3/libduckdb-linux-amd64.zip -o /tmp/libduckdb.zip
unzip -q /tmp/libduckdb.zip -d /tmp/libduckdb
echo "SIDEMANTIC_TEST_ADBC_DUCKDB_DRIVER=/tmp/libduckdb/libduckdb.so" >> "$GITHUB_ENV"
- name: Run Rust native fixtures
working-directory: sidemantic-rs
run: |
cargo test --test native_fixtures
cargo test --features adbc-exec --test native_fixtures native_fixtures_execute_expected_results_with_duckdb_adbc
check-rust-changes:
name: Check Rust/DuckDB changes
runs-on: ubuntu-latest
outputs:
rust_changed: ${{ steps.changes.outputs.rust }}
duckdb_changed: ${{ steps.changes.outputs.duckdb }}
dax_changed: ${{ steps.changes.outputs.dax }}
webapp_changed: ${{ steps.changes.outputs.webapp }}
widget_changed: ${{ steps.changes.outputs.widget }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
rust:
- 'sidemantic-rs/**'
duckdb:
- 'sidemantic-duckdb/**'
- 'sidemantic-rs/**'
dax:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'tests/dax/fixtures/**'
webapp:
- 'webapp/**'
- 'scripts/build_webapp.py'
- 'scripts/build_ui_distribution.py'
- 'sidemantic/ui/static/**'
- 'sidemantic-rs/ui/**'
- 'plugins/sidemantic/skills/webapp-builder/assets/ui-dist/**'
- 'examples/sidemantic_wasm_demo/src/components/sidemantic/**'
widget:
- 'js/**'
- 'scripts/build_widget.py'
- 'sidemantic/widget/static/**'
- 'plugins/sidemantic/skills/webapp-builder/assets/ui-dist/**'
dax-rust:
name: Rust (DAX crates)
needs: check-rust-changes
if: needs.check-rust-changes.outputs.dax_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: .
- name: Run cargo fmt check
run: cargo fmt --check
- name: Run cargo clippy
run: cargo clippy -p dax-parser -p dax-pyo3 --all-targets -- -D warnings
- name: Run cargo test
run: cargo test -p dax-parser -p dax-pyo3
rust:
name: Rust (sidemantic-rs)
needs: check-rust-changes
if: needs.check-rust-changes.outputs.rust_changed == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: sidemantic-rs
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: sidemantic-rs
- name: Run cargo fmt check
run: cargo fmt --check
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo test
run: cargo test
env:
RUST_MIN_STACK: 16777216
- name: Check package metadata
run: cargo test --test package_metadata
- name: Check crate package dry run
run: cargo package --locked --no-verify
- name: Check standalone feature surfaces
run: |
cargo check --no-default-features --all-targets
cargo check --features python --lib
cargo check --features python-adbc --lib
cargo check --features mcp-server --bin sidemantic-mcp --test mcp_protocol
cargo check --features mcp-adbc --bin sidemantic-mcp
cargo check --features runtime-server --bin sidemantic-server --test http_server
cargo check --features runtime-server-adbc --bin sidemantic-server
cargo check --features runtime-lsp --bin sidemantic-lsp --test lsp_protocol_smoke
cargo check --features workbench-tui --bin sidemantic --bin sidemantic-workbench
cargo check --features workbench-adbc --bin sidemantic --bin sidemantic-workbench
- name: Install DuckDB ADBC driver
run: |
curl -L https://github.com/duckdb/duckdb/releases/download/v1.5.3/libduckdb-linux-amd64.zip -o /tmp/libduckdb.zip
unzip -q /tmp/libduckdb.zip -d /tmp/libduckdb
echo "SIDEMANTIC_TEST_ADBC_DUCKDB_DRIVER=/tmp/libduckdb/libduckdb.so" >> "$GITHUB_ENV"
- name: Install SQLite ADBC driver
run: |
uv run --no-project --with adbc-driver-sqlite python - <<'PY' >> "$GITHUB_ENV"
import adbc_driver_sqlite
print(f"SIDEMANTIC_TEST_ADBC_SQLITE_DRIVER={adbc_driver_sqlite._driver_path()}")
print("SIDEMANTIC_TEST_ADBC_SQLITE_URI=:memory:")
print("SIDEMANTIC_TEST_ADBC_REQUIRE=duckdb,sqlite")
PY
- name: Run standalone protocol and UI tests
run: |
cargo test --features mcp-server --test mcp_protocol
cargo test --features runtime-server --test http_server
cargo test --features runtime-lsp --test lsp_protocol_smoke
cargo test --features workbench-tui --test cli_smoke workbench
cargo test --features workbench-adbc --test cli_smoke workbench
cargo test --features workbench-tui --test workbench_pty_smoke
cargo test --features workbench-adbc --test workbench_pty_smoke
cargo test --features workbench-adbc --bin sidemantic
cargo test --features adbc-exec --test adbc_driver_matrix
cargo test --features mcp-adbc,runtime-server-adbc --test adbc_duckdb_e2e
- name: Smoke C ABI header and static library
run: |
cargo build --release --lib
SIDEMANTIC_STATICLIB="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')/release/libsidemantic.a"
cc -std=c11 -Wall -Wextra -I include tests/c_abi_smoke.c "$SIDEMANTIC_STATICLIB" -lpthread -ldl -lm -lrt -o /tmp/sidemantic_c_abi_smoke
/tmp/sidemantic_c_abi_smoke
- name: Check WASM build
run: cargo check --no-default-features --features wasm --target wasm32-unknown-unknown --lib
- name: Install wasm-bindgen test runner
run: |
WASM_BINDGEN_VERSION="$(cargo metadata --format-version 1 | python3 -c 'import json, sys; print(next(pkg["version"] for pkg in json.load(sys.stdin)["packages"] if pkg["name"] == "wasm-bindgen"))')"
cargo install wasm-bindgen-cli --version "$WASM_BINDGEN_VERSION"
- name: Run WASM runtime tests
run: CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test --target wasm32-unknown-unknown --features wasm --test wasm_bindgen_runtime
- name: Check Python extension build
run: uvx maturin build --out dist
- name: Smoke Python extension wheel
run: uv run --no-project --with dist/*.whl tests/python_wheel_smoke.py
- name: Check lightweight Python extension build
run: uvx maturin build --no-default-features --features python --out dist-python
- name: Smoke lightweight Python extension wheel
run: uv run --no-project --with dist-python/*.whl tests/python_wheel_python_smoke.py
- name: Check Python extension ADBC build
run: uvx maturin build --no-default-features --features python-adbc --out dist-adbc
- name: Smoke Python extension ADBC wheel
run: uv run --no-project --with dist-adbc/*.whl tests/python_wheel_adbc_smoke.py
duckdb-extension:
name: DuckDB Extension
needs: check-rust-changes
if: needs.check-rust-changes.outputs.duckdb_changed == 'true'
runs-on: ubuntu-latest
env:
GEN: ninja
steps:
- uses: actions/checkout@v4
- name: Fetch DuckDB dependencies
working-directory: sidemantic-duckdb
run: make deps DUCKDB_VERSION=v1.5.3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: sidemantic-rs
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y ninja-build
- name: Build DuckDB extension
working-directory: sidemantic-duckdb
run: make
- name: Run extension tests
working-directory: sidemantic-duckdb
run: make test
webapp:
name: Webapp (types + unit)
needs: check-rust-changes
if: needs.check-rust-changes.outputs.webapp_changed == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: webapp
steps:
- uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Typecheck
run: bun run typecheck
- name: Unit tests
run: bun test src
- name: Check committed bundles
run: |
python ../scripts/build_webapp.py --check
python ../scripts/build_ui_distribution.py --check
widget:
name: AnyWidget bundle
needs: check-rust-changes
if: needs.check-rust-changes.outputs.widget_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
working-directory: js
run: bun install --frozen-lockfile
- name: Check committed bundle
run: python scripts/build_widget.py --check