diff --git a/.github/workflows/mysql-parser-extension-tests.yml b/.github/workflows/mysql-parser-extension-tests.yml deleted file mode 100644 index 45425bb8b..000000000 --- a/.github/workflows/mysql-parser-extension-tests.yml +++ /dev/null @@ -1,189 +0,0 @@ -name: MySQL Parser Extension Tests - -on: - push: - branches: - - trunk - paths: - - '.github/workflows/mysql-parser-extension-tests.yml' - - 'packages/mysql-on-sqlite/**' - - 'packages/php-ext-wp-mysql-parser/**' - pull_request: - paths: - - '.github/workflows/mysql-parser-extension-tests.yml' - - 'packages/mysql-on-sqlite/**' - - 'packages/php-ext-wp-mysql-parser/**' - 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: - extension-tests: - name: PHP ${{ matrix.php }} / ${{ matrix.coverage }} / ubuntu-latest - runs-on: ubuntu-latest - timeout-minutes: 30 - permissions: - contents: read # Required to clone the repo. - strategy: - fail-fast: false - matrix: - include: - - php: '7.2' - sqlite: '3.27.0' - native: false - coverage: SQLite integration - - php: '7.3' - sqlite: '3.31.1' - native: false - coverage: SQLite integration - - php: '7.4' - sqlite: '3.34.1' - native: false - coverage: SQLite integration - - php: '8.0' - sqlite: '3.37.0' - native: true - coverage: SQLite integration + Rust extension - - php: '8.1' - sqlite: '3.40.1' - native: true - coverage: SQLite integration + Rust extension - - php: '8.2' - sqlite: '3.45.1' - native: true - coverage: SQLite integration + Rust extension - - php: '8.3' - sqlite: '3.46.1' - native: true - coverage: SQLite integration + Rust extension - - php: '8.4' - sqlite: '3.51.2' - native: true - coverage: SQLite integration + Rust extension - - php: '8.5' - sqlite: latest - native: true - coverage: SQLite integration + Rust extension - - 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: Set up Rust - if: matrix.native - uses: dtolnay/rust-toolchain@stable - - - name: Install native build dependencies - if: matrix.native - 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 - if: matrix.php == '8.2' && matrix.native - run: cargo fmt --check - working-directory: packages/php-ext-wp-mysql-parser - - - name: Build parser extension - if: matrix.native - run: cargo build - working-directory: packages/php-ext-wp-mysql-parser - - - name: Verify native parser extension - if: matrix.native - run: php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so" tests/tools/verify-native-parser-extension.php - working-directory: packages/mysql-on-sqlite - - - name: Run full PHPUnit suite with parser extension - if: matrix.native - env: - WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION: '1' - 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 - working-directory: packages/mysql-on-sqlite - - - name: Run full PHPUnit suite - if: ${{ ! matrix.native }} - run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist - working-directory: packages/mysql-on-sqlite diff --git a/.github/workflows/mysql-proxy-tests.yml b/.github/workflows/mysql-proxy-tests.yml index e24c36f3d..6e6a0afa2 100644 --- a/.github/workflows/mysql-proxy-tests.yml +++ b/.github/workflows/mysql-proxy-tests.yml @@ -26,6 +26,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '7.4' + coverage: none - name: Install Composer dependencies uses: ramsey/composer-install@v3 diff --git a/.github/workflows/phpunit-tests-run.yml b/.github/workflows/phpunit-tests-run.yml deleted file mode 100644 index 2eec8ee2f..000000000 --- a/.github/workflows/phpunit-tests-run.yml +++ /dev/null @@ -1,113 +0,0 @@ -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 - -# Disable permissions for all available scopes by default. -# Any needed permissions should be configured at the job level. -permissions: {} - -jobs: - phpunit-tests: - name: ${{ inputs.os }} - runs-on: ${{ inputs.os }} - timeout-minutes: 20 - permissions: - contents: read # Required to clone the repo. - - 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 - 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: '${{ 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 diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 232930877..5126e2ea3 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -3,8 +3,25 @@ name: PHPUnit Tests on: push: branches: - - main + - trunk + paths: + - '.github/workflows/phpunit-tests.yml' + - 'packages/mysql-on-sqlite/**' + - 'packages/php-ext-wp-mysql-parser/**' + - 'composer.json' + - 'composer.lock' pull_request: + paths: + - '.github/workflows/phpunit-tests.yml' + - 'packages/mysql-on-sqlite/**' + - 'packages/php-ext-wp-mysql-parser/**' + - '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. @@ -12,38 +29,160 @@ permissions: {} jobs: test: - name: PHP ${{ matrix.php }} / SQLite ${{ matrix.sqlite || 'latest' }} - uses: ./.github/workflows/phpunit-tests-run.yml + # The pure-PHP parser is exercised across the full PHP/SQLite range; the + # native Rust parser extension is exercised on PHP 8.0+ (its minimum). Both + # run the same mysql-on-sqlite suite, just with a different parser engine. + name: PHP ${{ matrix.php }}${{ matrix.extension && ' + ext-wp-mysql-parser' || '' }} / SQLite ${{ matrix.sqlite }} + runs-on: ubuntu-latest + timeout-minutes: 30 permissions: contents: read # Required to clone the repo. - secrets: inherit strategy: fail-fast: false matrix: - os: [ ubuntu-latest ] - php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] include: - # Add specific SQLite versions for specific PHP versions here: - - php: '7.2' - sqlite: '3.27.0' # minimum version 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), common with PHP < 8.1 - - php: '8.0' - sqlite: '3.37.0' # minimum supported version (STRICT table support), Ubuntu 22.04 LTS (3.37.2) - - 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), Ubuntu >= 24.10 - - php: '8.4' - sqlite: '3.51.2' # First 2026 release - - php: '8.5' - sqlite: 'latest' - - with: - os: ${{ matrix.os }} - php: ${{ matrix.php }} - sqlite: ${{ matrix.sqlite || 'latest' }} + # 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', extension: false } # minimum with WP_SQLITE_UNSAFE_ENABLE_UNSUPPORTED_VERSIONS + - { php: '7.3', sqlite: '3.31.1', extension: false } # Ubuntu 20.04 LTS + - { php: '7.4', sqlite: '3.34.1', extension: false } # Debian 11 (Bullseye) + - { php: '8.0', sqlite: '3.37.0', extension: false } # minimum supported version (STRICT tables) + - { php: '8.1', sqlite: '3.40.1', extension: false } # Debian 12 (Bookworm) + - { php: '8.2', sqlite: '3.45.1', extension: false } # Ubuntu 24.04 LTS + - { php: '8.3', sqlite: '3.46.1', extension: false } # Debian 13 (Trixie) + - { php: '8.4', sqlite: '3.51.2', extension: false } # First 2026 release + - { php: '8.5', sqlite: 'latest', extension: false } + # Native Rust parser extension (requires PHP 8.0+). + - { php: '8.0', sqlite: '3.37.0', extension: true } + - { php: '8.1', sqlite: '3.40.1', extension: true } + - { php: '8.2', sqlite: '3.45.1', extension: true } + - { php: '8.3', sqlite: '3.46.1', extension: true } + - { php: '8.4', sqlite: '3.51.2', extension: true } + - { php: '8.5', sqlite: 'latest', extension: true } + + 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: Set up Rust + if: matrix.extension + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust build + if: matrix.extension + uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/php-ext-wp-mysql-parser + # Segregate by PHP version: the extension links against the PHP headers + # of the matrix's php-config, so a build cached for one PHP version is + # ABI-incompatible with another (Zend module API mismatch on load). + key: php-${{ matrix.php }} + + - name: Install native build dependencies + if: matrix.extension + 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 + if: ${{ matrix.extension && matrix.php == '8.2' }} + run: cargo fmt --check + working-directory: packages/php-ext-wp-mysql-parser + + - name: Build parser extension + if: matrix.extension + run: cargo build --release + working-directory: packages/php-ext-wp-mysql-parser + + - name: Verify native parser extension + if: matrix.extension + run: php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/release/libwp_mysql_parser.so" tests/tools/verify-native-parser-extension.php + working-directory: packages/mysql-on-sqlite + + - name: Run PHPUnit suite with parser extension + if: matrix.extension + env: + WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION: '1' + run: php -d extension="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/release/libwp_mysql_parser.so" ./vendor/bin/phpunit -c ./phpunit.xml.dist + working-directory: packages/mysql-on-sqlite + + - name: Run PHPUnit suite + if: ${{ ! matrix.extension }} + run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist + working-directory: packages/mysql-on-sqlite diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 7df545511..d02c88e3f 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -54,6 +54,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '8.2' + coverage: none - name: Build plugin zip run: composer run build-sqlite-plugin-zip