Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions .github/workflows/ci-test-build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ on:
type: string
default: ""
wp-version:
description: "WordPress version wp-env boots with. 'latest' uses the newest stable release."
description: >-
WordPress core wp-env boots: 'latest' (newest stable release), 'trunk' (development branch),
or a specific WordPress version (e.g. '6.8' for the latest 6.8.x or '6.8.2' for a specific
patch version).
type: string
default: "latest"
install-path:
Expand Down Expand Up @@ -107,13 +110,34 @@ jobs:
run: |
set -euo pipefail

case "$WP_VERSION" in
latest) core="" ;;
trunk) core="WordPress/WordPress#master" ;;
*)
# x.y means its newest x.y.z; the WordPress/WordPress mirror tags x.y.0 releases as x.y.
if [[ "$WP_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
ref=$(git ls-remote --tags --refs --sort=version:refname https://github.com/WordPress/WordPress.git "$WP_VERSION" "$WP_VERSION.*" \
| tail -n1 | sed 's|.*refs/tags/||')
elif [[ "$WP_VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then
ref=${WP_VERSION%.0}
else
ref=$WP_VERSION
fi
if [[ ! "$ref" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "::error::wp-version '$WP_VERSION' matches no WordPress release."
exit 1
fi
core="WordPress/WordPress#$ref"
;;
esac

# Mount only the artifact; a consumer's .wp-env.json usually mounts the dev source (".") at the same path.
jq -n \
--arg wp "$WP_VERSION" \
--arg core "$core" \
--arg php "$PHP_VERSION" \
--arg dest "${INSTALL_PATH%/}/${SLUG}" \
'{
core: (if $wp == "latest" then null else "WordPress/WordPress#\($wp)" end),
core: (if $core == "" then null else $core end),
phpVersion: $php,
plugins: [],
themes: [],
Expand Down Expand Up @@ -148,7 +172,10 @@ jobs:
- name: Run wp doctor
shell: bash
env:
DOCTOR_IGNORE_CHECKS: ${{ inputs.doctor-ignore-checks }}
# WordPress.org publishes no checksums for trunk builds.
DOCTOR_IGNORE_CHECKS: >-
${{ inputs.wp-version == 'trunk' && format('{0},core-verify-checksums', inputs.doctor-ignore-checks)
|| inputs.doctor-ignore-checks }}
run: |
set -euo pipefail

Expand Down
41 changes: 35 additions & 6 deletions .github/workflows/ci-test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ on:
default: ""
wp-version:
description: >-
WordPress core version for wp-env, e.g. '6.8' (resolved as WordPress/WordPress#<version>).
Empty uses the version from the consumer's .wp-env.json. Ignored when use-wp-env is false.
WordPress core for wp-env: 'latest' (newest stable release), 'trunk' (development branch),
or a specific WordPress version (e.g. '6.8' for the latest 6.8.x or '6.8.2' for a specific
patch version). Empty uses the consumer's .wp-env.json. Ignored when use-wp-env is false.
type: string
default: ""
use-wp-env:
Expand All @@ -45,12 +46,11 @@ jobs:
test-php:
name: PHPUnit
runs-on: ${{ fromJSON(inputs.runs-on) }}
# Pin the wp-env container's PHP/WordPress core via env: (not $GITHUB_ENV, which is
# newline-injectable) at job scope, so start/run/stop resolve the same environment.
# An empty WP_ENV_CORE is ignored by wp-env (falls back to the consumer's .wp-env.json).
# Pin the wp-env container's PHP via env: (not $GITHUB_ENV, which is newline-injectable)
# at job scope, so start/run/stop resolve the same environment. WP_ENV_CORE needs a
# lookup, so the "Resolve WordPress core" step validates it before writing $GITHUB_ENV.
env:
WP_ENV_PHP_VERSION: ${{ inputs.use-wp-env && inputs.php-version || '' }}
WP_ENV_CORE: ${{ (inputs.use-wp-env && inputs.wp-version != '') && format('WordPress/WordPress#{0}', inputs.wp-version) || '' }}
defaults:
run:
working-directory: ${{ inputs.working-dir }}
Expand Down Expand Up @@ -110,6 +110,35 @@ jobs:
if: ${{ inputs.use-wp-env }}
run: npm ci

- name: Resolve WordPress core
if: ${{ inputs.use-wp-env && inputs.wp-version != '' }}
shell: bash
env:
WP_VERSION: ${{ inputs.wp-version }}
run: |
set -euo pipefail
case "$WP_VERSION" in
latest) core="https://wordpress.org/latest.zip" ;;
trunk) core="WordPress/WordPress#master" ;;
*)
# x.y means its newest x.y.z; the WordPress/WordPress mirror tags x.y.0 releases as x.y.
if [[ "$WP_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
ref=$(git ls-remote --tags --refs --sort=version:refname https://github.com/WordPress/WordPress.git "$WP_VERSION" "$WP_VERSION.*" \
| tail -n1 | sed 's|.*refs/tags/||')
elif [[ "$WP_VERSION" =~ ^[0-9]+\.[0-9]+\.0$ ]]; then
ref=${WP_VERSION%.0}
else
ref=$WP_VERSION
fi
if [[ ! "$ref" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "::error::wp-version '$WP_VERSION' matches no WordPress release."
exit 1
fi
core="WordPress/WordPress#$ref"
;;
esac
echo "WP_ENV_CORE=$core" | tee -a "$GITHUB_ENV"

- name: Start wp-env
if: ${{ inputs.use-wp-env }}
run: npm run wp-env start
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/wp-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ on:
type: string
default: '["8.3"]'
wp-versions:
description: "JSON array of WordPress core versions for wp-env, crossed with php-versions, e.g. '[\"6.8\",\"6.9\"]'. An empty-string entry uses .wp-env.json. Ignored when use-wp-env is false."
description: >-
JSON array of WordPress core versions for wp-env, crossed with php-versions, e.g.
'["6.8","latest","trunk"]'. 'latest' is the newest stable release, 'trunk' the
development branch and '6.8' the latest 6.8.x. An empty-string entry uses .wp-env.json.
Ignored when use-wp-env is false.
type: string
default: '[""]'
test-php-exclude:
Expand Down
Loading