Skip to content

Ship wp_mysql_parser as WASM #27

Ship wp_mysql_parser as WASM

Ship wp_mysql_parser as WASM #27

Workflow file for this run

name: WASM extension build
on:
push:
branches:
- main
paths:
- 'packages/php-ext-wp-mysql-parser/**'
- '.github/workflows/wasm-spike.yml'
pull_request:
paths:
- 'packages/php-ext-wp-mysql-parser/**'
- '.github/workflows/wasm-spike.yml'
workflow_dispatch:
inputs:
playground-ref:
description: 'wordpress-playground branch/tag/SHA to build against'
required: false
default: 'trunk'
jobs:
build-and-load:
name: Build wp_mysql_parser.so and load it in Playground (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
max-parallel: 1
matrix:
php: ['8.5', '8.4', '8.3', '8.2', '8.1', '8.0']
async-mode: ['jspi']
steps:
- name: Check out sqlite-database-integration
uses: actions/checkout@v4
with:
path: sqlite-database-integration
- name: Check out wordpress-playground
uses: actions/checkout@v4
with:
repository: WordPress/wordpress-playground
ref: ${{ github.event.inputs.playground-ref || 'trunk' }}
path: wordpress-playground
sparse-checkout-cone-mode: false
sparse-checkout: |
/package.json
/package-lock.json
/nx.json
/tsconfig.base.json
/packages/meta/
/packages/nx-extensions/
/packages/php-wasm/cli-util/
/packages/php-wasm/compile-extension/
/packages/php-wasm/compile/
/packages/php-wasm/fs-journal/
/packages/php-wasm/logger/
/packages/php-wasm/node/
/packages/php-wasm/node-builds/8-0/
/packages/php-wasm/node-builds/8-1/
/packages/php-wasm/node-builds/8-2/
/packages/php-wasm/node-builds/8-3/
/packages/php-wasm/node-builds/8-4/
/packages/php-wasm/node-builds/8-5/
/packages/php-wasm/progress/
/packages/php-wasm/scopes/
/packages/php-wasm/stream-compression/
/packages/php-wasm/universal/
/packages/php-wasm/util/
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: wordpress-playground/package-lock.json
- name: Install Playground deps
working-directory: wordpress-playground
run: npm ci --ignore-scripts
- name: Configure Docker DNS
run: |
# GitHub-hosted runners occasionally have a Docker daemon whose
# default bridge network can't resolve archive.ubuntu.com. Pin
# explicit public resolvers so apt-get inside the base image build
# can reach the Ubuntu mirrors.
echo '{"dns": ["8.8.8.8", "1.1.1.1"]}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
# Wait for Docker to come back up.
for i in 1 2 3 4 5 6 7 8 9 10; do
if docker info >/dev/null 2>&1; then break; fi
sleep 2
done
- name: Build wp_mysql_parser side module
working-directory: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike
env:
PHP_VERSION: ${{ matrix.php }}
ASYNC_MODE: ${{ matrix.async-mode }}
PLAYGROUND_REPO: ${{ github.workspace }}/wordpress-playground
run: bash build-in-docker-rust.sh
- name: Verify build artifacts exist
working-directory: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike
run: |
test -f dist/wp_mysql_parser-php${{ matrix.php }}-${{ matrix.async-mode }}.so
test -f dist/manifest.json
test -f dist/libwp_mysql_parser.a
ls -lh dist/
- name: Verify manifest sha256 matches the .so byte-for-byte
working-directory: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike
run: |
MANIFEST_SHA=$(node -e "console.log(require('./dist/manifest.json').artifacts[0].sha256)")
ACTUAL_SHA=$(sha256sum dist/wp_mysql_parser-php${{ matrix.php }}-${{ matrix.async-mode }}.so | cut -d' ' -f1)
echo "manifest: $MANIFEST_SHA"
echo "actual: $ACTUAL_SHA"
test "$MANIFEST_SHA" = "$ACTUAL_SHA"
- name: Load the extension in Playground and parse a query
working-directory: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike
env:
PLAYGROUND_REPO: ${{ github.workspace }}/wordpress-playground
PHP_VERSION: ${{ matrix.php }}
run: node run-spike.mjs
- name: Upload artifacts on success
if: success()
uses: actions/upload-artifact@v4
with:
name: wp_mysql_parser-php${{ matrix.php }}-${{ matrix.async-mode }}
path: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike/dist/
if-no-files-found: error
retention-days: 14
- name: Upload diagnostic logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: wasm-spike-failure-php${{ matrix.php }}-${{ matrix.async-mode }}
path: |
sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike/dist/
sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike/*.log
if-no-files-found: ignore
retention-days: 14