-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Expanded wp-env
Lifecycle Scripts
#50570
Conversation
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
packages/env/lib/config/test/__snapshots__/config-integration.js.snap
Outdated
Show resolved
Hide resolved
b4511a5
to
318b5cf
Compare
This PR is now failing because of the config option validation. It isn't built to handle arguments with nested properties that are expected to be present. It's not too difficult a fix, but, I'd like to settle on whether or not we're going to ship this at all before moving forward with the fix. |
This is just an internal change aimed at supporting a shift to more lifecycle scripts. It does not change the external config file or the way that the scripts execute yet.
Instead of having a dedicated "afterSetup" execution path, we now have a generic execution path for lifecycle scripts. This will make it easy to execute other scripts on lifecycle events.
This removes `afterSetup` in favor of an `afterStart` and an `afterClean` script. These will provide a more granular way of handling things. We have also added a `beforeDestroy` script that will help.
This keeps the spinner from freezing and also has the benefit of making the script output more consumable.
318b5cf
to
97ca1be
Compare
Oh, another thing I just noticed is that output gets swallowed by the spinner. Is that expected? The "test start" example goes away after the command completes. |
I went with this approach so that it would be consistent with all of the other actions |
Hm, I guess that makes sense. I was comparing it more in my mind to |
Flaky tests detected in 7b1b898. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5060945367
|
What?
In #50196 I added an
afterSetup
script that is executed afterwp-env start
andwp-env clean
. This pull request expands on that work and provides more granular lifecycle scripts in its place.Why?
Once I began adopting the
afterSetup
feature I found that it wasn't granular enough and that there were cases where it would also be useful to have a script execute.How?
We're going to remove the
afterSetup
option in favor of a top-levellifecycleScripts
option with entries for each lifecycle script that the user wants to implement. These scripts can all be overridden usingWP_ENV_LIFECYCLE_SCRIPT_{ EVENT_NAME }
environment variables. For now this includesafterStart
,afterClean
, andbeforeDestroy
. I've also made the execution of the script asynchronous because it was blocking the spinner.Testing Instructions
start
,clean
, anddestroy
all work the same without any scripts set..wp-env.override.json
with content:start
,clean
, anddestroy
and watch the output.--debug
and it will persist the command output.export WP_ENV_LIFECYCLE_SCRIPT_AFTER_START="echo 'Test Override' && sleep 10"
and runstart
. Note that it is overridden.export WP_ENV_LIFECYCLE_SCRIPT_AFTER_START="echo "FAIL" 1>&2 && false"
and runstart
. It should give the error and indicate the failure.