-
Notifications
You must be signed in to change notification settings - Fork 59
84 lines (75 loc) · 2.59 KB
/
phpunit-tests-run.yml
File metadata and controls
84 lines (75 loc) · 2.59 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
name: Run PHPUnit tests
on:
workflow_call:
inputs:
os:
description: 'Operating system to run tests on'
required: false
type: 'string'
default: 'ubuntu-latest'
php:
description: 'The version of PHP to use, in the format of X.Y'
required: true
type: 'string'
sqlite:
description: 'SQLite version to install (e.g., 3.24.0). Leave empty for latest version.'
required: false
type: 'string'
default: 'latest'
env:
LOCAL_PHP: ${{ inputs.php }}-fpm
jobs:
phpunit-tests:
name: ${{ inputs.os }}
runs-on: ${{ inputs.os }}
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up SQLite
run: |
VERSION='${{ inputs.sqlite }}'
if [ "$VERSION" = 'latest' ]; then
TAG='release'
else
TAG="version-${VERSION}"
fi
wget -O sqlite.tar.gz "https://sqlite.org/src/tarball/sqlite.tar.gz?r=${TAG}"
tar xzf sqlite.tar.gz
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: '${{ inputs.php }}'
tools: phpunit-polyfills
- name: Verify SQLite version in PHP
run: |
EXPECTED='${{ inputs.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 tests
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
working-directory: packages/mysql-on-sqlite