-
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
wp-env: Fix errors which prevent it from working without internet #53547
Conversation
Size Change: 0 B Total Size: 1.66 MB ℹ️ View Unchanged
|
Flaky tests detected in 9b77af8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6016824682
|
5f01737
to
8b12b51
Compare
Thank you very much for addressing this, @noahtallen! One question: My typical scenario is that I'd like to work on Gutenberg while offline. Its default Line 2 in 9bd56dc
It seems that this isn't currently supported by this PR, correct? (Only empty or missing |
BTW -- unrelated to my other question -- do I need to destroy my existing wp-env environment to test the following?
I'm asking because if I change my
(and so on). This is apparently unrelated to the PR as it seems to happen on |
That should work with this branch! As long as the environment was already created once, The check for the latest WordPress version only happens when "core" doesn't exist. So that function isn't called otherwise. But even after fixing that issue, I needed to prevent You can also override "core" with your own |
8b12b51
to
9b77af8
Compare
cc @ockham if you have a chance to test this :) |
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.
Hey @noahtallen, apologies for not getting back to you sooner!
I just re-tested this offline, without changing my .wp-env.json
, i.e. without removing the core
field. This time around, it worked smoothely 🎉
LGMT then! 🚢 Thanks again for implementing this change!
9b77af8
to
9159431
Compare
9159431
to
f70dcbb
Compare
What?
Fixes #53433.
Fixes #52157.
Unfortunately, many
wp-env
commands don't work without internet due to a function which finds the latest WordPress version, which happens during config parsing. Beyond this function,wp-env start
could fail in many cases when it tries to do updates (like downloading sources or pulling docker images).Why?
Offline mode always has its uses!
How?
dns.resolve( 'WordPress.org' )
to check for internet access. This seems to be a reasonable practice based on my search for how to do this with NodeJS. It's also very fast, which isn't the case when we wait for timeouts in other functions.shouldConfigureWp
logic duringwp-env start
, since most of that involves internet connections (pulling docker images, downloading sources, etc.) I think it's easier to do this than to add extra checks all over the place when we do something with the network.The side effect is that certain types of
wp-env.json
updates won't work if you're offline, but that seems like a reasonable compromise. For example, if you set thephpVersion
, that involves downloading a different docker image. So a lot of the config options would be impacted anyways.Testing Instructions
core
from Gutenberg's.wp-env.json
file to trigger the check for the latest core source.npx wp-env start
npx wp-env install-path
npx wp-env run cli bash
npx wp-env run cli phpunit --version
All should work.
Testing Instructions for Keyboard
Screenshots or screencast
You should see an offline message in the terminal as well: