Make WordPress Core

Opened 7 months ago

Last modified 3 months ago

#57189 new defect (bug)

The PHP tests initialize very slowly in wp-env

Reported by: azaozz's profile azaozz Owned by:
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:


When run in wp-env (Docker), the PHP tests take very long time (over 30 seconds) to initialize. This is especially annoying/time wasting when running them multiple times.

Not sure if Docker or Composer is the cause, but I see this:

> WordPress@6.2.0 test:php /dev/wp/trunk
> node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit

Creating trunk_php_run ... done
.................................... (waits here for about 30-35 seconds)
Loading composer repositories with package information
Info from #StandWithUkraine
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
25 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Creating trunk_php_run ... done
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
..... (rest of the PHPUnit output)

The problem seems to be that Composer is run every time to re-check the dependencies, i.e. the script there does the equivalent of npm i every time before it starts PHPUnit. I understand the desire to keep things updated, but this is not productive.

Change History (4)

#1 @azaozz
7 months ago

Seems an easy fix here would be to split the "Composer install" part from the actual "run PHPUnit" part in npm run test:php. Something like:

"test:php-i": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit",
"test:php": "node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit",

A better way would be to have an equivalent of a lock file and run Composer only once per week.

Last edited 7 months ago by azaozz (previous) (diff)

#2 @azaozz
7 months ago

Another thing is that if a PHPUnit test fails, the (npm/Docker) script fails too. Seems not a big problem but needs fixing nevertheless. Error is:

    throw err;

Error: Command failed: docker-compose run php ./vendor/bin/phpunit

This ticket was mentioned in Slack in #core by costdev. View the logs.

3 months ago

#4 @hellofromTonya
3 months ago

  • Milestone changed from 6.2 to 6.3

Given that RC1 is fast approaching (next week) and this needs more discussion, moving it to 6.3. But if can be committed at any time when ready.

Note: See TracTickets for help on using tickets.