Skip to content

it

it #48

Workflow file for this run

name: zig-tests
# CI Strategy (TASK-207, TASK-214):
#
# Required jobs (must pass for release):
# - build-native: Build Zig extension on Linux + macOS
# - build-wasm: Build WASM target
# - test-unit: Zig unit tests
# - test-browser: Playwright browser tests
#
# Optional jobs (informational, allowed to fail):
# - test-parity-oracle: Oracle parity tests (require Rust/C binaries)
#
# Oracle binaries are checked into lib/ and available in CI.
on:
push:
branches: [main]
paths:
- 'zig/**'
- 'lib/**'
- '.github/workflows/zig-tests.yaml'
pull_request:
paths:
- 'zig/**'
- 'lib/**'
- '.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
# ═══════════════════════════════════════════════════════════════════════════
# Zig-Only Parity Tests (Required for Release)
# Tests that run against the Zig extension alone, no oracle needed.
# ═══════════════════════════════════════════════════════════════════════════
test-parity-zig-only:
name: Parity Tests (Zig-only)
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: Smoke test 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 "=== Smoke tests ==="
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT crsql_version();"
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT crsql_db_version();"
nix run nixpkgs#sqlite -- :memory: -cmd ".load zig-out/lib/libcrsqlite.so" "SELECT hex(crsql_site_id());"
- name: Run Zig-only parity tests
working-directory: zig
run: |
# Run tests that don't require the oracle
# These validate Zig extension behavior independently
cd harness
for test in \
test-alter.sh \
test-automigrate.sh \
test-backfill.sh \
test-clock-edge-cases.sh \
test-clset-vtab.sh \
test-crsqlite.sh \
test-e2e-sync.sh \
test-filters.sh \
test-fract.sh \
test-is-crr.sh \
test-large-data.sh \
test-merge-atomicity.sh \
test-noops.sh \
test-persistence.sh \
test-pk-update.sh \
test-realistic-collab.sh \
test-realistic-offline.sh \
test-realistic-sync.sh \
test-rowid-slab.sh \
test-sync-bit-isolation.sh \
test-table-compat.sh \
test-unpack-columns-vtab.sh \
test-wal-concurrency.sh \
; do
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Running: $test"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if bash "$test"; then
echo "✓ $test PASSED"
else
EXIT_CODE=$?
if [ $EXIT_CODE -eq 2 ]; then
echo "⚠ $test SKIPPED (functions not implemented)"
else
echo "✗ $test FAILED (exit $EXIT_CODE)"
exit 1
fi
fi
echo ""
done
echo "All Zig-only parity tests passed!"
# ═══════════════════════════════════════════════════════════════════════════
# Oracle Parity Tests (Optional - Informational)
# Tests that compare Zig vs Rust/C oracle. Allowed to fail if oracle unavailable.
# ═══════════════════════════════════════════════════════════════════════════
test-parity-oracle:
name: Parity Tests (Oracle)
runs-on: ubuntu-latest
continue-on-error: true # Oracle tests are informational, not release-blocking
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: Check oracle availability
id: oracle-check
run: |
if [ -f "lib/crsqlite-linux-x86_64.so" ]; then
echo "Oracle binary found: lib/crsqlite-linux-x86_64.so"
echo "available=true" >> $GITHUB_OUTPUT
else
echo "Oracle binary NOT found"
echo "available=false" >> $GITHUB_OUTPUT
fi
- name: Run oracle parity tests
if: steps.oracle-check.outputs.available == 'true'
working-directory: zig
run: |
# Run full parity test suite (handles oracle availability internally)
# test-parity.sh checks for oracle via has_oracle() and skips tests gracefully
make test-parity || true # continue-on-error at job level handles overall status
- name: Oracle unavailable notice
if: steps.oracle-check.outputs.available != 'true'
run: |
echo "⚠ Oracle parity tests skipped - Rust/C binary not available in CI"
echo "To add oracle: commit lib/crsqlite-linux-x86_64.so to repository"
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
# ═══════════════════════════════════════════════════════════════════════════
# Release Gate (Required for 0.16.300-preview)
# All required jobs must pass for release.
# Oracle parity tests are excluded from gate (informational only).
# ═══════════════════════════════════════════════════════════════════════════
release-gate:
name: Release Gate
runs-on: ubuntu-latest
needs:
- build-native
- build-wasm
- test-unit
- test-parity-zig-only
- test-browser
# Note: test-parity-oracle is NOT in needs - it's optional
steps:
- name: All required checks passed
run: |
echo "╔═══════════════════════════════════════════════════════════════════╗"
echo "║ Release Gate - All Required Checks Passed ║"
echo "╠═══════════════════════════════════════════════════════════════════╣"
echo "║ ✓ build-native (Linux + macOS) ║"
echo "║ ✓ build-wasm ║"
echo "║ ✓ test-unit ║"
echo "║ ✓ test-parity-zig-only ║"
echo "║ ✓ test-browser ║"
echo "╠═══════════════════════════════════════════════════════════════════╣"
echo "║ Ready for 0.16.300-preview release ║"
echo "╚═══════════════════════════════════════════════════════════════════╝"