-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathmysql-parser-extension-tests.yml
More file actions
144 lines (121 loc) · 5.22 KB
/
mysql-parser-extension-tests.yml
File metadata and controls
144 lines (121 loc) · 5.22 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: MySQL Parser Extension Tests
on:
push:
paths:
- '.github/workflows/mysql-parser-extension-tests.yml'
- 'packages/mysql-on-sqlite/**'
- 'tmp-test-native/**'
pull_request:
paths:
- '.github/workflows/mysql-parser-extension-tests.yml'
- 'packages/mysql-on-sqlite/**'
- 'tmp-test-native/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
extension-tests:
name: PHP 8.2 / Rust extension / ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
tools: phpunit-polyfills
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install native build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev
echo "PHP_CONFIG=$(command -v php-config)" >> "$GITHUB_ENV"
LIBCLANG_SO="$(find /usr/lib -name 'libclang.so*' | head -n 1)"
echo "LIBCLANG_PATH=$(dirname "$LIBCLANG_SO")" >> "$GITHUB_ENV"
- 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: Check Rust formatting
run: cargo fmt --check
working-directory: packages/mysql-on-sqlite/ext/wp-mysql-parser
- name: Build parser extension
run: cargo build
working-directory: packages/mysql-on-sqlite/ext/wp-mysql-parser
- name: Run PHPUnit tests with parser extension
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist
working-directory: packages/mysql-on-sqlite
sqlite-driver-extension-tests:
name: PHP 8.2 / SQLite driver / Rust extension / ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
tools: phpunit-polyfills
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install native build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev
echo "PHP_CONFIG=$(command -v php-config)" >> "$GITHUB_ENV"
LIBCLANG_SO="$(find /usr/lib -name 'libclang.so*' | head -n 1)"
echo "LIBCLANG_PATH=$(dirname "$LIBCLANG_SO")" >> "$GITHUB_ENV"
- 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: Build parser extension
run: cargo build
working-directory: packages/mysql-on-sqlite/ext/wp-mysql-parser
- name: Verify SQLite driver selects the native parser path
run: |
php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" -r '
require "packages/mysql-on-sqlite/src/load.php";
$lexer = new WP_MySQL_Lexer( "SELECT 1" );
if ( ! method_exists( $lexer, "native_token_stream" ) ) {
fwrite( STDERR, "Native token stream is not available.\n" );
exit( 1 );
}
$driver = new WP_PDO_MySQL_On_SQLite( "mysql-on-sqlite:path=:memory:;dbname=wp;" );
$parser = $driver->create_parser( "SELECT 1" );
$parser->next_query();
$ast = $parser->get_query_ast();
$property = ( new ReflectionClass( $ast ) )->getProperty( "native_ast" );
$property->setAccessible( true );
$native_ast = $property->getValue( $ast );
if ( ! is_object( $native_ast ) || "WP_MySQL_Native_Ast" !== get_class( $native_ast ) ) {
fwrite( STDERR, "SQLite driver did not return a native-backed AST.\n" );
exit( 1 );
}
'
- name: Run PHPUnit tests with SQLite driver using parser extension
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist
working-directory: packages/mysql-on-sqlite
- name: Run native SQLite facade smoke workload
run: php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" tmp-test-native/run-sqlite-facade-smoke.php