Skip to content

Commit 007ee51

Browse files
committed
Build playground-php-wasm base + compile-extension images in CI
The previous workflow assumed playground-php-wasm:compile-extension-php8-4-jspi was already present in the Docker daemon (which it is locally, after running the @php-wasm/compile-extension CLI once). On a fresh runner it isn't, so Dockerfile.rust failed at FROM with 'pull access denied'. Build it explicitly: 'make base-image' for the Emscripten toolchain layer, then docker build of compile-extension/docker/Dockerfile.ext with the same PHP_VERSION the CLI's resolvePHPRelease() would pick, tagged the way the CLI tags it (dots replaced with dashes).
1 parent ca0ad88 commit 007ee51

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

.github/workflows/wasm-spike.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,43 @@ jobs:
5353
working-directory: wordpress-playground
5454
run: npm ci
5555

56-
- name: Build @php-wasm/compile-extension base image
56+
- name: Resolve PHP release for ${{ matrix.php }}
57+
id: php-release
5758
working-directory: wordpress-playground
5859
run: |
59-
npx @php-wasm/compile-extension --help >/dev/null 2>&1 || true
60-
docker images | grep playground-php-wasm || true
60+
# Mirror @php-wasm/compile-extension's resolvePHPRelease() by
61+
# parsing its source map so we tag the image with the exact same
62+
# PHP_VERSION value the CLI would use.
63+
RELEASE=$(node -e "
64+
const fs=require('fs');
65+
const src=fs.readFileSync('./packages/php-wasm/compile-extension/src/compile.ts','utf8');
66+
const map=Object.fromEntries([...src.matchAll(/'(\d+\.\d+)':\s*'(\d+\.\d+\.\d+)'/g)].map(m=>[m[1],m[2]]));
67+
const r=map['${{ matrix.php }}'];
68+
if (!r) { process.exit(1); }
69+
console.log(r);
70+
")
71+
echo "release=$RELEASE" >> "$GITHUB_OUTPUT"
72+
echo "Resolved PHP ${{ matrix.php }} -> $RELEASE"
73+
74+
- name: Build playground-php-wasm:base image
75+
working-directory: wordpress-playground/packages/php-wasm/compile
76+
run: make base-image
77+
78+
- name: Build per-version compile-extension image
79+
working-directory: wordpress-playground/packages/php-wasm
80+
env:
81+
IMAGE_TAG: playground-php-wasm:compile-extension-php${{ matrix.php == '8.4' && '8-4' || matrix.php == '8.3' && '8-3' || matrix.php == '8.2' && '8-2' || matrix.php == '8.1' && '8-1' || matrix.php == '8.0' && '8-0' || matrix.php == '7.4' && '7-4' || matrix.php == '7.3' && '7-3' || matrix.php == '7.2' && '7-2' || matrix.php }}-${{ matrix.async-mode }}
82+
run: |
83+
JSPI_FLAG=no
84+
if [ "${{ matrix.async-mode }}" = "jspi" ]; then JSPI_FLAG=yes; fi
85+
docker build \
86+
-f compile-extension/docker/Dockerfile.ext \
87+
. \
88+
--tag "$IMAGE_TAG" \
89+
--progress=plain \
90+
--build-arg "PHP_VERSION=${{ steps.php-release.outputs.release }}" \
91+
--build-arg "JSPI=$JSPI_FLAG"
92+
docker images | grep playground-php-wasm
6193
6294
- name: Build wp_mysql_parser side module
6395
working-directory: sqlite-database-integration/packages/php-ext-wp-mysql-parser/wasm-spike

0 commit comments

Comments
 (0)