Repository navigation
130 lines (119 loc) · 4.36 KB
/
Copy pathphpunit-tests.yml
File metadata and controls
130 lines (119 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: PHPUnit Tests
on:
push:
branches:
- trunk
paths:
- '.github/workflows/phpunit-tests.yml'
- 'packages/mysql-on-sqlite/**'
- 'composer.json'
- 'composer.lock'
pull_request:
paths:
- '.github/workflows/phpunit-tests.yml'
- 'packages/mysql-on-sqlite/**'
- 'composer.json'
- 'composer.lock'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
test:
name: PHP ${{ matrix.php }} / SQLite ${{ matrix.sqlite }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read # Required to clone the repo.
strategy:
fail-fast: false
matrix:
include:
# Pure-PHP parser, across the supported PHP versions, each pinned to a
# representative SQLite version spanning the supported range.
- { php: '7.2', sqlite: '3.27.0' } # minimum with WP_SQLITE_UNSAFE_ENABLE_UNSUPPORTED_VERSIONS
- { php: '7.3', sqlite: '3.31.1' } # Ubuntu 20.04 LTS
- { php: '7.4', sqlite: '3.34.1' } # Debian 11 (Bullseye)
- { php: '8.0', sqlite: '3.37.0' } # minimum supported version (STRICT tables)
- { php: '8.1', sqlite: '3.40.1' } # Debian 12 (Bookworm)
- { php: '8.2', sqlite: '3.45.1' } # Ubuntu 24.04 LTS
- { php: '8.3', sqlite: '3.46.1' } # Debian 13 (Trixie)
- { php: '8.4', sqlite: '3.51.2' } # First 2026 release
- { php: '8.5', sqlite: 'latest' }
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up SQLite
run: |
VERSION='${{ matrix.sqlite }}'
if [ "$VERSION" = 'latest' ]; then
TAG='release'
else
TAG="version-${VERSION}"
fi
SQLITE_SOURCE="https://sqlite.org/src/tarball/sqlite.tar.gz?r=${TAG}"
SQLITE_MIRROR="https://github.com/sqlite/sqlite/archive/refs/tags/${TAG}.tar.gz"
DOWNLOADED=0
for url in "$SQLITE_SOURCE" "$SQLITE_MIRROR"; do
for attempt in 1 2 3 4 5; do
if wget -O sqlite.tar.gz "$url"; then
DOWNLOADED=1
break 2
fi
if [ "$attempt" -lt 5 ]; then
sleep $(( attempt * 10 ))
fi
done
done
if [ "$DOWNLOADED" -ne 1 ]; then
exit 1
fi
tar xzf sqlite.tar.gz
if [ ! -d sqlite ]; then
SQLITE_DIR=$(find . -maxdepth 1 -type d -name 'sqlite-*' | head -n 1)
if [ -z "$SQLITE_DIR" ]; then
exit 1
fi
mv "$SQLITE_DIR" sqlite
fi
cd sqlite
./configure --prefix=/usr/local CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS5 -DSQLITE_USE_URI -DSQLITE_ENABLE_JSON1" LDFLAGS="-lm"
make -j$(nproc)
sudo make install
sudo ldconfig
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: phpunit-polyfills
- name: Verify SQLite version in PHP
run: |
EXPECTED='${{ matrix.sqlite }}'
if [ "$EXPECTED" = 'latest' ]; then
EXPECTED=$(cat sqlite/VERSION)
fi
PDO=$(php -r "echo (new PDO('sqlite::memory'))->query('SELECT SQLITE_VERSION();')->fetch()[0];")
echo "Expected SQLite version: $EXPECTED"
echo "PHP PDO SQLite version: $PDO"
if [ "$EXPECTED" != "$PDO" ]; then
echo "Error: Expected SQLite version $EXPECTED, but PHP PDO uses $PDO"
exit 1
fi
- name: Install Composer dependencies (root)
uses: ramsey/composer-install@v3
with:
ignore-cache: "yes"
composer-options: "--optimize-autoloader"
- name: Install Composer dependencies (mysql-on-sqlite)
uses: ramsey/composer-install@v3
with:
working-directory: packages/mysql-on-sqlite
ignore-cache: "yes"
composer-options: "--optimize-autoloader"
- name: Run PHPUnit suite
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
working-directory: packages/mysql-on-sqlite