Skip to content

Commit c37c609

Browse files
committed
Add PHPUnit (Doltlite) workflow
Build Doltlite from source and run the mysql-on-sqlite PHPUnit suite against it via LD_PRELOAD, so PHP's PDO SQLite transparently uses the Doltlite engine. See: https://github.com/timsehn/doltlite
1 parent 104a872 commit c37c609

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: PHPUnit Tests (Doltlite)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: PHP ${{ matrix.php }} / Doltlite
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
php: [ '8.3' ]
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install Doltlite build dependencies
26+
run: sudo apt-get update && sudo apt-get install -y build-essential zlib1g-dev tcl-dev
27+
28+
- name: Check out Doltlite
29+
uses: actions/checkout@v4
30+
with:
31+
repository: timsehn/doltlite
32+
path: doltlite-src
33+
34+
- name: Build Doltlite shared library
35+
run: |
36+
mkdir -p build
37+
cd build
38+
../configure
39+
make -j"$(nproc)" doltlite-lib
40+
ls -la libdoltlite* sqlite3.h
41+
working-directory: doltlite-src
42+
43+
- name: Set up PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: '${{ matrix.php }}'
47+
tools: phpunit-polyfills
48+
49+
- name: Verify Doltlite is wired up via LD_PRELOAD
50+
env:
51+
LD_PRELOAD: ${{ github.workspace }}/doltlite-src/build/libdoltlite.so
52+
run: |
53+
echo "ldd pdo_sqlite:"
54+
ldd "$(php -r 'echo ini_get("extension_dir");')/pdo_sqlite.so" || true
55+
echo
56+
php -r '$v = (new PDO("sqlite::memory:"))->query("SELECT SQLITE_VERSION()")->fetch()[0]; echo "SQLITE_VERSION() = $v\n";'
57+
echo "If Doltlite is active, the engine() check below should print 'prolly':"
58+
php -r '$r = (new PDO("sqlite::memory:"))->query("SELECT doltlite_engine()")->fetch(); var_dump($r);' || true
59+
60+
- name: Install Composer dependencies (root)
61+
uses: ramsey/composer-install@v3
62+
with:
63+
ignore-cache: "yes"
64+
composer-options: "--optimize-autoloader"
65+
66+
- name: Install Composer dependencies (mysql-on-sqlite)
67+
uses: ramsey/composer-install@v3
68+
with:
69+
working-directory: packages/mysql-on-sqlite
70+
ignore-cache: "yes"
71+
composer-options: "--optimize-autoloader"
72+
73+
- name: Run PHPUnit tests against Doltlite
74+
env:
75+
LD_PRELOAD: ${{ github.workspace }}/doltlite-src/build/libdoltlite.so
76+
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
77+
working-directory: packages/mysql-on-sqlite

0 commit comments

Comments
 (0)