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
Update PHPUnit tests infrastructure #1065
base: trunk
Are you sure you want to change the base?
Conversation
d8140a4
to
60fe029
Compare
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Failing tests are unrelated. It wasn't discovered previously as something was going wrong in the |
@felixarntz @westonruter Should I skip the failing tests and fix them in a new follow-up PR? Seems like to fix this we need to make some changes in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thelovekesh There is a lot of changes to review here. I'd like for us to take a step back.
This PR makes several changes, and I'm not sure all of them are justified. It would be great if you could provide more context on what your goal is with this PR and why/how those changes help us.
For instance, I see the tests are being moved to the individual plugin folders. That generally makes sense to me. However, I also see the wp-env
setup is replaced with install-wp-tests.sh
. That to me doesn't make sense because having that install-wp-tests.sh
script here is far worse from a maintenance perspective than using a setup like wp-env
which is supposed to "just work".
Let's discuss that more. Generally, I would prefer that we make one change at a time, to avoid such very difficult-to-review PRs.
@felixarntz Most of the changes are related to moving test files from
There are many reasons to not use
If that's the case, I would love to break this PR into chunks. Just LMK your opinion. |
If contributors have a blessed way to run tests without wp-env this may prove advantageous given many developers now are unable to use Docker given the licensing change to Docker Desktop. |
@thelovekesh @westonruter While there are certainly different ways to set up CI workflows and tests, I feel quite strongly about using
So while based on the above, I'm opposed to using something custom in favor of |
TBH I don't think so after what's discovered in #1013 (comment) and that's why
And they can use it locally even for running their tests. But in CI, I don't think it will affect any user workflow. Rather it will act as a source of truth that tests are being run as expected in an expected environment. In the current setup, I don't think we are even able to validate the environment configuration apart from PHP version. |
I was referring to the development environment generally "just working", as in not requiring any external setup that is not part of the repository's documentation. I completely get your point though, but I would argue this kind of thing may happen and we can try to fix it upstream in https://github.com/WordPress/gutenberg/tree/trunk/packages/env.
I'm not sure I understand what you mean. As far as I know, we can customize how |
I referred to the logging of environment details like PHP, WP, and PHPUnit versions.
And how do we identify such problems? If we hadn't run our test suite with WP Tests setup we wouldn't have identified this issue in the first place. WP Tests setup is also from the WP ecosystem and used widely(just came to know site-kit also uses install-wp-tests 🤪). Maybe we can bring this discussion to #973 and discuss it widely? |
@thelovekesh We can consider enhancing Regarding Overall, I completely agree this should be discussed elsewhere. Though I think replacing |
We can always contribute upstream to make it a better tool for local development while I think fitting it into CI is a bit overkill, and I would say
I think this is also the case with As mentioned above, to discuss it more widely I have opened #1085 and I will limit the scope of this PR to organizing test files and improving DX in testing. |
@thelovekesh Sounds good. Let me know once you've updated the PR. |
37a22b9
to
ba03e11
Compare
dd80ee5
to
d5300d6
Compare
- uses: styfle/cancel-workflow-action@0.12.1 | ||
- uses: actions/checkout@v4 | ||
- uses: styfle/cancel-workflow-action@0.11.0 | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node.js (.nvmrc) | ||
uses: actions/setup-node@v4 | ||
uses: actions/setup-node@v3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be reverted as trunk now have latest dependancy.
// eslint-disable-next-line no-console | ||
console.error( | ||
formats.error( | ||
`The plugin ${ WPP_PLUGIN } is not a valid plugin managed as part of this project.` | ||
) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we utilize log
from require( '../plugin/lib/logger' )
?
// eslint-disable-next-line no-console | |
console.error( | |
formats.error( | |
`The plugin ${ WPP_PLUGIN } is not a valid plugin managed as part of this project.` | |
) | |
); | |
log( | |
formats.error( | |
`The plugin ${ WPP_PLUGIN } is not a valid plugin managed as part of this project.` | |
) | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better to use console.error()
as it goes to STDERR
instead of STDOUT
.
Otherwise, this could be added to logger as an alias in the same way that was done for console.log
.
/* | ||
* Last resort: see if this is a typical WP-CLI scaffold command set-up where a subset of | ||
* the WP test files have been put in the system temp directory. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* Last resort: see if this is a typical WP-CLI scaffold command set-up where a subset of | |
* the WP test files have been put in the system temp directory. | |
*/ | |
/* | |
* Last resort: see if this is a typical WP-CLI scaffold command set-up where a subset of | |
* the WP test files have been put in the system temp directory. | |
*/ |
/* | ||
* If neither of the constants was set, check whether the plugin is installed | ||
* in `src/wp-content/plugins`. In that case, this file would be in | ||
* `src/wp-content/plugins/performance/tests`. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* If neither of the constants was set, check whether the plugin is installed | |
* in `src/wp-content/plugins`. In that case, this file would be in | |
* `src/wp-content/plugins/performance/tests`. | |
*/ | |
/* | |
* If neither of the constants was set, check whether the plugin is installed | |
* in `src/wp-content/plugins`. In that case, this file would be in | |
* `src/wp-content/plugins/performance/tests`. | |
*/ |
|
||
const _plugins = []; // Store absolute paths to plugins. | ||
|
||
if ( WPP_PLUGIN ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thelovekesh Unrelated to the ongoing discussion in #1012: If we implement new JS tooling scripts like this, I think they should be incorporated into the existing foundation in bin/plugin
. It uses commander
for a full CLI suite, which has some benefits like built-in help / documentation functionality and error handling infrastructure. This could be reused rather than implementing standalone commands like this.
|
||
// Add `tiff` and `bmp` to the list of allowed file types. | ||
// These are removed by default in multisite. | ||
$site_exts[] = 'tiff'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need tiff and bmp for tests? what about webp/avif?
@thelovekesh if the issue for tests passing is with the Imagick implementation, we may be able to fix this by adding a filter to the test to have it use GD instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks great @thelovekesh - a few moire points from other commenters to address then this should be good to go. Thanks for limiting the scope here to reorganization of files.
Summary
Previously #1013
Fixes task 2 of #1012
Relevant technical choices
tests/data
directory.phpunit.xml.dist
to plugin directories. The current setup also allows to override of PHPUnit config per plugin e.g. put aphpunit.xml
file in the plugin directory and PHPUnit will overridephpunit.xml.dist
.