Skip to content

Commit ae0f4c9

Browse files
committed
Add a component-based Wasmtime Playground runtime
1 parent 506e013 commit ae0f4c9

86 files changed

Lines changed: 41837 additions & 12 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ packages/docs/site/docs/site/docs/ linguist-documentation=true
55
packages/docs/site/static/diagrams.excalidraw linguist-documentation=true
66
packages/php-wasm/compile/*/dist linguist-vendored
77
packages/php-wasm/compile/libz/zlib-src linguist-vendored
8+
packages/php-wasm/compile/php-wasi/patches/*.patch whitespace=-blank-at-eol,-blank-at-eof,-space-before-tab
89
packages/php-wasm/node/public/ linguist-generated=true
910
packages/php-wasm/node-builds/*/asyncify/** linguist-generated=true -diff
1011
packages/php-wasm/node-builds/*/jspi/** linguist-generated=true -diff

.github/actions/prepare-playground/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Clone the repository, install dependencies, and configures nx variables
1+
name: Clone the repository, install dependencies, and configure Nx variables
2+
description: Prepare a Playground checkout, dependencies, and Nx environment variables.
23

34
inputs:
45
node-version:
5-
type: string
66
required: true
77
description: 'Node.js version to use'
88
default: '20'

.github/workflows/ci.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ jobs:
3434
- run: npx nx affected --target=typecheck
3535
- run: npx nx check-orphan-pages docs-site
3636
- run: bash tools/check-node-engine-alignment.sh
37+
test-php-wasip2-component:
38+
name: 'Build and validate PHP WASI component'
39+
if: github.repository == 'WordPress/wordpress-playground' || github.event_name == 'pull_request'
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 30
42+
permissions:
43+
contents: read # Required to clone the repo.
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
submodules: true
48+
- uses: ./.github/actions/prepare-playground
49+
- run: npx nx run php-wasm-compile:build-wasip2-component --skip-nx-cache --output-style=stream
50+
- run: npx nx run php-wasm-compile:validate-wasip2-component --skip-nx-cache --output-style=stream
51+
- name: Upload component after a reproducibility failure
52+
if: failure()
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: php-wasi-component-reproducibility-failure
56+
path: packages/php-wasm/compile/php-wasi/dist/php-wasi-component.wasm
57+
if-no-files-found: error
58+
retention-days: 3
59+
- name: Verify the checked-in component is reproducible
60+
run: git diff --exit-code -- packages/php-wasm/compile/php-wasi/dist/php-wasi-component.wasm
61+
3762
test-unit-asyncify:
3863
if: github.repository == 'WordPress/wordpress-playground' || github.event_name == 'pull_request'
3964
runs-on: ubuntu-latest
@@ -156,6 +181,96 @@ jobs:
156181
node-version: 22
157182
- name: Run full test suite
158183
run: node node_modules/nx/bin/nx affected --target=test-playground-cli
184+
test-playground-cli-native:
185+
if: github.repository == 'WordPress/wordpress-playground' || github.event_name == 'pull_request'
186+
strategy:
187+
fail-fast: false
188+
matrix:
189+
include:
190+
- label: linux-x64
191+
os: ubuntu-latest
192+
target: x86_64-unknown-linux-gnu
193+
exe: ''
194+
precompile: --precompile-wasmtime
195+
- label: linux-arm64
196+
os: ubuntu-24.04-arm
197+
target: aarch64-unknown-linux-gnu
198+
exe: ''
199+
precompile: --precompile-wasmtime
200+
- label: windows-x64
201+
os: windows-latest
202+
target: x86_64-pc-windows-msvc
203+
exe: '.exe'
204+
precompile: --precompile-wasmtime
205+
- label: windows-arm64
206+
os: windows-11-arm
207+
target: aarch64-pc-windows-msvc
208+
exe: '.exe'
209+
precompile: --precompile-wasmtime
210+
- label: macos-x64
211+
os: macos-15-intel
212+
target: x86_64-apple-darwin
213+
exe: ''
214+
precompile: --precompile-wasmtime
215+
- label: macos-arm64
216+
os: macos-latest
217+
target: aarch64-apple-darwin
218+
exe: ''
219+
precompile: --precompile-wasmtime
220+
runs-on: ${{ matrix.os }}
221+
timeout-minutes: 90
222+
permissions:
223+
contents: read # Required to clone the repo.
224+
name: 'test-playground-cli-native (${{ matrix.label }})'
225+
steps:
226+
- uses: actions/checkout@v4
227+
with:
228+
submodules: true
229+
- name: Install Rust components
230+
run: |
231+
rustup toolchain install stable --profile minimal --component clippy --component rustfmt
232+
rustup default stable
233+
rustup target add ${{ matrix.target }}
234+
- name: Read package version
235+
shell: bash
236+
run: |
237+
VERSION="$(node -p "require('./lerna.json').version")"
238+
echo "WP_PLAYGROUND_NATIVE_VERSION=$VERSION" >> "$GITHUB_ENV"
239+
- name: Check formatting
240+
run: cargo fmt --manifest-path packages/playground/cli-native/Cargo.toml -- --check
241+
- name: Run clippy
242+
run: cargo clippy --manifest-path packages/playground/cli-native/Cargo.toml --all-targets -- -D warnings
243+
- name: Run tests
244+
run: cargo test --manifest-path packages/playground/cli-native/Cargo.toml
245+
- name: Smoke native server process
246+
run: cargo test --manifest-path packages/playground/cli-native/Cargo.toml --test native_server -- --ignored --nocapture
247+
- name: Build packaged binary and smoke packaged runtime
248+
shell: bash
249+
env:
250+
WP_PLAYGROUND_NATIVE_TARGET_TRIPLE: ${{ matrix.target }}
251+
WP_PLAYGROUND_NATIVE_SOURCE_COMMIT: ${{ github.sha }}
252+
WP_PLAYGROUND_NATIVE_PACKAGE_PRECOMPILE: '1'
253+
run: |
254+
smoke_args=(
255+
--smoke-wordpress-server
256+
--smoke-run-blueprint
257+
--smoke-build-snapshot
258+
)
259+
cargo build --manifest-path packages/playground/cli-native/Cargo.toml --release --bins --target ${{ matrix.target }}
260+
cargo run --manifest-path packages/playground/cli-native/Cargo.toml --release --bin package-native-cli -- \
261+
--binary "packages/playground/cli-native/target/${{ matrix.target }}/release/wp-playground-native${{ matrix.exe }}" \
262+
--name "wp-playground-native-$WP_PLAYGROUND_NATIVE_VERSION-${{ matrix.label }}" \
263+
${{ matrix.precompile }} \
264+
"${smoke_args[@]}"
265+
- name: Upload native package archive
266+
uses: actions/upload-artifact@v4
267+
with:
268+
name: wp-playground-native-${{ matrix.label }}
269+
path: |
270+
packages/playground/cli-native/target/package/*.zip
271+
packages/playground/cli-native/target/package/*.zip.sha256
272+
packages/playground/cli-native/target/package/*.zip.manifest.json
273+
if-no-files-found: error
159274
test-file-locking:
160275
if: github.repository == 'WordPress/wordpress-playground' || github.event_name == 'pull_request'
161276
strategy:

.github/workflows/publish-github-release.yml

Lines changed: 131 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,101 @@ on:
1212
permissions: {}
1313

1414
jobs:
15+
build-native-cli-archives:
16+
# Build native CLI archives before the release is created so they can
17+
# be uploaded as GitHub release assets.
18+
if: >
19+
github.repository == 'WordPress/wordpress-playground' &&
20+
(
21+
github.event_name == 'workflow_dispatch' ||
22+
(
23+
github.event.workflow_run.conclusion == 'success' &&
24+
github.event.workflow_run.head_branch == 'trunk'
25+
)
26+
)
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- label: linux-x64
33+
os: ubuntu-latest
34+
target: x86_64-unknown-linux-gnu
35+
exe: ''
36+
- label: linux-arm64
37+
os: ubuntu-24.04-arm
38+
target: aarch64-unknown-linux-gnu
39+
exe: ''
40+
- label: windows-x64
41+
os: windows-latest
42+
target: x86_64-pc-windows-msvc
43+
exe: '.exe'
44+
- label: windows-arm64
45+
os: windows-11-arm
46+
target: aarch64-pc-windows-msvc
47+
exe: '.exe'
48+
- label: macos-x64
49+
os: macos-15-intel
50+
target: x86_64-apple-darwin
51+
exe: ''
52+
- label: macos-arm64
53+
os: macos-latest
54+
target: aarch64-apple-darwin
55+
exe: ''
56+
runs-on: ${{ matrix.os }}
57+
timeout-minutes: 90
58+
permissions:
59+
contents: read # Required to clone the repo.
60+
name: 'build-native-cli-archive (${{ matrix.label }})'
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
with:
65+
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
66+
submodules: true
67+
68+
- name: Install Rust components
69+
run: |
70+
rustup toolchain install stable --profile minimal
71+
rustup default stable
72+
rustup target add ${{ matrix.target }}
73+
74+
- name: Read package version
75+
shell: bash
76+
run: |
77+
VERSION="$(node -p "require('./lerna.json').version")"
78+
echo "WP_PLAYGROUND_NATIVE_VERSION=$VERSION" >> "$GITHUB_ENV"
79+
80+
- name: Build native CLI package archive
81+
shell: bash
82+
env:
83+
WP_PLAYGROUND_NATIVE_TARGET_TRIPLE: ${{ matrix.target }}
84+
WP_PLAYGROUND_NATIVE_SOURCE_COMMIT: ${{ github.event.workflow_run.head_sha || github.sha }}
85+
WP_PLAYGROUND_NATIVE_PACKAGE_PRECOMPILE: '1'
86+
run: |
87+
cargo build --manifest-path packages/playground/cli-native/Cargo.toml --release --bins --target ${{ matrix.target }}
88+
cargo run --manifest-path packages/playground/cli-native/Cargo.toml --release --bin package-native-cli -- \
89+
--binary "packages/playground/cli-native/target/${{ matrix.target }}/release/wp-playground-native${{ matrix.exe }}" \
90+
--name "wp-playground-native-$WP_PLAYGROUND_NATIVE_VERSION-${{ matrix.label }}" \
91+
--precompile-wasmtime \
92+
--smoke-wordpress-server \
93+
--smoke-run-blueprint \
94+
--smoke-build-snapshot
95+
96+
- name: Upload native package archive
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: wp-playground-native-release-${{ matrix.label }}
100+
path: |
101+
packages/playground/cli-native/target/package/*.zip
102+
packages/playground/cli-native/target/package/*.zip.sha256
103+
packages/playground/cli-native/target/package/*.zip.manifest.json
104+
if-no-files-found: error
105+
15106
create-release:
16107
# Only run on the playground repo. Create a release after a successful
17108
# npm publish on trunk, or when triggered manually.
109+
needs: build-native-cli-archives
18110
if: >
19111
github.repository == 'WordPress/wordpress-playground' &&
20112
(
@@ -29,19 +121,27 @@ jobs:
29121
timeout-minutes: 20
30122
permissions:
31123
contents: write # Required to clone the repo, create the GitHub release, and push the tag.
124+
actions: read # Required to download native CLI package artifacts.
32125

33126
steps:
34127
- uses: actions/checkout@v4
35128
with:
36-
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
129+
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
37130

38131
- name: Read version from lerna.json
39132
id: version
40133
run: |
41-
VERSION=$(jq -r '.version' lerna.json)
134+
VERSION="$(node -p "require('./lerna.json').version")"
42135
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43136
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
44137
138+
- name: Read the post-run changelog from trunk
139+
shell: bash
140+
run: |
141+
set -euo pipefail
142+
git fetch --depth=1 origin trunk
143+
git show origin/trunk:CHANGELOG.md > "$RUNNER_TEMP/CHANGELOG.md"
144+
45145
- name: Extract changelog for this version
46146
id: changelog
47147
run: |
@@ -66,7 +166,7 @@ jobs:
66166
67167
# While in the section for this version, print lines.
68168
found
69-
' CHANGELOG.md)
169+
' "$RUNNER_TEMP/CHANGELOG.md")
70170
if [ -z "$CHANGELOG" ]; then
71171
CHANGELOG="No changelog entries for this release."
72172
fi
@@ -88,19 +188,40 @@ jobs:
88188
echo "> **Stay up to date:** Click **Watch → Custom → Releases** at the top of this repository to get notified of new releases."
89189
} > /tmp/release-body.md
90190
91-
- name: Create GitHub Release
191+
- name: Download native CLI package archives
192+
uses: actions/download-artifact@v4
193+
with:
194+
pattern: wp-playground-native-release-*
195+
path: /tmp/native-cli-release-assets
196+
merge-multiple: true
197+
198+
- name: Verify native CLI release assets
199+
env:
200+
VERSION: ${{ steps.version.outputs.version }}
201+
RELEASE_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
202+
ASSET_DIR: /tmp/native-cli-release-assets
203+
run: python3 packages/playground/cli-native/scripts/verify-release-assets.py
204+
205+
- name: Create or update GitHub Release
92206
env:
93207
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94208
run: |
95209
TAG="${{ steps.version.outputs.tag }}"
210+
ASSET_DIR="/tmp/native-cli-release-assets"
211+
212+
if [ ! -d "$ASSET_DIR" ] || [ -z "$(find "$ASSET_DIR" -type f -print -quit)" ]; then
213+
echo "::error::No native CLI release assets were downloaded."
214+
exit 1
215+
fi
96216
97217
# Check if this release already exists
98218
if gh release view "$TAG" &>/dev/null; then
99-
echo "Release $TAG already exists, skipping."
100-
exit 0
219+
echo "Release $TAG already exists, uploading native CLI assets."
220+
else
221+
gh release create "$TAG" \
222+
--title "WordPress Playground $TAG" \
223+
--notes-file /tmp/release-body.md \
224+
--target "${{ github.event.workflow_run.head_sha || github.sha }}"
101225
fi
102226
103-
gh release create "$TAG" \
104-
--title "WordPress Playground $TAG" \
105-
--notes-file /tmp/release-body.md \
106-
--target trunk
227+
gh release upload "$TAG" "$ASSET_DIR"/* --clobber
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
dist
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.build/
2+
dist/*
3+
!dist/php-wasi-component.wasm
4+
tests/smoke/*.sqlite*

0 commit comments

Comments
 (0)