Build/Test Tools: Make the logic around Playground testing reusable.

The workflow responsible for testing the build process is currently responsible for creating a ZIP file of the WordPress build and storing it as an artifact. This can be used for manual testing, but is mainly used for spinning up a Playground instance.

Because of how comments with Playground testing instructions are left pull requests. the pull request number needs to be stored as a workflow artifact as well. This moves the logic responsible for this to the reusable workflow, which allows older branches to make use of Playground testing without additional maintenance burden.

See .

git-svn-id: https://develop.svn.wordpress.org/trunk@58274 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2024-05-31 18:11:30 +00:00
parent 5aea85cad3
commit 93bcf8da93
2 changed files with 29 additions and 24 deletions

@ -21,6 +21,11 @@ on:
required: false
type: 'boolean'
default: true
prepare-playground:
description: 'Whether to prepare the artifacts needed for Playground testing.'
required: false
type: 'boolean'
default: false
env:
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
@ -39,6 +44,8 @@ jobs:
# - Cleans up after building WordPress.
# - Ensures version-controlled files are not modified or deleted.
# - Uploads the ZIP as a GitHub Actions artifact (when building to the build directory).
# - Saves the pull request number to a text file.
# - Uploads the pull request number as an artifact.
build-process-tests:
name: Core running from ${{ inputs.directory }} / ${{ inputs.os == 'macos-latest' && 'MacOS' || inputs.os == 'windows-latest' && 'Windows' || 'Linux' }}
runs-on: ${{ inputs.os }}
@ -90,8 +97,23 @@ jobs:
- name: Upload ZIP as a GitHub Actions artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ inputs.directory == 'build' && 'ubuntu-latest' == inputs.os }}
if: ${{ inputs.prepare-playground }}
with:
name: wordpress-build-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
path: wordpress.zip
if-no-files-found: error
- name: Save PR number
if: ${{ inputs.prepare-playground && github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}
run: |
mkdir -p ./pr-number
echo ${{ github.event.number }} > ./pr-number/NR
# Uploads the PR number as an artifact for the Pull Request Commenting workflow to download and then
# leave a comment detailing how to test the PR within WordPress Playground.
- name: Upload PR number as artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ inputs.prepare-playground && github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}
with:
name: pr-number
path: pr-number/

@ -40,9 +40,15 @@ jobs:
matrix:
os: [ ubuntu-latest, windows-latest ]
directory: [ 'src', 'build' ]
include:
# Only prepare artifacts for Playground once.
- os: ubuntu-latest
directory: 'build'
prepare-playground: true
with:
os: ${{ matrix.os }}
directory: ${{ matrix.directory }}
prepare-playground: ${{ matrix.prepare-playground && matrix.prepare-playground || false }}
# Tests the WordPress Core build process on MacOS.
#
@ -106,29 +112,6 @@ jobs:
os: ${{ matrix.os }}
directory: ${{ matrix.directory }}
# Uploads the PR number as an artifact for the Pull Request Commenting workflow to download and then
# leave a comment detailing how to test the PR within WordPress Playground.
playground-comment:
name: Leave WordPress Playground details
runs-on: ubuntu-latest
permissions:
actions: write
continue-on-error: true
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}
steps:
- name: Save PR number
run: |
mkdir -p ./pr-number
echo ${{ github.event.number }} > ./pr-number/NR
- name: Upload PR number as artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: pr-number
path: pr-number/
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk