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

Remove PHPUnit and Composer packages #50408

Merged
merged 15 commits into from
May 8, 2023
Merged

Remove PHPUnit and Composer packages #50408

merged 15 commits into from
May 8, 2023

Conversation

ObliviousHarmony
Copy link
Contributor

@ObliviousHarmony ObliviousHarmony commented May 5, 2023

What?

I have removed the composer and phpunit Docker services in favor of globally installing composer and phpunit in the wordpress, cli, tests-wordpress, and tests-cli containers.

Why?

The current approach comes with a few compatibility issues:

How?

This pull request removes the composer and phpunit services and installs the respective commands globally. In place of npx wp-env run composer you can now run npx wp-env run cli composer. One caveat is that the composer service used to default to the directory containing the config file. Instead, since it defaults to /var/www/html, they will need to run the command from the correct directory manually.

As an aside, I also got sudo installed in the CLI container so you have root access available in all of the containers. This is potentially useful for people who might install additional services or packages or what have you in a setup script.

Testing Instructions

  1. Run npx wp-env destroy.
  2. Run npx wp-env start --update.
  3. Run npx wp-env run cli bash.
  4. Check out composer and phpunit and confirm they run.
  5. Do the same in the wordpress, tests-wordpress, and tests-cli containers.
  6. Run npm run format:php and confirm that it works as expected.
  7. Run npm run lint:php and confirm that it works as expected.

},
volumes: {
...( ! config.env.development.coreSource && { wordpress: {} } ),
...( ! config.env.tests.coreSource && { 'tests-wordpress': {} } ),
mysql: {},
'mysql-test': {},
'phpunit-uploads': {},
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why I had to add this in the first place, but I can't remember 🙃

package.json Outdated Show resolved Hide resolved
@@ -318,9 +318,9 @@
"test:unit:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ",
"test:unit:profile": "wp-scripts --cpu-prof test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ",
"pretest:unit:php": "wp-env start",
"test:unit:php": "wp-env run tests-wordpress /var/www/html/wp-content/plugins/gutenberg/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist --verbose",
"test:unit:php": "wp-env run --env-cwd=\"wp-content/plugins/gutenberg\" tests-wordpress vendor/bin/phpunit -c phpunit.xml.dist --verbose",
Copy link
Member

Choose a reason for hiding this comment

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

so much clearer 😁

packages/env/lib/init-config.js Outdated Show resolved Hide resolved
packages/env/lib/init-config.js Show resolved Hide resolved
ObliviousHarmony and others added 11 commits May 5, 2023 20:31
This commit removes these containers because they don't
work the way you'd expect them to anymore. It also adds
Composer and PHPUnit globally to all of the containers so
that people can support the workflows these containers
used to.
Co-authored-by: Noah Allen <noahtallen@gmail.com>
@gziolo gziolo added the [Tool] Env /packages/env label May 6, 2023
Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

To make the migration easier, I'd like to add a clearer messaging when the containers don't exist. Since running npx wp-env run phpunit ... will fail anyways, I think we should add a helpful message to recommend using npx wp-env run cli phpunit instead, since not everyone will read the changelog

@ObliviousHarmony
Copy link
Contributor Author

That's a good idea @noahtallen. I've also gone ahead and added better error messaging for invalid commands since Docker's message is a bit obtuse.

packages/env/lib/commands/run.js Outdated Show resolved Hide resolved
packages/env/lib/commands/run.js Outdated Show resolved Hide resolved
@noahtallen noahtallen added the [Type] Enhancement A suggestion for improvement. label May 8, 2023
Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

This is looking good to me!

Given that:

  • We don't really document the phpunit & composer options already.
  • Both containers have been broken recently.
  • At least one of the containers has been broken for a while on M* macs.
  • It's confusing to have multiple containers that aren't much different from each other.

This makes a lot of sense :)

I also like how this makes the composer and phpunit globally available in different containers without any extra work, which hopefully makes at least PHPUnit a lot easier to set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants