Skip to content

Commit 13f131b

Browse files
committed
Run SQLite integration matrix in parser extension CI
1 parent e6d5b2c commit 13f131b

2 files changed

Lines changed: 105 additions & 5 deletions

File tree

.github/workflows/mysql-parser-extension-tests.yml

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,120 @@ concurrency:
2121

2222
jobs:
2323
extension-tests:
24-
name: PHP ${{ matrix.php }} / Rust extension / ubuntu-latest
24+
name: PHP ${{ matrix.php }} / ${{ matrix.coverage }} / ubuntu-latest
2525
runs-on: ubuntu-latest
26-
timeout-minutes: 20
26+
timeout-minutes: 30
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ]
30+
include:
31+
- php: '7.2'
32+
sqlite: '3.27.0'
33+
native: false
34+
coverage: SQLite integration
35+
- php: '7.3'
36+
sqlite: '3.31.1'
37+
native: false
38+
coverage: SQLite integration
39+
- php: '7.4'
40+
sqlite: '3.34.1'
41+
native: false
42+
coverage: SQLite integration
43+
- php: '8.0'
44+
sqlite: '3.37.0'
45+
native: true
46+
coverage: SQLite integration + Rust extension
47+
- php: '8.1'
48+
sqlite: '3.40.1'
49+
native: true
50+
coverage: SQLite integration + Rust extension
51+
- php: '8.2'
52+
sqlite: '3.45.1'
53+
native: true
54+
coverage: SQLite integration + Rust extension
55+
- php: '8.3'
56+
sqlite: '3.46.1'
57+
native: true
58+
coverage: SQLite integration + Rust extension
59+
- php: '8.4'
60+
sqlite: '3.51.2'
61+
native: true
62+
coverage: SQLite integration + Rust extension
63+
- php: '8.5'
64+
sqlite: latest
65+
native: true
66+
coverage: SQLite integration + Rust extension
3167

3268
steps:
3369
- name: Checkout repository
3470
uses: actions/checkout@v4
3571

72+
- name: Set up SQLite
73+
run: |
74+
VERSION='${{ matrix.sqlite }}'
75+
if [ "$VERSION" = 'latest' ]; then
76+
TAG='release'
77+
else
78+
TAG="version-${VERSION}"
79+
fi
80+
SQLITE_SOURCE="https://sqlite.org/src/tarball/sqlite.tar.gz?r=${TAG}"
81+
SQLITE_MIRROR="https://github.com/sqlite/sqlite/archive/refs/tags/${TAG}.tar.gz"
82+
DOWNLOADED=0
83+
for url in "$SQLITE_SOURCE" "$SQLITE_MIRROR"; do
84+
for attempt in 1 2 3 4 5; do
85+
if wget -O sqlite.tar.gz "$url"; then
86+
DOWNLOADED=1
87+
break 2
88+
fi
89+
if [ "$attempt" -lt 5 ]; then
90+
sleep $(( attempt * 10 ))
91+
fi
92+
done
93+
done
94+
if [ "$DOWNLOADED" -ne 1 ]; then
95+
exit 1
96+
fi
97+
tar xzf sqlite.tar.gz
98+
if [ ! -d sqlite ]; then
99+
SQLITE_DIR=$(find . -maxdepth 1 -type d -name 'sqlite-*' | head -n 1)
100+
if [ -z "$SQLITE_DIR" ]; then
101+
exit 1
102+
fi
103+
mv "$SQLITE_DIR" sqlite
104+
fi
105+
cd sqlite
106+
./configure --prefix=/usr/local CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS5 -DSQLITE_USE_URI -DSQLITE_ENABLE_JSON1" LDFLAGS="-lm"
107+
make -j$(nproc)
108+
sudo make install
109+
sudo ldconfig
110+
36111
- name: Set up PHP
37112
uses: shivammathur/setup-php@v2
38113
with:
39114
php-version: ${{ matrix.php }}
40115
coverage: none
41116
tools: phpunit-polyfills
42117

118+
- name: Verify SQLite version in PHP
119+
run: |
120+
EXPECTED='${{ matrix.sqlite }}'
121+
if [ "$EXPECTED" = 'latest' ]; then
122+
EXPECTED=$(cat sqlite/VERSION)
123+
fi
124+
PDO=$(php -r "echo (new PDO('sqlite::memory'))->query('SELECT SQLITE_VERSION();')->fetch()[0];")
125+
echo "Expected SQLite version: $EXPECTED"
126+
echo "PHP PDO SQLite version: $PDO"
127+
if [ "$EXPECTED" != "$PDO" ]; then
128+
echo "Error: Expected SQLite version $EXPECTED, but PHP PDO uses $PDO"
129+
exit 1
130+
fi
131+
43132
- name: Set up Rust
133+
if: matrix.native
44134
uses: dtolnay/rust-toolchain@stable
45135

46136
- name: Install native build dependencies
137+
if: matrix.native
47138
run: |
48139
sudo apt-get update
49140
sudo apt-get install -y libclang-dev
@@ -65,15 +156,17 @@ jobs:
65156
composer-options: "--optimize-autoloader"
66157

67158
- name: Check Rust formatting
68-
if: matrix.php == '8.2'
159+
if: matrix.php == '8.2' && matrix.native
69160
run: cargo fmt --check
70161
working-directory: packages/php-ext-wp-mysql-parser
71162

72163
- name: Build parser extension
164+
if: matrix.native
73165
run: cargo build
74166
working-directory: packages/php-ext-wp-mysql-parser
75167

76168
- name: Run native parser smoke tests
169+
if: matrix.native
77170
run: |
78171
php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so" -r '
79172
require "src/load.php";
@@ -106,6 +199,7 @@ jobs:
106199
working-directory: packages/mysql-on-sqlite
107200

108201
- name: Verify SQLite driver selects the native parser path
202+
if: matrix.native
109203
run: |
110204
php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so" -r '
111205
require "packages/mysql-on-sqlite/src/load.php";
@@ -157,7 +251,13 @@ jobs:
157251
'
158252
159253
- name: Run full PHPUnit suite with parser extension
254+
if: matrix.native
160255
env:
161256
WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION: '1'
162257
run: php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist
163258
working-directory: packages/mysql-on-sqlite
259+
260+
- name: Run full PHPUnit suite
261+
if: ${{ ! matrix.native }}
262+
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
263+
working-directory: packages/mysql-on-sqlite

packages/php-ext-wp-mysql-parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "GPL-2.0-or-later"
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
ext-php-rs = "0.15.12"
11+
ext-php-rs = { version = "0.15.12", default-features = false, features = ["runtime"] }
1212
libc = "0.2"
1313
stacker = "0.1"
1414

0 commit comments

Comments
 (0)