Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using npm run test:php results in errors related to cli #50690

Closed
carolinan opened this issue May 17, 2023 · 10 comments
Closed

Using npm run test:php results in errors related to cli #50690

carolinan opened this issue May 17, 2023 · 10 comments
Labels
[Tool] Env /packages/env [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable

Comments

@carolinan
Copy link
Contributor

Description

I am no longer able to use npm run test:php.
error tldr:

ℹ Starting 'composer update --no-interaction' on the cli container. 

service "cli" is not running container #1
✖ Command failed with exit code 1

Am I missing a command?

  • I am in the gutenberg directory.
  • I have run composer install and npm install, npm run build
  • Docker is running
  • wp-env is started

I am using MacOs 13.3.1
Docker Desktop 4.19.0
node v14.20.0 (npm v6.14.18)
Composer version 2.5.5

[email protected] test:php /Users/carolina/LocalSites/62/app/public/wp-content/plugins/gutenberg > npm-run-all lint:php test:unit:php

[email protected] prelint:php /Users/carolina/LocalSites/62/app/public/wp-content/plugins/gutenberg
wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer update --no-interaction

ℹ Starting 'composer update --no-interaction' on the cli container.

service "cli" is not running container #1
✖ Command failed with exit code 1
Command failed with exit code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prelint:php: wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer update --no-interaction
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prelint:php script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/carolina/.npm/_logs/2023-05-17T08_54_46_955Z-debug.log
ERROR: "lint:php" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:php: npm-run-all lint:php test:unit:php
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:php script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Step-by-step reproduction instructions

In your Gutenberg developer environment try to use the command npm run test:php

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan
Copy link
Contributor Author

OK, I discovered that using lint:php and test:unit:PHP as individual commands do work.

Pinging @ObliviousHarmony and @noahtallen in case it is related to #50408
But I am really not sure if it was something I did to mess up my environment...

@noahtallen
Copy link
Member

noahtallen commented May 17, 2023

Ah, I think I know the problem:

service "cli" is not running container #1

You need to run npx wp-env start first so that the environment is available. One of the changes we made is that these CLI environments are long-running now, so that when you run commands against them, they're a lot faster. (See more in #50007)

But previously, you could run these commands without wp-env having been started. I think we should consider this scenario more -- I wonder if people often use these composer related scripts without using the rest of the env?

@noahtallen noahtallen added [Tool] Env /packages/env [Type] Question Questions about the design or development of the editor. [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable and removed [Type] Question Questions about the design or development of the editor. labels May 17, 2023
@carolinan
Copy link
Contributor Author

Except wp-env is started.

@carolinan
Copy link
Contributor Author

I normally use Local, meaning I don't have either docker or wp-env running: but I have learned that I do need both to run different tests. And that this is the only time I start them.

@noahtallen
Copy link
Member

Hm, that's odd. To help troubleshoot, could you provide the output from npx wp-env --version and npx wp-env run cli ls, after running npx wp-env start?

For me, that looks like this:

npx wp-env --version
7.0.0
npx wp-env run cli ls
ℹ Starting 'ls' on the cli container.

index.php             wp-admin              wp-config.php         wp-links-opml.php     wp-settings.php
license.txt           wp-blog-header.php    wp-content            wp-load.php           wp-signup.php
readme.html           wp-comments-post.php  wp-cron.php           wp-login.php          wp-trackback.php
wp-activate.php       wp-config-sample.php  wp-includes           wp-mail.php           xmlrpc.php
✔ Ran `ls` in 'cli'. (in 0s 526ms)

And the output for the test command looks like this:

npx wp-env start
WordPress development site started at http://localhost:8888
WordPress test site started at http://localhost:8889
MySQL is listening on port 50066
MySQL for automated testing is listening on port 50067

 ✔ Done! (in 1s 915ms)
npm run test:php

> [email protected] test:php /Users/noahallen/source/gutenberg
> npm-run-all lint:php test:unit:php


> [email protected] prelint:php /Users/noahallen/source/gutenberg
> wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer update --no-interaction

ℹ Starting 'composer update --no-interaction' on the cli container.

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading nikic/php-parser (v4.15.4 => v4.15.5)
  - Upgrading phpunit/phpunit (9.6.7 => 9.6.8)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downloading nikic/php-parser (v4.15.5)
  - Downloading phpunit/phpunit (9.6.8)
  - Upgrading nikic/php-parser (v4.15.4 => v4.15.5): Extracting archive
  - Upgrading phpunit/phpunit (9.6.7 => 9.6.8): Extracting archive
Generating autoload files
45 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
✔ Ran `composer update --no-interaction` in 'cli'. (in 29s 121ms)

> [email protected] lint:php /Users/noahallen/source/gutenberg
> wp-env run --env-cwd="wp-content/plugins/gutenberg" cli composer run-script lint

ℹ Starting 'composer run-script lint' on the cli container.

> phpcs --standard=phpcs.xml.dist
...

Time: 20.94 secs; Memory: 56MB

✔ Ran `composer run-script lint` in 'cli'. (in 22s 332ms)

> [email protected] pretest:unit:php /Users/noahallen/source/gutenberg
> wp-env start

WordPress development site started at http://localhost:8888
WordPress test site started at http://localhost:8889
MySQL is listening on port 50066
MySQL for automated testing is listening on port 50067

 ✔ Done! (in 0s 753ms)

> [email protected] test:unit:php /Users/noahallen/source/gutenberg
> wp-env run --env-cwd="wp-content/plugins/gutenberg" tests-wordpress vendor/bin/phpunit -c phpunit.xml.dist --verbose

ℹ Starting 'vendor/bin/phpunit -c phpunit.xml.dist --verbose' on the tests-wordpress container.

[23-May-2023 17:41:32 UTC] PHP Warning:  Constant WP_DEBUG already defined in /wordpress-phpunit/wp-tests-config.php on line 214
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 9.6.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.0.28
Configuration: phpunit.xml.dist

...

WARNINGS!
Tests: 1197, Assertions: 2222, Warnings: 34.
✔ Ran `vendor/bin/phpunit -c phpunit.xml.dist --verbose` in 'tests-wordpress'. (in 24s 122ms)

@ObliviousHarmony
Copy link
Contributor

I have also had cases where Docker's logs show startup errors and give actionable content. You can do this using docker-compose -f $(npx wp-env install-path)/docker-compose.yml logs. If you look for output from the CLI container it might give an indication of what is preventing the container from starting. Lastly, it might be helpful to get the output of npx wp-env start --debug too.

@carolinan
Copy link
Contributor Author

Today I successfully ran the php tests twice. Then after some time of working on Gutenberg PR's, it stops working and I can't even stop or restart wp-env. When trying to stop it, it tells me there is no exit command.

I eventually restarted the mac and this is the result after the restart:

npx wp-env --version
7.0.0

npx wp-env run cli ls

ℹ Starting 'ls' on the cli container. 

index.php             wp-activate.php       wp-comments-post.php  wp-content            wp-links-opml.php     wp-mail.php           wp-trackback.php
license.txt           wp-admin              wp-config-sample.php  wp-cron.php           wp-load.php           wp-settings.php       xmlrpc.php
readme.html           wp-blog-header.php    wp-config.php         wp-includes           wp-login.php          wp-signup.php
✔ Ran `ls` in 'cli'. (in 0s 597ms)

Expand to see the log:

docker-compose -f $(npx wp-env install-path)/docker-compose.yml logs ✔ (in 0s 488ms)
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:57+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.3+maria~ubu2204 started.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.3+maria~ubu2204 started.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] Starting MariaDB 10.11.3-MariaDB-1:10.11.3+maria~ubu2204 source revision 0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0 as process 1
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Number of transaction pools: 1
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Using ARMv8 crc32 + pmull instructions
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Using liburing
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Completed initialization of buffer pool
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: 128 rollback segments are active.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: log sequence number 637472; transaction id 493
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] Plugin 'FEEDBACK' is disabled.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] Server socket created on IP: '0.0.0.0'.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] Server socket created on IP: '::'.
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] InnoDB: Buffer pool(s) load completed at 230524 10:21:58
345d5aef242893ab5faa7477058d99af-mysql-1  | 2023-05-24 10:21:58 0 [Note] mariadbd: ready for connections.
345d5aef242893ab5faa7477058d99af-mysql-1  | Version: '10.11.3-MariaDB-1:10.11.3+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.3+maria~ubu2204 started.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.3+maria~ubu2204 started.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] Starting MariaDB 10.11.3-MariaDB-1:10.11.3+maria~ubu2204 source revision 0bb31039f54bd6a0dc8f0fc7d40e6b58a51998b0 as process 1
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Number of transaction pools: 1
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Using ARMv8 crc32 + pmull instructions
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Using liburing
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Completed initialization of buffer pool
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: 128 rollback segments are active.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: log sequence number 34560472; transaction id 10806
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] Plugin 'FEEDBACK' is disabled.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] Server socket created on IP: '0.0.0.0'.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] Server socket created on IP: '::'.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] mariadbd: ready for connections.
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | Version: '10.11.3-MariaDB-1:10.11.3+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
345d5aef242893ab5faa7477058d99af-tests-mysql-1  | 2023-05-24 10:22:09 0 [Note] InnoDB: Buffer pool(s) load completed at 230524 10:22:09
345d5aef242893ab5faa7477058d99af-wordpress-1    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.4. Set the 'ServerName' directive globally to suppress this message
345d5aef242893ab5faa7477058d99af-wordpress-1    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.4. Set the 'ServerName' directive globally to suppress this message
345d5aef242893ab5faa7477058d99af-wordpress-1    | [Wed May 24 10:22:09.151189 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.56 (Debian) PHP/8.0.28 configured -- resuming normal operations
345d5aef242893ab5faa7477058d99af-wordpress-1    | [Wed May 24 10:22:09.151282 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
345d5aef242893ab5faa7477058d99af-tests-wordpress-1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.5. Set the 'ServerName' directive globally to suppress this message
345d5aef242893ab5faa7477058d99af-tests-wordpress-1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.5. Set the 'ServerName' directive globally to suppress this message
345d5aef242893ab5faa7477058d99af-tests-wordpress-1  | [Wed May 24 10:22:09.580215 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.56 (Debian) PHP/8.0.28 configured -- resuming normal operations
345d5aef242893ab5faa7477058d99af-tests-wordpress-1  | [Wed May 24 10:22:09.580247 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

@ObliviousHarmony
Copy link
Contributor

That's very strange @carolinan. What was the specific output stop gave you in the first place?

I eventually restarted the mac and this is the result after the restart:

This output looks like wp-env is working just fine. Was this the case after restarting? If so, maybe there's something wrong with your Docker?

Then after some time of working on Gutenberg PR's

This might be the cause. I don't think any of the breaking changes we've made would cause this aggressive a failure, but, it might be something to consider in terms of reproducibility.

@carolinan
Copy link
Contributor Author

Yes after restarting it worked fine, but I had to end my work day. I'll see what happens tomorrow.

@carolinan
Copy link
Contributor Author

I forgot about this issue. To confirm, I ran the commands from within the Gutenberg directory today without issues, so I am closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env [Type] Feedback Issues that relate purely to feedback on a feature that isn't necessarily actionable
Projects
None yet
Development

No branches or pull requests

3 participants