Skip to content

Commit 4a3955e

Browse files
committed
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.
1 parent b00336a commit 4a3955e

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ on:
1313
required: false
1414
type: 'string'
1515
default: 'ubuntu-24.04'
16+
repository:
17+
description: 'The repository to check out and test. Defaults to the repository calling this workflow.'
18+
required: false
19+
type: 'string'
20+
default: ''
21+
ref:
22+
description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.'
23+
required: false
24+
type: 'string'
25+
default: ''
1626
php:
1727
description: 'The version of PHP to use, in the format of X.Y'
1828
required: true
@@ -82,6 +92,11 @@ on:
8292
required: false
8393
type: string
8494
default: ''
95+
overlay-artifact:
96+
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.'
97+
required: false
98+
type: string
99+
default: ''
85100
secrets:
86101
CODECOV_TOKEN:
87102
description: 'The Codecov token required for uploading reports.'
@@ -111,6 +126,7 @@ jobs:
111126
# Performs the following steps:
112127
# - Sets environment variables.
113128
# - Checks out the repository.
129+
# - Unpacks the caller-provided overlay artifact over the checkout, if any.
114130
# - Downloads the prepared Gutenberg build provided by the calling workflow.
115131
# - Sets up Node.js.
116132
# - Sets up PHP.
@@ -143,9 +159,21 @@ jobs:
143159
- name: Checkout repository
144160
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
145161
with:
162+
repository: ${{ inputs.repository || github.repository }}
163+
ref: ${{ inputs.ref }}
146164
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
147165
persist-credentials: false
148166

167+
# If the caller specifies an overlay artifact then unpack it over the checkout.
168+
- name: Download overlay artifact
169+
if: inputs.overlay-artifact != ''
170+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
171+
with:
172+
# Without a run ID, this action reads only from the caller's current workflow run.
173+
name: ${{ inputs.overlay-artifact }}
174+
path: .
175+
digest-mismatch: error
176+
149177
# Branches >= 5.9 call this workflow at @trunk without the producer job, so they
150178
# pass no artifact. They skip this step and fall back to a per-job download.
151179
- name: Download prepared Gutenberg build

0 commit comments

Comments
 (0)