Skip to content

Build/Test Tools: Allow the reusable PHPUnit workflow to test another repository. - #12862

Open
lucatume wants to merge 5 commits into
WordPress:trunkfrom
lucatume:reusable-phpunit-tests-extended-support
Open

Build/Test Tools: Allow the reusable PHPUnit workflow to test another repository.#12862
lucatume wants to merge 5 commits into
WordPress:trunkfrom
lucatume:reusable-phpunit-tests-extended-support

Conversation

@lucatume

@lucatume lucatume commented Aug 5, 2026

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/65964

A reusable workflow checks out the repository that calls it, so reusable-phpunit-tests-v3.yml can only test a wordpress-develop checkout made by a wordpress-develop workflow run. A repository that wants to run this suite against a wordpress-develop checkout with its own test files layered in has no way to call it, and keeps a copy of the workflow instead. That copy then inherits none of the fixes that land here.

Three optional inputs remove the need for one: repository and ref for the checkout, and overlay-artifact, which unpacks a same-run artifact over the checkout for callers whose test files aren't part of the repository being tested.

What to check

All three inputs default to an empty string, so no existing caller changes behaviour:

  • repository: ${{ inputs.repository || github.repository }} falls back to github.repository, which is actions/checkout's own default.
  • ref: '' is already actions/checkout's default.
  • the overlay step is guarded by if: inputs.overlay-artifact != ''.

phpunit-tests.yml, test-coverage.yml and every 5.9+ branch calling this workflow at @trunk pass none of them.

The overlay is downloaded after the checkout and before the Gutenberg build, so a caller can't use it to swap out a prepared Gutenberg build. It reads through the same same-run artifact mechanism as gutenberg-artifact, so it can only reach artifacts from the run that called the workflow.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: analysing the constraint and proposing the diff; I applied and reviewed the change.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props lucatume.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@lucatume
lucatume marked this pull request as draft August 5, 2026 15:04
@lucatume
lucatume force-pushed the reusable-phpunit-tests-extended-support branch from 4a3955e to 5fdbb75 Compare August 6, 2026 13:45
@lucatume
lucatume force-pushed the reusable-phpunit-tests-extended-support branch from 5fdbb75 to 7512776 Compare August 26, 2026 09:07
@lucatume
lucatume marked this pull request as ready for review August 26, 2026 09:07
@lucatume
lucatume force-pushed the reusable-phpunit-tests-extended-support branch from 7512776 to ec2e88b Compare August 31, 2026 08:12
… 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.

Derive the prepared Gutenberg artifact name from `ref` as well. Every
branch in a run shares one artifact namespace, so a caller testing
several branches needs one build per branch. The producer composes the
same name from its own `ref`, so the name is never passed between them
and `gutenberg-artifact` stays the boolean it became in [63162].

All inputs 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 keeps the original `gutenberg-build`
name, and the overlay step is skipped.
…ository.

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.

Name the uploaded artifact after the ref it was built from. Every branch
in a run shares one artifact namespace, so a caller preparing several
builds would otherwise collide on a single name. The PHPUnit consumer
composes the same name from its own `ref`, so the name is never passed
between them.

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.

Both inputs default to the current behaviour, so existing callers are
unaffected: an empty `ref` keeps the original `gutenberg-build` name.
@lucatume
lucatume force-pushed the reusable-phpunit-tests-extended-support branch from ec2e88b to ea2e265 Compare August 31, 2026 09:10
Both workflows compose the Gutenberg artifact name from `ref`, and
upload-artifact rejects a name holding a slash or any of : < > | * ? or
a double quote. A `refs/heads/trunk` or `feature/x` value fails the
upload, after the download has already run.

Workflow expressions have no string replacement, so the two sides cannot
sanitise the value independently and still agree on a name. State the
constraint on both inputs instead. `reusable-test-core-build-process`
avoids the problem the other way, naming its ZIP after a pull request
number or a SHA.

Claude-Session: https://claude.ai/code/session_011piBrz5J1ZWLqwuCF2YYgG
The new `repository` input is only half a location. Without a `ref` the
PHPUnit workflow checks out that repository's default branch, so a job
labelled for one branch tests another and still reports green. The
Gutenberg producer fails instead, but on a commit SHA that says nothing
about the missing input.

Fail both up front, before the checkout, rather than leaving the two
workflows to diverge on how they mishandle the same gap.

Claude-Session: https://claude.ai/code/session_011piBrz5J1ZWLqwuCF2YYgG
Three outer attempts around the three that download.js now makes itself
is nine downloads of up to two minutes, well past the ten minutes the
job is allowed. A persistently failing download had the job killed on
the timeout instead of reporting why it gave up.

Retry once, and raise the timeout to cover the two attempts that remain.
Branches whose download.js predates the in-script retry still get the
second try they were given this for.

Claude-Session: https://claude.ai/code/session_011piBrz5J1ZWLqwuCF2YYgG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant