name: SQL Tests on: workflow_dispatch: push: branches: ["main"] pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true env: CARGO_TERM_COLOR: always # With CI set, the Makefiles build tursodb, tursopg and the test runner # with --release, which uses thin LTO. These are test tools, not shipped # binaries: they stay optimized without LTO and build faster. Set for the # whole workflow so the later `cargo run --release` reuses the same build. CARGO_PROFILE_RELEASE_LTO: "false" CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16" jobs: sqltest-check: name: Check .sqltest syntax runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build test runner run: make -C sqlite/conformance build-runner - name: Check test syntax run: make -C sqlite/conformance check - name: Check pg test syntax run: make -C postgres/conformance check sqltest-cli: name: Run SQL tests (CLI backend) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - uses: "./.github/shared/install_sqlite" - name: Build tursodb run: make -C sqlite/conformance build-tursodb - name: Build test runner run: make -C sqlite/conformance build-runner - name: Run tests run: make -C sqlite/conformance run-cli CROSS_CHECK_BINARY=sqlite3 - name: Run tests (MVCC) run: make -C sqlite/conformance run-cli MVCC=1 sqltest-rust: name: Run SQL tests (Rust backend) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build test runner run: make -C sqlite/conformance build-runner - name: Run tests run: make -C sqlite/conformance run-rust - name: Run tests (MVCC) run: make -C sqlite/conformance run-rust MVCC=1 sqltest-js: name: Run SQL tests (JS backend, ${{ matrix.mode }}) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 # The normal and MVCC passes run on separate machines at the same time. strategy: fail-fast: false matrix: mode: [default, mvcc] # napi-build uses the release-official profile (full LTO, one codegen # unit) meant for published packages. These tests only need a working # binding, so turn off LTO to build it faster. env: CARGO_PROFILE_RELEASE_OFFICIAL_LTO: "false" CARGO_PROFILE_RELEASE_OFFICIAL_CODEGEN_UNITS: "16" defaults: run: working-directory: bindings/javascript steps: - uses: actions/checkout@v4 # Both modes build the same things and share this key; one saves. - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' && matrix.mode == 'default' }} - name: Setup node uses: useblacksmith/setup-node@v5 with: node-version: 24 # `make run-js` installs the JS dependencies and builds the common # package, the native binding (with the test_helper feature the tests # need) and the TypeScript, so this job has no separate build steps. - name: Build test runner working-directory: sqlite/conformance run: make build-runner - name: Run tests if: matrix.mode == 'default' working-directory: sqlite/conformance run: make run-js - name: Run tests (MVCC) if: matrix.mode == 'mvcc' working-directory: sqlite/conformance run: make run-js MVCC=1 sqltest-tursopg: name: Run SQL tests (tursopg backend) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 with: # The gap-removal check compares the checkout with its first parent, # which for a pull request is the target branch (the checkout is the # merge commit). fetch-depth: 2 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build tursopg run: make -C postgres/conformance build-tursopg - name: Build test runner run: make -C postgres/conformance build-runner - name: Run tests run: make -C postgres/conformance run - name: Run tests (turso_pg embedded, without the pgwire server) run: make -C postgres/conformance run-embedded - name: Write gap-test counts to the job summary if: ${{ !cancelled() && github.event_name == 'pull_request' }} run: make -s --no-print-directory -C postgres/conformance gaps >> "$GITHUB_STEP_SUMMARY" - name: Check that no gap test was removed if: ${{ !cancelled() && github.event_name == 'pull_request' }} run: | git worktree add --detach "$RUNNER_TEMP/gap-base" HEAD^1 make -C postgres/conformance check-gap-removals BASE="$RUNNER_TEMP/gap-base" sqltest-postgres: name: Run SQL tests (PostgreSQL) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build test runner run: make -C postgres/conformance build-runner - name: Run tests against PostgreSQL run: make -C postgres/conformance run-postgres # The SQLSTATE differential fuzzer still reports divergences that need # expression types the engine does not track — operator and function # overload resolution, unknown-literal typing, int4 arithmetic # overflow — so it runs manually, not in CI: # make -C postgres/conformance run-sqlstate-fuzzer # - name: Run SQLSTATE differential fuzzer # run: make -C postgres/conformance run-sqlstate-fuzzer pg-dump-fuzzer: name: PostgreSQL dump differential fuzzer runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@1.88 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Install PostgreSQL clients run: | pg_version=$(cat postgres/version) sudo install -d /usr/share/postgresql-common/pgdg sudo curl --fail --silent --show-error --location \ https://www.postgresql.org/media/keys/ACCC4CF8.asc \ -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt noble-pgdg main' | sudo tee /etc/apt/sources.list.d/pgdg.list sudo apt-get update sudo apt-get install -y "postgresql-client-$pg_version" echo "/usr/lib/postgresql/$pg_version/bin" >> "$GITHUB_PATH" - name: Check fuzzer and comparison logic run: cargo test --locked --profile pg-dump-fuzzer -p turso_pg_dump_fuzzer - name: Compare generated PostgreSQL and Turso dumps run: make -C postgres/conformance fuzz-pgdump FUZZ_ARGS='--cases 100 --fail-fast' - name: Upload generation report and failure artifacts if: always() uses: actions/upload-artifact@v4 with: name: pg-dump-fuzzer-results path: postgres/conformance/pgdump/results/ if-no-files-found: ignore retention-days: 1 sqltest-sqlite: name: Run SQL tests (SQLite) runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: useblacksmith/rust-cache@v3 with: prefix-key: "v1-rust" save-if: ${{ github.ref == 'refs/heads/main' }} - uses: "./.github/shared/install_sqlite" - name: Build test runner run: make -C sqlite/conformance build-runner - name: Run tests against SQLite run: make -C sqlite/conformance test-sqlite