Skip to content

Try: Build once for PHP Unit.#12649

Draft
peterwilsoncc wants to merge 13 commits into
WordPress:trunkfrom
peterwilsoncc:try/phpunit-building-once
Draft

Try: Build once for PHP Unit.#12649
peterwilsoncc wants to merge 13 commits into
WordPress:trunkfrom
peterwilsoncc:try/phpunit-building-once

Conversation

@peterwilsoncc

@peterwilsoncc peterwilsoncc commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This is a POC to build WordPress once for use during the PHP Unit workflow.

  1. Create and upload an artifact during a build step. Check for git change in this step once only.
  2. Use the generated artifact for running the tests.

Choosing a PR to trunk at random, the machine time for PHPUnit is dropping by about 3 hours. As trunk runs additional tests, this will save additional time there.

A space checkout is retained as that will set up the GHA environment variables needed for the unit test suite to determine if tests that target only trunk are, in fact, targetting trunk. It's also needed for the actions that report back to WP.org.

Questions:

  • The new sniff added for GH Actions is reporting there is a cache pollution risk involved with this change. I am not sure how serious that is.
  • Is it preferable to use an artifact or a cache?
  • Is this a complete non-starter?

Risks/issues:

  • Re-running workflows after the artifact is deleted will fail
  • The artifact is ~250M and could lead to dropping of other data in the WordPress org.
  • Please add more in the comments
  • I've put in a test with all the github environment variables, as some of these are defined on

Trac ticket:

Use of AI Tools

AI assistance: Yes
Tool(s): VS Code/GitHub Copilot
Model(s): GPT-5.3-Codex
Used for: Most of it as this is a POC.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copilot AI review requested due to automatic review settings July 23, 2026 01:39
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the PHPUnit GitHub Actions workflow to build WordPress once, upload the build as an artifact, and let the matrix test jobs reuse that artifact to avoid repeated builds.

Changes:

  • Adds a dedicated build-wordpress job that builds and uploads a wordpress-build artifact.
  • Extends the reusable PHPUnit workflow with an input to optionally download/unzip the build artifact.
  • Wires the PHPUnit matrix jobs to depend on the build job and (in most cases) enable artifact reuse.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/reusable-phpunit-tests-v3.yml Adds an input and conditional logic to download/unzip a prebuilt WordPress artifact instead of rebuilding.
.github/workflows/phpunit-tests.yml Adds a build job that uploads a build artifact and updates test jobs to depend on it and enable reuse.
Comments suppressed due to low confidence (2)

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

  • Skipping Set up PHP when the build artifact is available breaks the subsequent Composer install (and can leave vendor/bin/phpunit missing for the test runs). The build artifact only addresses built JS/CSS; the PHP/Composer toolchain is still required per test job.
      - name: Set up PHP
        if: ${{ ! inputs.wordpress-build-artifact-available }}
        uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2

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

  • With wordpress-build-artifact-available enabled, this skips installing Composer dependencies, but the test commands invoke ./vendor/bin/phpunit. Unless vendor/ is guaranteed to be present in the workspace, this will fail.
      # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
      # passing a custom cache suffix ensures that the cache is flushed at least once per week.
      - name: Install Composer dependencies
        if: ${{ ! inputs.wordpress-build-artifact-available }}
        uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 137 to 139
- name: Checkout repository
if: ${{ ! inputs.wordpress-build-artifact-available }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Comment on lines +83 to +85
- name: Create ZIP of built files
run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

Comment thread .github/workflows/phpunit-tests.yml Outdated
Comment on lines 183 to 186
uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
needs: [ build-wordpress ]
permissions:
contents: read
Copilot AI review requested due to automatic review settings July 23, 2026 01:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (4)

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

  • When inputs.wordpress-build-artifact-available is true, this step is skipped, but later steps still run PHPUnit via ./vendor/bin/phpunit (see the Run PHPUnit tests step). Since vendor/ is not in the repo by default, skipping PHP setup will prevent Composer dependencies from being installed correctly for the job.

This issue also appears on line 160 of the same file.

      - name: Set up PHP
        if: ${{ ! inputs.wordpress-build-artifact-available }}
        uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
        with:
          php-version: '${{ inputs.php }}'
          coverage: none

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

  • vendor/bin/phpunit is invoked later in this workflow, but Composer dependencies are not installed when wordpress-build-artifact-available is true. The build artifact created in phpunit-tests.yml only runs npm ci/build and does not generate vendor/, so the test job will fail without running this step.
      - name: Install Composer dependencies
        if: ${{ ! inputs.wordpress-build-artifact-available }}
        uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
        with:
          custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")

.github/workflows/phpunit-tests.yml:186

  • This job now depends on build-wordpress, but it never enables the new artifact path (wordpress-build-artifact-available: true). As a result it will still do its own checkout/npm install/build inside the reusable workflow (duplicating work) while also waiting for the separate build job to complete.
  test-with-mariadb:
    name: PHP ${{ matrix.php }}
    uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
    needs: [ build-wordpress ]
    permissions:
      contents: read

.github/workflows/phpunit-tests.yml:85

  • The artifact zip is created from the entire working directory after npm ci, which will include node_modules/ and any other build-time artifacts. With the large PHPUnit matrix, every downstream job will download this ZIP, which can significantly increase workflow time and artifact storage/transfer. Consider limiting the artifact contents to only what downstream jobs need (e.g., built assets) and letting each job restore/install dependencies via cache, or otherwise pruning large directories before zipping.
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

Copilot AI review requested due to automatic review settings July 23, 2026 02:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (4)

.github/workflows/phpunit-tests.yml:173

  • wordpress-build-artifact-available is passed into the reusable workflow, but reusable-phpunit-tests-v4.yml does not declare this as a workflow_call input. This will cause the calling job to fail workflow validation with an "Unexpected input" error.

This issue also appears in the following locations of the same file:

  • line 272
  • line 304
  • line 366
      memcached: ${{ matrix.memcached }}
      phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
      tests-domain: ${{ matrix.tests-domain }}
      report: ${{ matrix.report || false }}

.github/workflows/phpunit-tests.yml:274

  • wordpress-build-artifact-available is passed into the reusable workflow, but reusable-phpunit-tests-v4.yml does not declare this as a workflow_call input. This will cause the calling job to fail workflow validation with an "Unexpected input" error.
      report: false

  #

.github/workflows/phpunit-tests.yml:308

  • wordpress-build-artifact-available is passed into the reusable workflow, but reusable-phpunit-tests-v4.yml does not declare this as a workflow_call input. This will cause the calling job to fail workflow validation with an "Unexpected input" error.
      db-version: ${{ matrix.db-version }}
      phpunit-test-groups: ${{ matrix.phpunit-test-groups }}

  #
  # Runs unit tests for forks.

.github/workflows/phpunit-tests.yml:370

  • wordpress-build-artifact-available is passed into the reusable workflow, but reusable-phpunit-tests-v4.yml does not declare this as a workflow_call input. This will cause the calling job to fail workflow validation with an "Unexpected input" error.
      phpunit-test-groups: ${{ matrix.phpunit-test-groups || '' }}

  slack-notifications:
    name: Slack Notifications
    uses: ./.github/workflows/slack-notifications.yml

Comment on lines +140 to +145
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
cache: npm

Comment on lines +101 to +118
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Sets up Node.js.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Installs npm dependencies
# - Logs general debug information about the runner.
# - Logs Docker debug information (about the Docker installation within the runner).
# - Starts the WordPress Docker container.
# - Logs the running Docker containers.
# - Logs debug information about what's installed within the WordPress Docker containers.
# - Install WordPress within the Docker container.
# - Run the PHPUnit tests.
# - Upload the code coverage report to Codecov.io.
# - Ensures version-controlled files are not modified or deleted.
# - Checks out the WordPress Test reporter repository.
# - Submit the test results to the WordPress.org host test results.
Copilot AI review requested due to automatic review settings July 23, 2026 02:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

.github/workflows/reusable-phpunit-tests-v4.yml:154

  • This workflow no longer installs Composer dependencies, but it still runs PHPUnit from ./vendor/bin/phpunit. Since vendor/ is not in the repository, the test commands will fail with "No such file or directory" unless Composer dependencies are installed in this job (as was done in reusable-phpunit-tests-v3.yml).
      - name: Set up Node.js
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version-file: '.nvmrc'
          cache: npm

      - name: General debug information
        run: |
          npm --version
          node --version
          curl --version
          git --version
          composer --version
          locale -a

.github/workflows/reusable-phpunit-tests-v4.yml:105

  • The "Performs the following steps" list is now out of sync with what the workflow actually does (it no longer checks out the repo, builds WordPress, installs npm deps, or runs a git diff check). Updating this comment block will make the workflow easier to maintain.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.

Comment on lines +57 to +63
build-wordpress:
name: Build WordPress
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 20

Copilot AI review requested due to automatic review settings July 23, 2026 02:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

.github/workflows/phpunit-tests.yml:88

  • The build artifact is created by zipping the entire repository root (".") after npm ci, which will include ignored directories like node_modules/ (see .gitignore:20) and significantly increase artifact size and download/unzip time for every matrix job. It also makes the artifact (and thus the test jobs) implicitly OS/arch-specific.
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

.github/workflows/reusable-phpunit-tests-v4.yml:255

  • The header comment lists “Ensures version-controlled files are not modified or deleted”, but the workflow no longer performs that check (it existed in v3). Reintroducing the git diff --exit-code guard helps catch unexpected file changes during env setup/tests.

      - name: Upload test coverage report to Codecov
        if: ${{ inputs.coverage-report }}
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml
          flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
          fail_ci_if_error: true

Comment on lines +149 to +154
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
cache: npm

Comment on lines +132 to +140
- name: Sparse checkout repository metadata
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
sparse-checkout: |
.github

Copilot AI review requested due to automatic review settings July 23, 2026 02:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (4)

.github/workflows/reusable-phpunit-tests-v4.yml:118

  • The job header comment lists steps (PHP setup, Composer install, npm ci, build, and a post-test git diff) that are no longer performed in this workflow. This makes the workflow misleading to maintainers and reviewers.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.
  # - Installs Composer dependencies.
  # - Installs npm dependencies
  # - Logs general debug information about the runner.
  # - Logs Docker debug information (about the Docker installation within the runner).
  # - Starts the WordPress Docker container.
  # - Logs the running Docker containers.
  # - Logs debug information about what's installed within the WordPress Docker containers.
  # - Install WordPress within the Docker container.
  # - Run the PHPUnit tests.
  # - Upload the code coverage report to Codecov.io.
  # - Ensures version-controlled files are not modified or deleted.
  # - Checks out the WordPress Test reporter repository.
  # - Submit the test results to the WordPress.org host test results.

.github/workflows/reusable-phpunit-tests-v4.yml:136

  • The sparse checkout into "repo-metadata" is currently unused (no later step references that path), and it also means the workspace doesn’t have a .git directory. That prevents restoring the post-test "git diff --exit-code" guard that exists in reusable-phpunit-tests-v3.yml:271, and it makes it harder to debug CI failures locally. Consider doing a normal checkout into the workspace root, and unzip with overwrite enabled.
      - name: Sparse checkout repository metadata
        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          path: 'repo-metadata'
          fetch-depth: 1

.github/workflows/reusable-phpunit-tests-v4.yml:257

  • reusable-phpunit-tests-v3.yml includes a post-test "git diff --exit-code" check (v3:271) to ensure tests/build steps don’t modify tracked files. This workflow drops that guard. If you switch back to a normal checkout (so .git exists), you can restore the check just before bringing in the external test-runner repo.
      - name: Checkout the WordPress Test Reporter

.github/workflows/phpunit-tests.yml:88

  • The ZIP artifact is created from the entire workspace ("zip -r ... ."), which will also include large, generated directories like node_modules/ from the build step. Because every matrix job downloads/unzips this artifact, this can significantly increase CI time and bandwidth and risks hitting artifact size limits.
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

Comment thread .github/workflows/reusable-phpunit-tests-v4.yml
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 23, 2026 04:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

.github/workflows/reusable-phpunit-tests-v4.yml:105

  • The step list in this header comment is now inaccurate: the workflow no longer checks out the full repository or sets up PHP / installs Composer + npm dependencies (it downloads and unzips a prebuilt artifact instead). Please update the comment to match the actual steps so future changes don’t rely on stale guidance.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.

.github/workflows/reusable-phpunit-tests-v4.yml:136

  • The “Sparse checkout repository metadata” step checks out .github into repo-metadata/, but nothing in this workflow references repo-metadata afterward. This adds time and complexity without affecting the job outcome.
      - name: Sparse checkout repository metadata
        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          path: 'repo-metadata'
          fetch-depth: 1

.github/workflows/phpunit-tests.yml:87

  • zip -r wordpress-build.zip . will include everything in the workspace after npm ci and npm run build:dev, including node_modules/ (and any other build byproducts). That will likely create a very large artifact that must be downloaded/unzipped by every matrix job, which can negate the benefit of “build once” and may hit artifact size/time limits.
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

Comment on lines +247 to +255
- name: Upload test coverage report to Codecov
if: ${{ inputs.coverage-report }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml
flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
fail_ci_if_error: true

Copilot AI review requested due to automatic review settings July 23, 2026 04:27
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (6)

tests/phpunit/tests/peter-is-testing-this-pr.php:21

  • This test will fail when the PHPUnit suite is run outside GitHub Actions (e.g., locally or on other CI) because it hard-requires GITHUB_* env vars. To keep the core test suite portable, skip these assertions when not running in GitHub Actions.
	public function test_github_environment_variable_defined( $variable, $expected_value = null ) {
		$variable_value = getenv( $variable );
		$this->assertNotFalse( $variable_value, "Environment variable $variable is not defined." );

		if ( $expected_value !== null ) {
			$this->assertSame( $expected_value, $variable_value, "Environment variable $variable does not have the expected value." );
		}

tests/phpunit/tests/peter-is-testing-this-pr.php:46

  • Several variables asserted here are only set for specific event types (e.g., GITHUB_HEAD_REF/GITHUB_BASE_REF are only present for pull_request), and expecting GITHUB_EVENT_NAME to always be "pull_request" will break push/schedule runs of .github/workflows/phpunit-tests.yml. Consider only asserting PR-specific variables when the event is actually a PR, and avoid hard-coding the event name.
	public function data_github_environment_variable_defined() {
		return array(
			array( 'GITHUB_ACTIONS', 'true' ),
			array( 'GITHUB_WORKFLOW' ),
			array( 'GITHUB_RUN_ID' ),
			array( 'GITHUB_RUN_NUMBER' ),
			array( 'GITHUB_JOB' ),
			array( 'GITHUB_ACTION' ),
			array( 'GITHUB_ACTOR' ),
			array( 'GITHUB_REPOSITORY' ),
			array( 'GITHUB_EVENT_NAME', 'pull_request' ),
			array( 'GITHUB_EVENT_PATH' ),
			array( 'GITHUB_WORKSPACE' ),
			array( 'GITHUB_SHA' ),
			array( 'GITHUB_REF' ),
			array( 'GITHUB_HEAD_REF' ),
			array( 'GITHUB_BASE_REF' ),
		);

.github/workflows/reusable-phpunit-tests-v4.yml:107

  • The step list in this job comment no longer matches what the workflow actually does (it no longer checks out the full repo, sets up PHP on the runner, installs Composer deps, runs npm ci, builds WordPress, or runs git diff). Please update the comment so future edits/debugging aren’t based on incorrect documentation.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.
  # - Installs Composer dependencies.
  # - Installs npm dependencies

.github/workflows/reusable-phpunit-tests-v4.yml:162

  • This workflow invokes php ./vendor/bin/phpunit, but it no longer installs Composer dependencies on the runner (and the new build job only runs npm ci/npm run build:dev, so vendor/ is unlikely to exist after unzipping the artifact). Re-introduce a Composer install step (or ensure vendor/ is included in the artifact) so the PHPUnit binary is available.
      - name: Set up Node.js
        uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version-file: '.nvmrc'
          cache: npm

      - name: General debug information
        run: |
          npm --version
          node --version
          curl --version
          git --version
          locale -a

.github/workflows/phpunit-tests.yml:88

  • zip -r wordpress-build.zip . will package the entire working directory after npm ci, including node_modules/, which can make the artifact very large and slow to upload/download across every matrix job. Consider excluding node_modules/ and re-installing with the existing npm cache in each test job, or otherwise limiting the artifact contents to only what the reusable PHPUnit workflow needs.
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

.github/workflows/phpunit-tests.yml:63

  • build-wordpress currently runs unconditionally for any event that triggers the workflow. In forks, this means it can run on push events even though all downstream test jobs are skipped (their if: only allows PRs for non-WordPress repos). Consider adding an if: to align the build job with the conditions under which test jobs will actually run.
  build-wordpress:
    name: Build WordPress
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    timeout-minutes: 20

Comment on lines +3 to +6
/**
* Peter is testing this PR.
*/
class Tests_Peter_Is_Testing_This_PR extends WP_UnitTestCase {
Copilot AI review requested due to automatic review settings July 23, 2026 04:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

tests/phpunit/tests/peter-is-testing-this-pr.php:44

  • GITHUB_EVENT_NAME is not always pull_request (this workflow also runs on push and schedule), so this assertion will fail in CI for non-PR runs.
			array( 'GITHUB_BASE_REF' ),
			array( 'GITHUB_ENV' ),
			array( 'GITHUB_EVENT_NAME', 'pull_request' ),
			array( 'GITHUB_EVENT_PATH' ),

.github/workflows/reusable-phpunit-tests-v4.yml:105

  • The step list in this header comment is now inaccurate (it mentions checking out the full repo, setting up PHP, and installing Composer/npm deps). In v4 the job downloads and unzips a pre-built artifact instead, so the comment should be updated to reflect the actual steps.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.

.github/workflows/phpunit-tests.yml:87

  • zip -r wordpress-build.zip . will package the entire working directory, including node_modules/ produced by npm ci. With this workflow's large test matrix, repeatedly uploading/downloading a huge artifact can be slower and risks hitting artifact size/time limits. The repo already uses a narrower build artifact elsewhere (e.g. .github/workflows/reusable-test-core-build-process.yml:125-128 zips only build/).
      - name: Create ZIP of built files
        run: zip -q -r wordpress-build.zip . -x '.git/*' 'wordpress-build.zip'

Comment on lines +17 to +24
public function test_github_environment_variable_defined( $variable, $expected_value = null ) {
$variable_value = getenv( $variable );
$this->assertNotFalse( $variable_value, "Environment variable $variable is not defined." );

if ( $expected_value !== null ) {
$this->assertSame( $expected_value, $variable_value, "Environment variable $variable does not have the expected value." );
}
}
Comment on lines +132 to +141
- name: Sparse checkout repository metadata
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
path: 'repo-metadata'
fetch-depth: 1
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
sparse-checkout: |
.github

Copilot AI review requested due to automatic review settings July 23, 2026 05:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

.github/workflows/reusable-phpunit-tests-v4.yml:108

  • The step list in this job header is out of sync with what the workflow actually does (it no longer checks out the full repo, sets up PHP, installs npm deps, or builds). This makes the workflow harder to maintain because readers will assume those steps still exist.
  # Performs the following steps:
  # - Sets environment variables.
  # - Checks out the repository.
  # - Sets up Node.js.
  # - Sets up PHP.
  # - Installs Composer dependencies.
  # - Installs npm dependencies
  # - Logs general debug information about the runner.

.github/workflows/phpunit-tests.yml:62

  • build-wordpress currently runs unconditionally, but all the downstream test jobs are gated to WordPress/* repos (and PRs). On forks/non-WordPress repos this will spend CI time building and uploading a large artifact even though no test jobs run. Consider applying the same if: gate used by the matrix jobs.
  build-wordpress:
    name: Build WordPress
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    timeout-minutes: 20

.github/workflows/phpunit-tests.yml:94

  • Uploading a ~250MB artifact on every run can put noticeable pressure on org storage/retention. If the intent is strictly intra-run reuse, set a short artifact retention period to reduce storage footprint.
      - name: Upload ZIP as a GitHub Actions artifact
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: wordpress-build
          path: wordpress-build.zip
          if-no-files-found: error

Comment on lines +241 to +244
- name: Run GitHub Actions environment variable tests (do not include this in any merge)
if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c "${PHPUNIT_CONFIG}" --group this-should-never-be-committed-to-trunk-but-some-of-it-might-be-helpful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants