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

FSE: Integrate wp-env environment #39000

Merged
merged 7 commits into from Feb 14, 2020
Merged

Conversation

noahtallen
Copy link
Member

@noahtallen noahtallen commented Jan 21, 2020

Originally, I covered several more things in this PR which I have split out into the following:

This PR sets up @wordpress/env as a Docker environment for running the plugin locally (and hopefully, in the future, in CI).

As part of this effort, I have created an opinionated "setup-env" script which sets up the repositories a developer needs for working with the FSE plugin locally.

  • It clones gutenberg and themes as siblings of wp-calypso in your filesystem if they are not there yet. (So if you have gutenberg, themes, and wp-calypso cloned in the same directory, nothing will change.)
  • It builds FSE plugin
  • It starts wp-env on localhost:4013

Changes proposed in this Pull Request

  • This PR integrates @wordress/env directly into the FSE plugin so that we have a WordPress environment in which to run our tests.
  • Adds an environment init script to help set up the local env (includes cloning Gutenberg and themes.)
  • Adds a .wp-env.json file to specify dependencies of the project.

Test Install Step

  1. In your gutenberg checkout (which should be a sibling of wp-calypso), make sure you have the latest changes on the master branch, and build everything: nvm use && npm ci && npm run build.
  2. From wp-calypso root, run ./apps/full-site-editing/bin/setup-env.sh. Once it does everything, it will ask you if you want to run the development version of wp-env. Choose yes since the changes we require have not been published to npm yet.
  3. If all goes well, you should be able to access a Docker instance at localhost:4013. (Note: I have experienced issues with my browser caching a redirect between different ports, so you may need to try different browsers and/or clear the cache for localhost).

To do:

  • Check what would be needed to make the setup-env script work in CircleCI
  • Ability to run env commands with the correct port numbers (see my Gutenberg PR)

@noahtallen noahtallen added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Goal] Full Site Editing [Team] Cylon labels Jan 21, 2020
@noahtallen noahtallen requested review from a team as code owners January 21, 2020 23:26
@noahtallen noahtallen self-assigned this Jan 21, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Jan 21, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~128111 bytes removed 📉 [gzipped])

name                  parsed_size             gzip_size
media                   -177041 B   (-31.8%)   -31257 B   (-23.4%)
security                -145713 B   (-26.1%)   -36118 B   (-25.2%)
themes                  -143736 B   (-29.8%)   -32449 B   (-26.3%)
settings                -134404 B   (-20.4%)   -26883 B   (-16.5%)
people                  +130293 B   (+54.5%)   +28179 B   (+42.1%)
preview                 -118967 B   (-52.2%)   -27684 B   (-47.2%)
settings-writing        -110614 B   (-19.7%)   -29452 B   (-20.5%)
plans                   -105542 B   (-19.2%)   -22485 B   (-16.2%)
jetpack-connect         -105542 B   (-15.7%)   -22485 B   (-13.0%)
posts-custom            +104798 B   (+55.5%)   +24773 B   (+47.2%)
comments                 +93876 B   (+21.7%)   +20869 B   (+20.5%)
theme                    -88484 B   (-24.7%)   -21212 B   (-22.5%)
posts                    +87113 B   (+41.7%)   +20470 B   (+35.6%)
devdocs                  +82351 B  (+120.9%)   +22113 B  (+119.8%)
home                     -81416 B   (-21.7%)   -21386 B   (-21.5%)
stats                    +65855 B    (+8.9%)   +11228 B    (+5.9%)
marketing                +55687 B   (+14.5%)   +22131 B   (+25.0%)
pages                    +53961 B   (+27.0%)   +13212 B   (+23.6%)
google-my-business       -42907 B   (-13.5%)   -10276 B   (-11.8%)
checkout                 +42141 B    (+3.6%)   +11178 B    (+3.9%)
concierge                +41704 B   (+15.3%)   +11630 B   (+18.2%)
plugins                  -37847 B    (-7.2%)    -9351 B    (-6.9%)
auth                     -35344 B   (-65.8%)    -8939 B   (-62.6%)
hosting                  -33745 B   (-11.7%)    -8878 B   (-11.3%)
woocommerce              -29218 B    (-1.4%)    -7700 B    (-1.4%)
settings-performance     +20480 B   (+10.1%)    +5625 B   (+10.3%)
export                    -7623 B    (-3.9%)     -763 B    (-1.5%)
mailing-lists             -7310 B   (-52.3%)    -2277 B   (-54.2%)
gutenberg-editor           -615 B    (-0.1%)      +76 B    (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~34747 bytes removed 📉 [gzipped])

name                                 parsed_size             gzip_size
async-load-signup-steps-plans          -105542 B   (-40.6%)   -22485 B   (-35.5%)
async-load-my-sites-guided-transfer     -51676 B   (-68.9%)   -12547 B   (-69.0%)
async-load-reader-tag-stream-main       -41268 B   (-72.1%)    -9694 B   (-66.8%)
async-load-reader-sidebar               +30096 B  (+111.0%)    +7785 B  (+115.8%)
async-load-reader-search-stream          +5676 B    (+7.1%)    +1219 B    (+5.9%)
async-load-reader-following-manage       +5676 B    (+5.4%)    +1219 B    (+4.3%)
async-load-reader-site-stream            -1890 B    (-7.1%)     -122 B    (-1.7%)
async-load-reader-feed-stream            -1890 B    (-7.1%)     -122 B    (-1.8%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Moment.js Locales (~3979 bytes removed 📉 [gzipped])

name                    parsed_size            gzip_size
moment-locale-en-au        -12567 B  (-90.9%)    -4212 B  (-86.0%)
moment-locale-sw            -1357 B  (-53.9%)     -459 B  (-42.1%)
moment-locale-te            +1126 B  (+97.0%)     +327 B  (+51.7%)
moment-locale-tet           -1024 B  (-44.8%)     -270 B  (-28.2%)
moment-locale-ur            -1009 B  (-42.6%)     -289 B  (-28.3%)
moment-locale-kn             +993 B  (+56.4%)     +275 B  (+31.4%)
moment-locale-gu             +986 B  (+64.9%)     +351 B  (+47.6%)
moment-locale-sq             -858 B  (-39.9%)     -230 B  (-24.7%)
moment-locale-it-ch          -825 B  (-38.6%)     -245 B  (-25.4%)
moment-locale-ms             -822 B  (-37.6%)     -251 B  (-25.9%)
moment-locale-tg             +790 B  (+62.5%)     +292 B  (+42.4%)
moment-locale-my             +777 B  (+57.0%)     +219 B  (+30.5%)
moment-locale-pt-br          -751 B  (-36.3%)     -293 B  (-29.4%)
moment-locale-sr             +735 B  (+56.9%)     +249 B  (+35.4%)
moment-locale-si             +733 B  (+55.2%)     +155 B  (+21.9%)
moment-locale-ug-cn          +731 B  (+44.7%)     +153 B  (+17.6%)
moment-locale-ku             -664 B  (-24.1%)     -174 B  (-15.1%)
moment-locale-tr             -620 B  (-29.4%)      -61 B   (-7.1%)
moment-locale-he             -565 B  (-22.6%)     -210 B  (-19.3%)
moment-locale-sr-cyrl        +491 B  (+24.2%)     +139 B  (+14.6%)
moment-locale-mn             +435 B  (+24.9%)      +60 B   (+6.6%)
moment-locale-x-pseudo       +376 B  (+32.5%)     +253 B  (+42.2%)
moment-locale-kk             +347 B  (+24.5%)     +137 B  (+18.6%)
moment-locale-mk             -295 B  (-14.4%)      -47 B   (-4.9%)
moment-locale-lt             +276 B  (+13.5%)     +290 B  (+35.7%)
moment-locale-me             -275 B  (-11.9%)     -145 B  (-13.2%)
moment-locale-zh-cn          +226 B  (+14.7%)      +70 B   (+8.2%)
moment-locale-uz-latn        -200 B  (-14.7%)     -132 B  (-18.1%)
moment-locale-hr             +185 B   (+9.5%)      +61 B   (+6.9%)
moment-locale-gl             +171 B  (+12.7%)       +3 B   (+0.4%)
moment-locale-fy             +155 B  (+12.3%)      +83 B  (+12.1%)
moment-locale-tzl            +148 B  (+10.0%)      +68 B   (+8.5%)
moment-locale-nl             -147 B   (-6.9%)       -1 B   (-0.1%)
moment-locale-jv             +103 B   (+7.9%)      +17 B   (+2.4%)
moment-locale-sk              +90 B   (+4.4%)      +70 B   (+8.1%)
moment-locale-pl              +65 B   (+3.2%)      +55 B   (+5.9%)
moment-locale-ga              -63 B   (-4.5%)      -34 B   (-4.4%)
moment-locale-th              +54 B   (+2.6%)     -121 B  (-12.3%)
moment-locale-lo              -47 B   (-2.2%)     -164 B  (-16.8%)
moment-locale-sd              +40 B   (+3.0%)      +53 B   (+7.5%)
moment-locale-se              -29 B   (-2.1%)      -47 B   (-6.2%)
moment-locale-hy-am           +12 B   (+0.6%)      +26 B   (+2.8%)

Locale data for moment.js. Unless you are upgrading the moment.js library, changes in these chunks are suspicious.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@noahtallen
Copy link
Member Author

noahtallen commented Jan 22, 2020

apparently it is impossible to entirely override the ports: docker/compose#2260. Docker will actually merge those ports

@noahtallen
Copy link
Member Author

Solved by adding the port as an environment variable in the run script :)

@noahtallen noahtallen force-pushed the try/wordpress-env-for-tests branch 2 times, most recently from 1087844 to a82edbf Compare January 24, 2020 22:08
@noahtallen noahtallen changed the title WIP: Add WordPress env for our test framework WIP: FSE - Complete Test Environment Jan 24, 2020
@noahtallen noahtallen changed the title WIP: FSE - Complete Test Environment FSE: Introduce All Sorts of Tests Jan 25, 2020
@noahtallen noahtallen changed the title FSE: Introduce All Sorts of Tests FSE: All The Tests Jan 25, 2020
@noahtallen
Copy link
Member Author

The failing e2e tests don't appear to be related to our additions here. I do see this error:

Found console error: "https://wordpress.com/ - A cookie associated with a cross-site resource at http://wordpress.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032." on url 'https://hash-cd9beeca81bec5df19f0cc05faaf2a738983ff08.calypso.live/read'
0

@noahtallen noahtallen requested review from a team January 25, 2020 21:15
@noahtallen
Copy link
Member Author

Added @Automattic/luna in case folks have opinions on some of this stuff. After all, we'll all be working in this environment :)

@mattwiebe
Copy link
Contributor

mattwiebe commented Jan 27, 2020

After running the npx lerna run env --scope='@automattic/full-site-editing' --stream -- install command, I get errors activating the plugin:

> env LOCAL_PORT=9999 wp-scripts env "cli" "plugin" "activate" "full-site-editing-plugin"
> WordPress@5.4.0 env:cli /Users/matt/www/calypso/apps/full-site-editing/wordpress
> node ./tools/local-env/scripts/docker.js run cli "--path=/var/www/src" "plugin" "activate" "full-site-editing-plugin"
Plugin 'full-site-editing-plugin' activated.
Success: Activated 1 of 1 plugins.
Warning: filemtime(): stat failed for /var/www/src/wp-content/plugins/full-site-editing-plugin/starter-page-templates/dist/starter-page-templates.js in /var/www/src/wp-content/plugins/full-site-editing-plugin/starter-page-templates/class-starter-page-templates.php on line 72
Warning: require(dist/editor.asset.php): failed to open stream: No such file or directory in /var/www/src/wp-content/plugins/full-site-editing-plugin/blog-posts-block/index.php on line 41
Fatal error: require(): Failed opening required 'dist/editor.asset.php' (include_path='.:/usr/local/lib/php') in /var/www/src/wp-content/plugins/full-site-editing-plugin/blog-posts-block/index.php on line 41

Visiting localhost:9999 results in this:

Warning: filemtime(): stat failed for /var/www/src/wp-content/plugins/full-site-editing-plugin/starter-page-templates/dist/starter-page-templates.js in /var/www/src/wp-content/plugins/full-site-editing-plugin/starter-page-templates/class-starter-page-templates.php on line 72

Warning: require(dist/editor.asset.php): failed to open stream: No such file or directory in /var/www/src/wp-content/plugins/full-site-editing-plugin/blog-posts-block/index.php on line 41

Fatal error: require(): Failed opening required 'dist/editor.asset.php' (include_path='.:/usr/local/lib/php') in /var/www/src/wp-content/plugins/full-site-editing-plugin/blog-posts-block/index.php on line 41

I'll leave it there for now as I go to debug what went wrong and see if I can help with a fix. Looks like the FSE plugin didn't get built properly.

@noahtallen
Copy link
Member Author

Warning: filemtime(): stat failed

@mattwiebe I've seen that error before while running the plugin on wpcom, and usually it is fixed by re-building the plugin. It sounds like we may need to run the fse build step before trying to load it in the environment.

@noahtallen
Copy link
Member Author

@mattwiebe I fixed it by making the script also run the build first.

Try: npm run distclean from the root. Then, run docker system prune -a to delete any docker images you have. Then try again with this command (slightly different name now that I moved it to a script.)

npx lerna run init --scope='@automattic/full-site-editing' --stream

.eslintrc.js Outdated
@@ -33,6 +33,14 @@ module.exports = {
step: false,
},
},
{
files: [ 'apps/full-site-editing/**/tests/**' ],
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: improve this so that it matches .test.js and .spec.js files

@mattwiebe
Copy link
Contributor

Okay, passed the first step. Had to run npm ci after 'npm run distcleanand beforenpx lerna run init --scope='@automattic/full-site-editing' --stream- we could probably addnpm run install-if-deps-outdatedto the ourinit` command to remove the need to remember the extra step.

Also, the first time I ran it and then logged into wp-admin, the FSE plugin showed up as deactivated due to not existing, but then the second time I ran it, the plugin is still there and active.

Then I started to try to run the tests.

test:php
test:e2e
test:js

Here's the e2e failure output:

lerna notice cli v3.20.2
lerna info versioning independent
lerna notice filter including "@automattic/full-site-editing"
lerna info filter [ '@automattic/full-site-editing' ]
lerna info Executing command in 1 package: "npm run test:e2e"
@automattic/full-site-editing: > @automattic/full-site-editing@0.18.2 test:e2e /Users/matt/www/calypso/apps/full-site-editing
@automattic/full-site-editing: > npx wp-scripts test-e2e --wordpress-base-url='http://localhost:9999'
@automattic/full-site-editing: (node:98699) UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected!
@automattic/full-site-editing:     at CDPSession.<anonymous> (/Users/matt/www/calypso/node_modules/puppeteer/lib/LifecycleWatcher.js:46:107)
@automattic/full-site-editing:     at CDPSession.emit (events.js:210:5)
@automattic/full-site-editing:     at CDPSession._onClosed (/Users/matt/www/calypso/node_modules/puppeteer/lib/Connection.js:215:10)
@automattic/full-site-editing:     at Connection._onMessage (/Users/matt/www/calypso/node_modules/puppeteer/lib/Connection.js:105:17)
@automattic/full-site-editing:     at WebSocket.<anonymous> (/Users/matt/www/calypso/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
@automattic/full-site-editing:     at WebSocket.onMessage (/Users/matt/www/calypso/node_modules/ws/lib/event-target.js:120:16)
@automattic/full-site-editing:     at WebSocket.emit (events.js:210:5)
@automattic/full-site-editing:     at Receiver.receiverOnMessage (/Users/matt/www/calypso/node_modules/ws/lib/websocket.js:744:20)
@automattic/full-site-editing:     at Receiver.emit (events.js:210:5)
@automattic/full-site-editing:     at Receiver.dataMessage (/Users/matt/www/calypso/node_modules/ws/lib/receiver.js:417:14)
@automattic/full-site-editing:   -- ASYNC --
@automattic/full-site-editing:     at Frame.<anonymous> (/Users/matt/www/calypso/node_modules/puppeteer/lib/helper.js:111:15)
@automattic/full-site-editing:     at Page.waitForNavigation (/Users/matt/www/calypso/node_modules/puppeteer/lib/Page.js:695:49)
@automattic/full-site-editing:     at Page.waitForNavigation (/Users/matt/www/calypso/node_modules/puppeteer/lib/helper.js:112:23)
@automattic/full-site-editing:     at _callee$ (/Users/matt/www/calypso/node_modules/@wordpress/e2e-test-utils/build/@wordpress/e2e-test-utils/src/login-user.js:29:28)
@automattic/full-site-editing:     at tryCatch (/Users/matt/www/calypso/node_modules/regenerator-runtime/runtime.js:45:40)
@automattic/full-site-editing:     at Generator.invoke [as _invoke] (/Users/matt/www/calypso/node_modules/regenerator-runtime/runtime.js:271:22)
@automattic/full-site-editing:     at Generator.prototype.<computed> [as next] (/Users/matt/www/calypso/node_modules/regenerator-runtime/runtime.js:97:21)
@automattic/full-site-editing:     at asyncGeneratorStep (/Users/matt/www/calypso/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
@automattic/full-site-editing:     at _next (/Users/matt/www/calypso/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
@automattic/full-site-editing:     at processTicksAndRejections (internal/process/task_queues.js:93:5)
@automattic/full-site-editing: (node:98699) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
@automattic/full-site-editing: (node:98699) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@automattic/full-site-editing: FAIL full-site-editing-plugin/full-site-editing/tests/e2e/fse-back-button.spec.js (7.549s)
@automattic/full-site-editing:   Full Site Editing Back Button
@automattic/full-site-editing:     ✕ Should navigate to a new post. (5005ms)
@automattic/full-site-editing:   ● Full Site Editing Back Button › Should navigate to a new post.
@automattic/full-site-editing:     : Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:
@automattic/full-site-editing:        6 |
@automattic/full-site-editing:        7 | describe( 'Full Site Editing Back Button', () => {
@automattic/full-site-editing:     >  8 | 	it( 'Should navigate to a new post.', async () => {
@automattic/full-site-editing:          | 	^
@automattic/full-site-editing:        9 | 		await createNewPost();
@automattic/full-site-editing:       10 | 		const title = await page.title();
@automattic/full-site-editing:       11 | 		expect( title ).toBe( 'Add New Post ‹ WordPress Develop — WordPress' );
@automattic/full-site-editing:       at new Spec (../../node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
@automattic/full-site-editing:       at Suite.<anonymous> (full-site-editing-plugin/full-site-editing/tests/e2e/fse-back-button.spec.js:8:2)
@automattic/full-site-editing: Test Suites: 1 failed, 1 total
@automattic/full-site-editing: Tests:       1 failed, 1 total
@automattic/full-site-editing: Snapshots:   0 total
@automattic/full-site-editing: Time:        7.961s, estimated 13s
@automattic/full-site-editing: Ran all test suites.
@automattic/full-site-editing: npm ERR! code ELIFECYCLE
@automattic/full-site-editing: npm ERR! errno 1
@automattic/full-site-editing: npm ERR! @automattic/full-site-editing@0.18.2 test:e2e: `npx wp-scripts test-e2e --wordpress-base-url='http://localhost:9999'`
@automattic/full-site-editing: npm ERR! Exit status 1
@automattic/full-site-editing: npm ERR!
@automattic/full-site-editing: npm ERR! Failed at the @automattic/full-site-editing@0.18.2 test:e2e script.

I'll try to dig in more.

Great work getting us this far! 🎉

@noahtallen noahtallen changed the title WIP FSE: All The Tests FSE: Integrate wp-env environment Feb 8, 2020
@noahtallen
Copy link
Member Author

Update: see the new PR description. I've removed all the testing related code from this PR and narrowed it down to just adding @wordpress/env. This should make it easier for me to iterate on the individual pieces of the puzzle :)

In particular, #39326 should be completely ready to go.

Still doing some work on this PR and the e2e one, but the phpunit one is completely blocked at the moment.

@noahtallen noahtallen changed the title FSE: Integrate wp-env environment (WIP) FSE: Integrate wp-env environment Feb 8, 2020
@@ -0,0 +1,6 @@
{
"plugins": [ "./full-site-editing-plugin", "../../../gutenberg" ],
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about including Jetpack and wpcomsh here so it's closer to Atomic env?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could definitely do that. Do you think it could be a follow up?

One of the reasons that it might not be nice to do this is that every plugin and theme here is the development version. So I'd have to do npm i and npm run build for every plugin so that it loads correctly. And then I would have to make sure that I do git pull regularly. I could see that being a pain with a lot of plugins.

Copy link
Member

Choose a reason for hiding this comment

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

Do you think it could be a follow up?

Sure, that's fine with me.

@vindl
Copy link
Member

vindl commented Feb 12, 2020

The current testing steps work fine for me up to a certain point. 🚀The site's front end and wp-admin load fine. When I try to open the editor though I'm running into this fatal, not sure how it's related given that this is a core WP function.

Fatal error: Uncaught Error: Call to undefined function wp_get_registered_image_subsizes() in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php:690 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(288): gutenberg_extend_settings_image_dimensions(Array) #1 /var/www/html/wp-includes/plugin.php(208): WP_Hook->apply_filters(Array, Array) #2 /var/www/html/wp-admin/edit-form-blocks.php(374): apply_filters('block_editor_se...', Array, Object(WP_Post)) #3 /var/www/html/wp-admin/post.php(178): include('/var/www/html/w...') #4 {main} thrown in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php on line 690

I'm guessing this is also the culprit behind my errors in e2e testing PR.

Also, what do you think about adding ./apps/full-site-editing/bin/setup-env.sh as a script (e.g. start-fse-env)?

@noahtallen
Copy link
Member Author

what do you think about adding ./apps/full-site-editing/bin/setup-env.sh as a script

Honestly, I wanted to do that, but I was thinking that it'd be really verbose to run it with npm:

npx lerna run start-fse-env --scope='@automattic/full-site-editing' --stream --no-prefix"

at which point referencing the script directly seems to make more sense. Plus, the script is written such that expects to start in the wp-calypso root, and not in the FSE app folder. (Though I could improve that :))

Plus, this is just for setting up the environment, so it should be a one-time thing. Once everything is working, you should be able to run wp-env start from the FSE root and it will work automatically.

When I try to open the editor though I'm running into this fatal, not sure how it's related given that this is a core WP function.

My only guess is that it's a bug in Gutenberg?? The WordPress version is the latest production version (I think 5.3), not the dev version. Could try re-building the Gutenberg plugin to see if that works since the error is thrown in plugins/gutenberg.

@vindl
Copy link
Member

vindl commented Feb 13, 2020

Honestly, I wanted to do that, but I was thinking that it'd be really verbose to run it with npm:

Oh true, for a moment I forgot how much incantations it takes now. 😄

@vindl vindl changed the title (WIP) FSE: Integrate wp-env environment FSE: Integrate wp-env environment Feb 14, 2020
@vindl
Copy link
Member

vindl commented Feb 14, 2020

I tested this and everything works fine except loading the Gutenberg editor which results in the following fatal:

Fatal error: Uncaught Error: Call to undefined function wp_get_registered_image_subsizes() in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php:690 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(288): gutenberg_extend_settings_image_dimensions(Array) #1 /var/www/html/wp-includes/plugin.php(208): WP_Hook->apply_filters(Array, Array) #2 /var/www/html/wp-admin/edit-form-blocks.php(374): apply_filters('block_editor_se...', Array, Object(WP_Post)) #3 /var/www/html/wp-admin/post-new.php(72): include('/var/www/html/w...') #4 {main} thrown in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php on line 690

I tracked it down, and the problem seems to be stemming from the fact that my env is running WP 5.2.2, and required wp_get_registered_image_subsizes function that latest master of Gutenberg depends on was introduced in WP 5.3.

I suspected that docker might be using some of my old WP images, but I purged them all and made sure that the script downloads a new one, and it still ended up being 5.2.2.

Having said that, this problem is not caused by this PR and it's something that needs to be resolved in the WP docker image or wp-env script.

@vindl vindl added [Status] Ready to Merge and removed [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 14, 2020
Copy link
Member

@vindl vindl left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@noahtallen noahtallen merged commit 4c58722 into master Feb 14, 2020
@noahtallen noahtallen deleted the try/wordpress-env-for-tests branch February 14, 2020 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants