|
5 | 5 | paths: |
6 | 6 | - '.github/workflows/mysql-parser-extension-tests.yml' |
7 | 7 | - 'packages/mysql-on-sqlite/**' |
| 8 | + - 'tmp-test-native/**' |
8 | 9 | pull_request: |
9 | 10 | paths: |
10 | 11 | - '.github/workflows/mysql-parser-extension-tests.yml' |
11 | 12 | - 'packages/mysql-on-sqlite/**' |
| 13 | + - 'tmp-test-native/**' |
12 | 14 | workflow_dispatch: |
13 | 15 |
|
14 | 16 | concurrency: |
|
67 | 69 | - name: Run PHPUnit tests with parser extension |
68 | 70 | 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 |
69 | 71 | working-directory: packages/mysql-on-sqlite |
| 72 | + |
| 73 | + sqlite-driver-extension-tests: |
| 74 | + name: PHP 8.2 / SQLite driver / Rust extension / ubuntu-latest |
| 75 | + runs-on: ubuntu-latest |
| 76 | + timeout-minutes: 20 |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout repository |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Set up PHP |
| 83 | + uses: shivammathur/setup-php@v2 |
| 84 | + with: |
| 85 | + php-version: '8.2' |
| 86 | + coverage: none |
| 87 | + tools: phpunit-polyfills |
| 88 | + |
| 89 | + - name: Set up Rust |
| 90 | + uses: dtolnay/rust-toolchain@stable |
| 91 | + |
| 92 | + - name: Install native build dependencies |
| 93 | + run: | |
| 94 | + sudo apt-get update |
| 95 | + sudo apt-get install -y libclang-dev |
| 96 | + echo "PHP_CONFIG=$(command -v php-config)" >> "$GITHUB_ENV" |
| 97 | + LIBCLANG_SO="$(find /usr/lib -name 'libclang.so*' | head -n 1)" |
| 98 | + echo "LIBCLANG_PATH=$(dirname "$LIBCLANG_SO")" >> "$GITHUB_ENV" |
| 99 | +
|
| 100 | + - name: Install Composer dependencies (root) |
| 101 | + uses: ramsey/composer-install@v3 |
| 102 | + with: |
| 103 | + ignore-cache: "yes" |
| 104 | + composer-options: "--optimize-autoloader" |
| 105 | + |
| 106 | + - name: Install Composer dependencies (mysql-on-sqlite) |
| 107 | + uses: ramsey/composer-install@v3 |
| 108 | + with: |
| 109 | + working-directory: packages/mysql-on-sqlite |
| 110 | + ignore-cache: "yes" |
| 111 | + composer-options: "--optimize-autoloader" |
| 112 | + |
| 113 | + - name: Build parser extension |
| 114 | + run: cargo build |
| 115 | + working-directory: packages/mysql-on-sqlite/ext/wp-mysql-parser |
| 116 | + |
| 117 | + - name: Verify SQLite driver selects the native parser path |
| 118 | + run: | |
| 119 | + php -d extension="$GITHUB_WORKSPACE/packages/mysql-on-sqlite/ext/wp-mysql-parser/target/debug/libwp_mysql_parser.so" -r ' |
| 120 | + require "packages/mysql-on-sqlite/src/load.php"; |
| 121 | + $lexer = new WP_MySQL_Lexer( "SELECT 1" ); |
| 122 | + if ( ! method_exists( $lexer, "native_token_stream" ) ) { |
| 123 | + fwrite( STDERR, "Native token stream is not available.\n" ); |
| 124 | + exit( 1 ); |
| 125 | + } |
| 126 | + $driver = new WP_PDO_MySQL_On_SQLite( "mysql-on-sqlite:path=:memory:;dbname=wp;" ); |
| 127 | + $parser = $driver->create_parser( "SELECT 1" ); |
| 128 | + $parser->next_query(); |
| 129 | + $ast = $parser->get_query_ast(); |
| 130 | + $property = ( new ReflectionClass( $ast ) )->getProperty( "native_ast" ); |
| 131 | + $property->setAccessible( true ); |
| 132 | + $native_ast = $property->getValue( $ast ); |
| 133 | + if ( ! is_object( $native_ast ) || "WP_MySQL_Native_Ast" !== get_class( $native_ast ) ) { |
| 134 | + fwrite( STDERR, "SQLite driver did not return a native-backed AST.\n" ); |
| 135 | + exit( 1 ); |
| 136 | + } |
| 137 | + ' |
| 138 | +
|
| 139 | + - name: Run PHPUnit tests with SQLite driver using parser extension |
| 140 | + 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 |
| 141 | + working-directory: packages/mysql-on-sqlite |
| 142 | + |
| 143 | + - name: Run native SQLite facade smoke workload |
| 144 | + 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 |
0 commit comments