-
Notifications
You must be signed in to change notification settings - Fork 11
173 lines (141 loc) · 5.18 KB
/
ci.yml
File metadata and controls
173 lines (141 loc) · 5.18 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
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
python:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- 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 dependencies
run: uv sync --extra dev
- 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: Run tests
run: uv run pytest -v --cov=sidemantic --cov-report=term-missing
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 dependencies
run: uv sync --extra dev
- 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
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 }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
rust:
- 'sidemantic-rs/**'
duckdb:
- 'sidemantic-duckdb/**'
- 'sidemantic-rs/**'
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
- 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 -- -D warnings
- name: Run cargo test
run: cargo test
env:
RUST_MIN_STACK: 16777216
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: Clone DuckDB dependencies
working-directory: sidemantic-duckdb
run: |
# These are listed as submodules in .gitmodules but aren't tracked properly
# Clone them directly at the commits the extension was built against
rm -rf duckdb extension-ci-tools
git clone --depth 1 --branch v1.4.2 https://github.com/duckdb/duckdb.git duckdb
git clone --depth 1 --branch v1.4.2 https://github.com/duckdb/extension-ci-tools.git extension-ci-tools
- 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 Rust library
working-directory: sidemantic-rs
run: cargo build --release
- name: Build DuckDB extension
working-directory: sidemantic-duckdb
run: make
- name: Run extension tests
working-directory: sidemantic-duckdb
run: make test