-
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
Docs: How to pull a Gutenberg PR to your local WP develop environment setup. #25202
Comments
I received the following error when I tried to test another PR. I had restarted terminal. I then switched to
Run: The above should remove the package lock. |
Example go to
|
Questions that come up.... I noticed in the Dashboard in Docker. (On a Mac) top right bar to the left of the wifi icon is the Docker icon (if it has been started up that is). In the drop down is the option to select Dashboard. One sees a stack. Clicks the orange icon/area. Enters the containers screen. Here one can also click Port:8888 to access the localhost 8888 web site. There is also a port 8889. |
Theoretically, we could add a note to the prerequisite so that folks don't start wp-env from the root directory if they are going to use it with a plugin |
We can talk more about it Noah, and see if that is the logical approach. An example use case. NB. First follow 1B above: #25202 (comment) I want to test this PR. #24875 I copy the needed information: update/navigation-editor-redesign I reopen terminal. Add: Open Docker. As Docker needs to be open before starting up the local version of WordPress. Add (optional if this has recently been started.): Then either through Docker -> Dashboard -> Stack -> hover over a Container which mentions the port:888 and click the icon to open the browser. There was an error in the top of the wp-admin but I just skipped it and went straight to the Navigation beta screen, and could see the latest build. |
Yep, those steps make sense to me! |
### ---- Will be edited. Please DM me adjustments that I can add below. Thank you!----- An improved method of running a PR and/or contributing to Gutenberg.Using remotes. When the user has access rights to the Gutenberg repo. To get access rights one needs to ask in the Slack Core Editor channel to be added to the team. For running a PR or contributing this step needs to be done. Add to terminal:
How to run (test) a PR when user has access, as part of the Gutenberg team. To figure out if the PR you are running is from a user who has access then look at the PR and see if it says from example username. Add the following commands to terminal: 2a. Add the remote from that users fork. I am using the example with ntsekuras username, but I can call it anything that I want. The username in the URL needs to be correct. 3a. Get branches/work done on this users remote repo. I can rename ntsekouras to anything that I choose. 4a. Get the PR that is to run. I can rename ntsekouras to anything that I choose. 5a. NPM needs to be installed. 6a. Run the current npm build. 7a. Start the local WP dev environment to gain access to http://localhost:8888/ To contribute when the user has access, as part of the Gutenberg team.
2b. Create a new local branch to work on git checkout When the user does NOT have access rights to the Gutenberg repo. To get access rights one needs to ask in the Slack Core Editor channel to be added to the team. How to run a PR when user does not have access to the Gutenberg team. How to contribute when user does not have access to the Gutenberg team
A think thank you to @ntsekouras for the above instructions! |
Here is an even simpler way of running a PR. Shared by @talldanhttps://stackoverflow.com/questions/27567846/how-can-i-check-out-a-github-pull-request-with-git Here’s another one that’s a bit shorter, potentially easier, and should work with any PR (whether on a fork or not):
Example use case:
(Optionally start:
Terminal result:
Terminal result:
EDIT: Update 21 October NB! I had to instead use this approach: That worked. |
I am thinking of using the information in this comment: #25202 (comment) I will just have to focus on running (testing) a PR. |
Just a note, the new Github CLI makes a lot of these tasts a lot easier... This of course requires actually installing the GH CLI first, but that's easy enough to do and their docs on how to install it are pretty good and cover all OSs |
Reasoning for removal of UserDocumentation label: |
Right now I have a few methods for running/testing a PR. That are short and to the point. Ari I will wait a little bit with Github CLI. I need to land the how to contribute alongside the running of PR's. As for running a PR one downloads the Gutenberg repo, and it seems for contributing one downloads a fork of the Gutenberg repo. For this approach one needs two folders locally containing the Gutenberg repo. I am thinking there needs to be a much simpler way of contributing in addition to using the above simple approaches to running a PR. |
An error guide... (EDITED: based on feedback from @talldan ) Did a search for code ELIFECYCLE and found this page: https://reactgo.com/npm-err-code-elifecycle/ npm install can take a while to install. It will update packages to the right version on your local machine. I restarted terminal switched to Another type of error message. If you get an message in terminal mentioning:
I have found that one way to switch branches/testing another PR is to first write: |
Great work on this @paaljoachim I understand that we shouldn't provide troubleshooting advice for every single use case in the docs but I've also found that npm advice (quoted above) is really helpful when encountering similar errors when testing out PRs and switching between branches, etc and should be included in the docs. |
Agree with @skorasaurus on this. Just to give feedback on the errors:
The error message mentions An option here is that we could add a nicer error message to The reason for this is that
This is tricky to answer without knowing exactly what happened. It happens when there are local changes to files within the project. I don't think rebasing is the right thing to do, really you want to look at what changes have been made to the files and either get rid of them, stash them, or commit them. That SO thread is very misleading. 😬 |
EDITED: Added corrections from Dan. How to test a PR made by a non team member. Non team members have their name added to the file(?). aaronrobertshaw:try/border-radius-block-support They add PRs to their own gutenberg fork. Meaning they use their own repository instead of directly the Gutenberg repository (This is entirely correct and needs to be adjusted.) To be able to test a PR from a non team member the testing process is a little different. #25791
To remove a Git remote locally use: Example. To check if a remote was removed, use |
A couple of corrections here that I think are worth making.
Happy to go into more detail if needed. |
Though learning how to use git |
Thank you Dan @talldan for the corrections! I have updated the text. Ari @aristath as I get different methods of testing a PR in place, and use them myself. I also add adjustments along the way based on my own tests. It will be natural to also add how to test a PR with Github CLI. I will get back to both of you! |
@paaljoachim I forget if it was you or someone else, but I posted at some point that I would try these instructions out and never did. 3 months forward, here I am. I followed step by step what you wrote and successfully setup a local dev env on my Mac and was able to test a PR. Thanks for the solid instructions. :) |
@paaljoachim are there any followups here? |
@paaljoachim is this still active? |
Came here to ask the same after it didn't work this week :) |
It seems like we need an update. I have not tested this out in a while. I have been been using the Gutenberg PR build to test PR's. https://make.wordpress.org/design/2021/03/03/testing-a-gutenberg-pull-request-pr/ |
By the way, I've been using the |
I'm closing this, but feel free to open a PR updating docs with anything that might be useful! |
----The following issue is being worked on...---
I am first adding this issue with steps that @noahtallen shared with me.
I am first creating the issue, and will then
very sooncreate the PR documentation.Having documentation on how to run a Gutenberg PR will help make it possible for additional people to test the PR's and be able to give feedback as a feature is being built. Gutenberg.run is not reliable and we need a reliable way to test PR's.
There is a prerequisite one will need to do before following the below Quick Guide.
Go to the documentation for setting up a
Local WP Development Environment.
In the above documentation we set up the needed JavaScript tools and create a local WordPress development site.
Quick Guide
The first question you should ask yourself is.
Are you planning on only running PR's or do you think you might also contribute a PR to Gutenberg?
-1A- For running and optionally submitting PR's.
First we need to create a fork of the Gutenberg Github repository.
Go to: https://github.com/WordPress/gutenberg
Click the Fork button in the top right area of the screen. This creates a clone of the WordPress Gutenberg repository to your own Github account.
Open terminal and run:
git clone https://github.com/YOUR-USER-NAME/gutenberg
Change YOUR-USER-NAME to your own Github repo account name.
This clones (downloads) the gutenberg repository locally to a gutenberg folder on you computer.
Go to step 2.
-1B- For only running Gutenberg PR's locally.
First we need to download the Gutenberg Github repository.
Go to: https://github.com/WordPress/gutenberg
Click the green Code button.
Click "Use HTTPS" text link.
Click the copy link icon containing this link: https://github.com/WordPress/gutenberg.git
Open terminal it will be in the root. (If you want to switch to another folder then add:
cd
nameoffolder.)Add the following:
git clone https://github.com/WordPress/gutenberg.git
This will clone Gutenberg into the folder that is currently selected. I am in the root folder.
This is what I looked like in terminal on my Mac.
If you want the Gutenberg folder in another directory, then you need to use the command
cd
nameofdirectory/folder and switch to that before cloning gutenberg.Go to step 2.
-2-
In terminal. Add
cd gutenberg
to go to the newly downloaded Gutenberg folder.-3-
Now we need to find the PR that we would like to run.
Here is an example of a Gutenberg PR I want to test:
#24419
I click the clipboard icon next to where it says update/list-view-design, and the following is copied:
update/list-view-design
In terminal I add:
git checkout update/list-view-design
This will copy the branch (PR) to our local version of gutenberg.
Result:
-4-
We now need to run npm install from inside the gutenberg directory. It will install all of the project’s/Gutenberg(?) dependencies.
In terminal add:
npm install
-5-
We now need to run npm run build in order to generate a production-ready build of the Gutenberg plugin. In terminal add:
npm run build
NB!
-6-
In the prerequisite documentation for Setting up a Local WP development environment we started
wp-env
in the root folder. We now need tostop wp-env
in the root as we are now working in the gutenberg folder.In terminal add:
cd ~/
which brings us back to the root folder. Then in terminal add:wp-env stop
Go back to the gutenberg folder by adding:
cd gutenberg
.-7-
The following will start a wp-env instance within the Gutenberg folder.
In terminal add:
npx wp-env start
It downloads WordPress.
Now test run a PR you have added above. In your browser click this link: http://localhost:8888/
It will open your local WP development environment site.
User name: admin and password: password
To test another Pull Request (PR)
-1- NB. Can probably be skipped if you have recently run other PR's.
Run:
git pull
to make sure all the latest changes from Github is available locally.NEEDED -2-
Run:
git checkout $branchname
(change branchname to the correct name of the PR you are testing) will change the code files on your computer to be the ones in the other branch.NEEDED -3-
Run:
npm run build
will build those files. Sometimes we need to runnpm install
first if the dependencies have changed.-4- (Just refresh: http://localhost:8888/ and it should work fine. No need to restart npx wp-env start.)
Start up again localhost at http://localhost:8888/ and add in terminal:
npx wp-env start
Then check the PR you are running.
Uninstall
-1-
In terminal go to to the gutenberg folder
cd gutenberg
directory and add:npx wp-env destroy
. That destroys the WordPress environment and data that was installed inside the gutenberg folder.-2-
Outside of terminal. Locate the gutenberg folder inside the root user folder. Then delete the gutenberg folder.
The text was updated successfully, but these errors were encountered: