Skip to content

Commit ab5d0f1

Browse files
committed
Add Pyodide CI test to prevent browser breakage
- Add pyodide-test.yml workflow to test basic imports in Pyodide - Tests: SemanticLayer, Model, Dimension, Metric instantiation - Update CLAUDE.md with Pyodide compatibility requirements - Ensures core deps remain Pyodide-compatible for dashboard
1 parent 484cdb3 commit ab5d0f1

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

.claude/CLAUDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ This is NON-NEGOTIABLE. You MUST run these BEFORE every commit.
3535
- `workbench` - textual, plotext (for TUI)
3636
- `serve` - riffq, pyarrow (for PostgreSQL server)
3737

38+
## Pyodide Compatibility
39+
40+
- Core dependencies MUST be Pyodide-compatible (used in browser dashboard)
41+
- Heavy deps (textual, riffq) are optional to avoid Pyodide conflicts
42+
- CI tests basic imports in Pyodide environment
43+
- If adding new core deps, check they work in Pyodide or make them optional
44+
3845
## Testing
3946

4047
Run tests before committing significant changes:

.github/workflows/pyodide-test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Pyodide Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test-pyodide:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
19+
- name: Install Pyodide
20+
run: npm install pyodide
21+
22+
- name: Test sidemantic in Pyodide
23+
run: |
24+
cat > test_pyodide.mjs << 'EOF'
25+
import { loadPyodide } from 'pyodide';
26+
27+
async function main() {
28+
const pyodide = await loadPyodide();
29+
30+
console.log('Installing sidemantic...');
31+
await pyodide.loadPackage('micropip');
32+
await pyodide.runPythonAsync(`
33+
import micropip
34+
await micropip.install('sidemantic')
35+
`);
36+
37+
console.log('Testing basic imports...');
38+
await pyodide.runPythonAsync(`
39+
from sidemantic import SemanticLayer, Model, Dimension, Metric
40+
print('✓ Core imports successful')
41+
42+
# Test creating a simple semantic layer
43+
layer = SemanticLayer()
44+
print('✓ SemanticLayer instantiation successful')
45+
46+
# Test creating a model
47+
model = Model(
48+
name="test",
49+
table="test_table",
50+
primary_key="id",
51+
dimensions=[
52+
Dimension(name="name", type="categorical", sql="name")
53+
],
54+
metrics=[
55+
Metric(name="count", agg="count")
56+
]
57+
)
58+
layer.add_model(model)
59+
print('✓ Model creation successful')
60+
61+
print('All Pyodide tests passed!')
62+
`);
63+
}
64+
65+
main().catch(err => {
66+
console.error(err);
67+
process.exit(1);
68+
});
69+
EOF
70+
node test_pyodide.mjs

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)