++ #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: 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 |