From 4708cb44b13f3872b9b04f473a6410bd6cf37021 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Wed, 5 Aug 2026 16:45:07 +0200 Subject: [PATCH 1/2] Build/Test Tools: Allow the reusable PHPUnit workflow to test another repository. A reusable workflow checks out the repository that calls it, so a caller that is not wordpress-develop cannot use this workflow and ends up maintaining a copy of it. Add optional `repository` and `ref` inputs so the checkout can point elsewhere, and an `overlay-artifact` input that unpacks a same-run artifact over the checkout, for callers whose test files are not part of the repository being tested. All three default to empty, so existing callers are unaffected: repository falls back to the calling repository, an empty ref is already checkout's own default and the overlay step is skipped. --- .../workflows/reusable-phpunit-tests-v3.yml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index 6a7f49fba468c..b9369690e5eff 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -13,6 +13,16 @@ on: required: false type: 'string' default: 'ubuntu-24.04' + repository: + description: 'The repository to check out and test. Defaults to the repository calling this workflow.' + required: false + type: 'string' + default: '' + ref: + description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.' + required: false + type: 'string' + default: '' php: description: 'The version of PHP to use, in the format of X.Y' required: true @@ -82,6 +92,11 @@ on: required: false type: string default: '' + overlay-artifact: + description: 'The name of a same-workflow artifact whose contents are unpacked over the checkout. Optional: for callers whose test files are not part of the repository being tested.' + required: false + type: string + default: '' secrets: CODECOV_TOKEN: description: 'The Codecov token required for uploading reports.' @@ -111,6 +126,7 @@ jobs: # Performs the following steps: # - Sets environment variables. # - Checks out the repository. + # - Unpacks the caller-provided overlay artifact over the checkout, if any. # - Downloads the prepared Gutenberg build provided by the calling workflow. # - Sets up Node.js. # - Sets up PHP. @@ -143,9 +159,21 @@ jobs: - name: Checkout repository uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref }} show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} persist-credentials: false + # If the caller specifies an overlay artifact then unpack it over the checkout. + - name: Download overlay artifact + if: inputs.overlay-artifact != '' + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + # Without a run ID, this action reads only from the caller's current workflow run. + name: ${{ inputs.overlay-artifact }} + path: . + digest-mismatch: error + # Branches >= 5.9 call this workflow at @trunk without the producer job, so they # pass no artifact. They skip this step and fall back to a per-job download. - name: Download prepared Gutenberg build From 5fdbb75e91d05c143968f299aa12b3e5892705b4 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Thu, 6 Aug 2026 15:44:46 +0200 Subject: [PATCH 2/2] Build/Test Tools: Allow the Gutenberg producer to prepare another repository. The producer checks out the commit that started the calling workflow run, so a caller preparing a build for a branch of another repository always got the wrong one. Add optional `repository` and `ref` inputs, plus an `artifact-name` input for callers that prepare several builds in a single run and would otherwise collide on one artifact name. Retry the download as well. On branches whose download.js predates the in-script retry the blob is streamed straight into tar in a single attempt, so an interrupted stream fails the job outright. All three inputs default to the current behaviour, so existing callers are unaffected. --- .../workflows/reusable-prepare-gutenberg.yml | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-prepare-gutenberg.yml b/.github/workflows/reusable-prepare-gutenberg.yml index c5e1f904a9680..7743a6fa466f9 100644 --- a/.github/workflows/reusable-prepare-gutenberg.yml +++ b/.github/workflows/reusable-prepare-gutenberg.yml @@ -6,6 +6,22 @@ name: Prepare Gutenberg build on: workflow_call: + inputs: + repository: + description: 'The repository to check out. Defaults to the repository calling this workflow.' + required: false + type: 'string' + default: '' + ref: + description: 'The branch, tag, or SHA to check out. Defaults to the commit that started the calling workflow run.' + required: false + type: 'string' + default: '' + artifact-name: + description: 'The name of the uploaded artifact. Callers preparing more than one build per run must give each a unique name.' + required: false + type: 'string' + default: 'gutenberg-build' outputs: gutenberg-sha: description: 'The immutable Gutenberg source SHA verified by this workflow.' @@ -29,8 +45,10 @@ jobs: - name: Checkout repository uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - # Resolve the Gutenberg ref from the exact commit that started this workflow run. - ref: ${{ github.sha }} + repository: ${{ inputs.repository || github.repository }} + # Resolve the Gutenberg ref from the exact commit that started this workflow run, + # unless the caller is preparing a build for a repository or branch of its own. + ref: ${{ inputs.ref || github.sha }} show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} persist-credentials: false @@ -42,7 +60,17 @@ jobs: - name: Download and verify Gutenberg build id: download run: | - node tools/gutenberg/download.js + # Branches whose download.js predates the in-script retry stream the blob straight + # into tar in a single attempt, so an interrupted stream fails the run outright. + for attempt in 1 2 3; do + node tools/gutenberg/download.js && break + if [ "$attempt" = 3 ]; then + echo "Gutenberg download failed after $attempt attempts." >&2 + exit 1 + fi + echo "Gutenberg download failed; retrying in 5 seconds..." + sleep 5 + done gutenberg_sha="$(tr -d '\n' < gutenberg/.gutenberg-hash)" if [[ ! "$gutenberg_sha" =~ ^[a-fA-F0-9]{40}$ ]]; then echo "Expected a 40-character Gutenberg SHA, received: $gutenberg_sha" >&2 @@ -53,7 +81,7 @@ jobs: - name: Upload Gutenberg build uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: gutenberg-build + name: ${{ inputs.artifact-name }} path: gutenberg/ if-no-files-found: error include-hidden-files: true