forked from vlcn-io/cr-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (199 loc) · 6.79 KB
/
zig-tests.yaml
File metadata and controls
230 lines (199 loc) · 6.79 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
name: zig-tests
on:
push:
branches: [main]
paths:
- 'zig/**'
- '.github/workflows/zig-tests.yaml'
pull_request:
paths:
- 'zig/**'
- '.github/workflows/zig-tests.yaml'
jobs:
build-native:
name: Build Native (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
zig/.zig-cache
~/.cache/zig
key: zig-nix-${{ runner.os }}-${{ hashFiles('zig/build.zig', 'zig/build.zig.zon') }}
restore-keys: |
zig-nix-${{ runner.os }}-
- name: Build
working-directory: zig
run: nix run nixpkgs#zig -- build
- name: Size Report
working-directory: zig
run: |
echo "════════════════════════════════════════════════════════════════"
echo " CR-SQLite Artifact Size Report"
echo "════════════════════════════════════════════════════════════════"
echo ""
echo "CR-SQLite Zig Build Artifacts:"
for f in zig-out/lib/*; do
if [ -f "$f" ]; then
SIZE=$(stat -c%s "$f" 2>/dev/null || stat -f%z "$f" 2>/dev/null)
SIZE_MB=$(echo "scale=2; $SIZE / 1024 / 1024" | bc)
echo " $(basename $f): ${SIZE_MB} MB (${SIZE} bytes)"
fi
done
echo ""
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: crsqlite-native-${{ runner.os }}
path: zig/zig-out/lib/
retention-days: 7
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
zig/.zig-cache
~/.cache/zig
key: zig-wasm-nix-${{ hashFiles('zig/build.zig', 'zig/build.zig.zon') }}
restore-keys: |
zig-wasm-nix-
- name: Build WASM
working-directory: zig
run: nix run nixpkgs#zig -- build wasm
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: crsqlite-wasm
path: zig/zig-out/lib/*.wasm
retention-days: 7
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
zig/.zig-cache
~/.cache/zig
key: zig-nix-${{ runner.os }}-${{ hashFiles('zig/build.zig', 'zig/build.zig.zon') }}
restore-keys: |
zig-nix-${{ runner.os }}-
- name: Run unit tests
working-directory: zig
run: nix run nixpkgs#zig -- build test
test-parity:
name: Parity Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
zig/.zig-cache
~/.cache/zig
key: zig-nix-${{ runner.os }}-${{ hashFiles('zig/build.zig', 'zig/build.zig.zon') }}
restore-keys: |
zig-nix-${{ runner.os }}-
- name: Build extension
working-directory: zig
run: nix run nixpkgs#zig -- build
- name: Diagnose extension loading
working-directory: zig
run: |
echo "=== Extension file info ==="
ls -la zig-out/lib/
file zig-out/lib/libcrsqlite.so
echo ""
echo "=== SQLite version ==="
nix run nixpkgs#sqlite -- --version
echo ""
echo "=== Test extension load ==="
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT crsql_version();" 2>&1 || true
echo ""
echo "=== Test crsql_db_version ==="
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT crsql_db_version();" 2>&1 || true
echo ""
echo "=== Test crsql_site_id ==="
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT hex(crsql_site_id());" 2>&1 || true
echo ""
echo "=== Test crsql_changes insert (rows_impacted issue) ==="
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "
CREATE TABLE foo (a PRIMARY KEY NOT NULL, b);
SELECT crsql_as_crr('foo');
BEGIN;
INSERT INTO crsql_changes VALUES ('foo', X'010901', 'b', 2, 1, 1, NULL, 1, 1);
SELECT crsql_rows_impacted();
" 2>&1 || echo "ERROR: $?"
- name: Run parity tests
working-directory: zig
run: make test-parity
test-browser:
name: Browser Tests
runs-on: ubuntu-latest
needs: build-wasm
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache Zig
uses: actions/cache@v4
with:
path: |
zig/.zig-cache
~/.cache/zig
key: zig-wasm-nix-${{ hashFiles('zig/build.zig', 'zig/build.zig.zon') }}
restore-keys: |
zig-wasm-nix-
- name: Build WASM
working-directory: zig
run: nix run nixpkgs#zig -- build wasm
- name: Install dependencies
working-directory: zig/browser-test
run: npm ci
- name: Install Playwright browsers
working-directory: zig/browser-test
run: npx playwright install --with-deps chromium
- name: Run browser tests
working-directory: zig/browser-test
run: npm test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: zig/browser-test/test-results/
retention-days: 7