Skip to content

Commit b375d21

Browse files
committed
Add PHPUnit tests workflow for Turso DB
Adds a CI job that runs the SQLite driver unit tests against Turso DB (https://github.com/tursodatabase/turso), a Rust reimplementation of SQLite. The workflow builds the turso_sqlite3 crate as a cdylib and preloads it via LD_PRELOAD so PHP's pdo_sqlite resolves its sqlite3_* symbols against Turso instead of the system libsqlite3. The job is informational: Turso is in beta with a partially implemented SQLite C API, so failing tests are expected. Refs: #204
1 parent 104a872 commit b375d21

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: PHPUnit Tests (Turso DB)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
# The test suite is run against Turso DB (https://github.com/tursodatabase/turso),
10+
# a Rust reimplementation of SQLite. Turso is still in beta and its SQLite C API
11+
# is only partially implemented; failing tests are expected and the job is purely
12+
# informational. It tracks compatibility progress over time.
13+
jobs:
14+
test:
15+
name: PHP 8.5 / Turso DB (latest)
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
26+
- name: Determine latest Turso release
27+
id: turso
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
run: |
31+
TAG=$(gh release view --repo tursodatabase/turso --json tagName --jq .tagName)
32+
echo "Using Turso release: $TAG"
33+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
34+
35+
- name: Cache Turso build
36+
uses: actions/cache@v4
37+
with:
38+
path: |
39+
~/.cargo/registry
40+
~/.cargo/git
41+
turso/target
42+
key: turso-${{ runner.os }}-${{ steps.turso.outputs.tag }}
43+
44+
- name: Clone Turso source
45+
run: git clone --depth 1 --branch '${{ steps.turso.outputs.tag }}' https://github.com/tursodatabase/turso.git
46+
47+
- name: Build turso_sqlite3 shared library
48+
working-directory: turso
49+
run: cargo build --release -p turso_sqlite3
50+
51+
- name: Verify Turso shared library exposes SQLite3 C API
52+
id: turso-lib
53+
run: |
54+
LIB="$GITHUB_WORKSPACE/turso/target/release/libturso_sqlite3.so"
55+
test -f "$LIB"
56+
echo "Library: $LIB"
57+
echo "path=$LIB" >> "$GITHUB_OUTPUT"
58+
echo '--- Sample of exported sqlite3_* symbols ---'
59+
nm -D --defined-only "$LIB" | awk '$3 ~ /^sqlite3_/ {print $3}' | sort | head -20
60+
61+
- name: Set up PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: '8.5'
65+
tools: phpunit-polyfills
66+
67+
- name: Report SQLite version via Turso preload
68+
env:
69+
LD_PRELOAD: ${{ steps.turso-lib.outputs.path }}
70+
run: |
71+
php -r "echo 'Turso sqlite_version(): ' . (new PDO('sqlite::memory:'))->query('SELECT sqlite_version()')->fetch()[0] . PHP_EOL;"
72+
73+
- name: Install Composer dependencies (root)
74+
uses: ramsey/composer-install@v3
75+
with:
76+
ignore-cache: "yes"
77+
composer-options: "--optimize-autoloader"
78+
79+
- name: Install Composer dependencies (mysql-on-sqlite)
80+
uses: ramsey/composer-install@v3
81+
with:
82+
working-directory: packages/mysql-on-sqlite
83+
ignore-cache: "yes"
84+
composer-options: "--optimize-autoloader"
85+
86+
- name: Run PHPUnit tests against Turso DB
87+
continue-on-error: true
88+
env:
89+
LD_PRELOAD: ${{ steps.turso-lib.outputs.path }}
90+
working-directory: packages/mysql-on-sqlite
91+
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist

0 commit comments

Comments
 (0)