Skip to content

Commit b419ff3

Browse files
committed
Tidy up intro.md and rename to getting-started-with-development.md
1 parent 428c1cb commit b419ff3

File tree

3 files changed

+388
-451
lines changed

3 files changed

+388
-451
lines changed
Lines changed: 387 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,387 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Getting started with Plone development"
5+
"property=og:description": "Getting started with Plone development"
6+
"property=og:title": "Getting started with Plone development"
7+
"keywords": "Plone, development"
8+
---
9+
10+
# Getting started with development
11+
12+
This document assumes you want to run the current latest Plone source, fix a bug in Plone, or test an add-on in the context of the latest code, and will detail the full process.
13+
For how to write Plone Improvement Proposals (PLIPs), read {doc}`plips`.
14+
15+
16+
## Version support policy
17+
18+
If you are triaging or fixing bugs, keep in mind that Plone has a [version support policy](https://plone.org/download/release-schedule#91815aec-0513-40e0-a804-55ea787a8c68).
19+
20+
21+
## Dependencies
22+
23+
- git. See [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git).
24+
- [Python](https://python.org/). See the [current supported versions of Python](https://plone.org/download/release-schedule).
25+
- If you are on macOS, you will need to install [XCode](https://developer.apple.com/xcode/).
26+
You can do this through the App Store or registering through the Apple Developer Program.
27+
- [Pillow](https://pypi.org/project/Pillow/).
28+
- [GCC](https://gcc.gnu.org/) in order to compile ZODB, Zope and lxml.
29+
- [libxml2 and libxslt](https://gitlab.gnome.org/GNOME/libxslt/-/releases), including development headers.
30+
31+
32+
(setup-development-environment)=
33+
34+
## Set up your development environment
35+
36+
The first step in fixing a bug is getting this [buildout](https://github.com/plone/buildout.coredev) running.
37+
We recommend fixing the bug on the latest branch, and then [backporting](https://en.wikipedia.org/wiki/Backporting) as necessary.
38+
Dependent on the current development cycle, there may exist a future branch.
39+
For example, `6.0` is the actively maintained stable branch.
40+
[Some other branch] is the future, currently unstable, active development branch.
41+
More information on switching release branches is described below.
42+
43+
To set up a plone 6 development environment.
44+
45+
```shell
46+
cd ~/projects # or wherever you want to put things
47+
git clone -b 6.0 https://github.com/plone/buildout.coredev ./plone6devel
48+
cd ./plone6devel
49+
./bootstrap.sh
50+
```
51+
52+
If you run into issues in this process, please see {doc}`issues`.
53+
54+
This will run for a long time if it is your first pull (approximately 20 minutes).
55+
Once that is done pulling down eggs, you can start your new instance with:
56+
57+
```shell
58+
./bin/instance fg
59+
```
60+
61+
or as a WSGI service with:
62+
63+
```shell
64+
./bin/wsgi
65+
```
66+
67+
To login, the defaults are:
68+
69+
- username: admin
70+
- password: admin
71+
72+
73+
## Switching branches
74+
75+
If your bug is specific to one branch, or you think it should be backported, you can switch branches.
76+
The first time you get a branch, you must do:
77+
78+
```shell
79+
git checkout -t origin/6.0
80+
```
81+
82+
This should set up a local 6.0 branch tracking the one on GitHub.
83+
From then on you can just do:
84+
85+
```shell
86+
git checkout 6.0
87+
```
88+
89+
To see what branch you are currently on:
90+
91+
```shell
92+
git branch
93+
```
94+
95+
The line with a `*` by it will indicate the branch on which you are currently working.
96+
97+
```{important}
98+
Make sure to rerun buildout if you were in a different branch earlier to get the correct versions of packages, otherwise you will get some weird behavior.
99+
```
100+
101+
102+
## Jenkins and mr.roboto
103+
104+
Plone has a continuous integration (CI) setup and follows CI rules.
105+
106+
When you push a change to any Plone package, our testing/CI middleware `mr.roboto` starts running all the tests that are needed to make sure that you don't break anything.
107+
For each Plone and Python version we run two jobs, one for the package itself (which will give you a fast feedback, within 10 minutes) and one on the full `coredev` build (which can take up to an hour, but makes sure no other packages are effected by your change.
108+
109+
For more information you can read {doc}`Mr. Roboto workflow <roboto>` or our [Jenkins machine](https://jenkins.plone.org/).
110+
111+
The CI system at `jenkins.plone.org` is a shared resource for Plone developers to notify them of regressions in Plone code.
112+
Build breakages are a normal and expected part of the development process.
113+
Our aim is to find errors and eliminate them as quickly as possible, without expecting perfection and zero errors.
114+
Though, there are some essential practices that need to be followed in order to achieve a stable build:
115+
116+
1. Don't check in on a broken build. Check Jenkins first.
117+
2. Always run all commit tests locally before committing.
118+
3. Wait for commit tests to pass before moving on.
119+
4. Never go home on a broken build.
120+
5. Always be prepared to revert to the previous revision.
121+
6. Time-box fixing before reverting.
122+
7. Don't comment out failing tests.
123+
8. Take responsibility for all breakages that result from your changes.
124+
125+
See {doc}`continous-integration` for more information.
126+
127+
Since it can be burdensome to check this manually, install the tools locally to always see the current state of the Plone CI Server:
128+
129+
- For Linux and X11 environments, there is [BuildNotify](https://pypi.org/project/BuildNotify/).
130+
- For macOS there is [CCMenu](http://ccmenu.org/).
131+
- For windows there is [CCTray](https://cruisecontrolnet.org/cctray_download_plugin-2/).
132+
- For Firefox there is [CruiseControl Monitor](https://addons.thunderbird.net/EN-US/firefox/addon/cruisecontrol-monitor/?src=cb-dl-name) (no longer supported), and many other [Jenkins plugins](https://addons.mozilla.org/en-US/firefox/search/?q=jenkins).
133+
134+
These tools were built to parse a specific file that CruiseControl, another CI tool, generated.
135+
Jenkins generates this file too.
136+
You can configure your notifier of choice with this url: `https://jenkins.plone.org/cc.xml` [which is a 404, LOL!]
137+
138+
139+
## Check out packages to fix
140+
141+
Most packages are not in {file}`src/` by default, so you can use `mr.developer` to get the latest and make sure you are always up to date.
142+
It can be a little daunting at first to find out which packages cause the bug in question, but just ask in https://community.plone.org/ if you need some help.
143+
Once you know which packages you want, pull their source.
144+
145+
You can get the source of the package with `mr.developer` and the checkout command, or you can go directly to editing {file}`checkouts.cfg`.
146+
We recommend the latter but will describe both.
147+
In the end, {file}`checkouts.cfg` must be configured, so you might as well start there.
148+
149+
At the base of your buildout, open {file}`checkouts.cfg` and add your package if it's not already there:
150+
151+
```cfg
152+
auto-checkout =
153+
# my modified packages
154+
plone.app.caching
155+
plone.caching
156+
# others
157+
...
158+
```
159+
160+
Then rerun buildout to get the source packages:
161+
162+
```shell
163+
./bin/buildout
164+
```
165+
166+
Alternatively, we can manage checkouts from the command line, by using `mr.developer`'s `bin/develop` command to get the latest source.
167+
For example, if the issue is in `plone.app.caching` and `plone.caching`:
168+
169+
```shell
170+
./bin/develop co plone.app.caching
171+
./bin/develop co plone.caching
172+
./bin/buildout
173+
```
174+
175+
Don't forget to rerun buildout!
176+
In both methods, `mr.developer` will download the source from GitHub (or otherwise) and put the package in the {file}`src/` directory.
177+
You can repeat this process with as many or as few packages as you need.
178+
For some more tips on working with `mr.developer`, please read {doc}`mrdeveloper`.
179+
180+
181+
## Testing Locally
182+
183+
To run a test for the specific module you modify:
184+
185+
```shell
186+
./bin/test -m plone.app.caching
187+
```
188+
189+
These should all run without error.
190+
Please don't check in anything that doesn't succeed!
191+
Now write a test case for the bug you are fixing, and make sure everything is running as it should.
192+
193+
After the module level tests run with your change, please make sure other modules aren't affected by the change by running the full suite, including robot-tests (remove the `--all` to run without robot tests):
194+
195+
```shell
196+
./bin/test --all
197+
```
198+
199+
```{note}
200+
Tests take a long time to run.
201+
Once you become a master of bugfixes,
202+
you may just let jenkins do this part for you.
203+
More on that below.
204+
```
205+
206+
207+
## Updating `CHANGES.rst` and `checkouts.cfg`
208+
209+
Once all the tests are running locally on your machine, you are **ALMOST** ready to commit the changes.
210+
You must perform a couple housekeeping chores before moving on.
211+
212+
First, edit {file}`CHANGES.rst` (or {file}`CHANGES.txt`, or {file}`HISTORY.txt`) in each package you have modified and add a summary of the change.
213+
This change note will be collated for the next Plone release and is important for integrators and developers to be able to see what they will get if they upgrade.
214+
New changelog entries should be added at the very top of {file}`CHANGES.rst`.
215+
Some packages already switched to use [towncrier](https://pypi.org/project/towncrier/).
216+
If this is the case you'll find a note at the top of the `CHANGES.rst` file.
217+
218+
Most importantly, if you didn't do it earlier, edit the file {file}`checkouts.cfg` in the buildout directory, and add your changes package to the `auto-checkout` list.
219+
This lets the release manager know that the package has been updated, so that when the next release of Plone is cut, a new egg will be released, and Plone will need to pin to the next version of that package.
220+
In other words, this is how your fix becomes an egg!
221+
222+
Note that there is a section separator called "# Test Fixes Only".
223+
Make sure your egg is above that line, else your egg probably won't get made very quickly.
224+
This just tells the release manager that any eggs below this line have tests that are updated, but no code changes.
225+
226+
Modifying the file {file}`checkouts.cfg` also triggers the buildbot, [jenkins](https://jenkins.plone.org/), to pull in the egg and run all the tests against the changes you just made.
227+
Not that you would ever skip running all tests.
228+
229+
If your bug is in more than one release, for example 5.2 and 6.0, please checkout both branches, and add it to the file {file}`checkouts.cfg`.
230+
231+
232+
## Commits and pull requests
233+
234+
Review the following checklist:
235+
236+
- Did you fix the original bug?
237+
- Is your code consistent with our [Style Guides](https://5.docs.plone.org/develop/styleguide/index.html)?
238+
- Did you remove any extra code and lingering pdbs?
239+
- Did you write a test case for that bug?
240+
- DO all test cases for the modules and Plone pass?
241+
- Did you update {file}`CHANGES.rst` in each packages you touched?
242+
- Did you add your changed packages to {file}`checkouts.cfg`?
243+
244+
If you answered *YES* to all of these questions, then you are ready to push your changes!
245+
A couple quick reminders:
246+
247+
- Only commit directly to the development branch if you're confident that your code won't break anything badly and the changes are small and fairly trivial.
248+
Otherwise, please create a `pull request` (more on that below).
249+
- Please try to make one change per commit.
250+
If you are fixing three bugs, make three commits.
251+
That way, it is easier to see what was done when, and easier to roll back any changes if necessary.
252+
If you want to make large changes cleaning up whitespace or renaming variables, it is especially important to do so in a separate commit for this reason.
253+
- We have a few angels that follow the changes and each commit to see what happens to their favourite CMS!
254+
If you commit something REALLY sketchy, they will politely contact you, most likely after immediately reverting changes.
255+
There are no official people assigned to this so if you are especially nervous, ask in https://community.plone.org/.
256+
257+
258+
## Commit to `Products.CMFPlone`
259+
260+
If you are working a bug fix on `Products.CMFPlone`, there are a couple other things to take notice of.
261+
First and foremost, you'll see that there are several branches.
262+
At the time of writing this document, there are branches for 4.2.x, 4.3.x and master, which is the implied 5.0.
263+
This may change faster than this documentation, so check the branch dropdown on GitHub.
264+
265+
If the fix is only for one version, make sure to get that branch.
266+
However, chances are the bug is in multiple branches.
267+
268+
Let's say the bug starts in 4.1.
269+
Pull the 4.1 branch and fix and commit there with tests.
270+
271+
If your fix only involved a single commit, you can use git's `cherry-pick` command to apply the same commit to a different branch.
272+
273+
First check out the branch:
274+
275+
```shell
276+
git checkout 4.2
277+
```
278+
279+
And then cherry-pick the commit (you can get the SHA hash from git log):
280+
281+
```shell
282+
git cherry-pick b6ff4309
283+
```
284+
285+
There may be conflicts.
286+
If so, resolve them, then follow the directions git gives you to complete the cherry-pick.
287+
288+
If your fix involved multiple commits, cherry-picking them one by one can get tedious.
289+
In this case, things are easiest if you did your fix in a separate feature branch.
290+
291+
In that scenario, you first merge the feature branch to the 4.1 branch:
292+
293+
```shell
294+
git checkout 4.1
295+
git merge my-awesome-feature
296+
```
297+
298+
Then return to the feature branch, and make a branch for rebasing it onto the 4.2 branch:
299+
300+
```shell
301+
git checkout my-awesome-feature
302+
git checkout -b my-awesome-feature-4.2
303+
git rebase ef978a --onto 4.2
304+
```
305+
306+
(`ef978a` happens to be the last commit in the feature branch's history before it was branched off of 4.1.
307+
You can look at `git log` to find this.)
308+
309+
At this point, the feature branch's history has been updated, but it hasn't actually been merged to 4.2 yet.
310+
This lets you deal with resolving conflicts before you actually merge it to the 4.2 release branch.
311+
Let's do that now:
312+
313+
```shell
314+
git checkout 4.2
315+
git merge my-awesome-feature-4.2
316+
```
317+
318+
### Branches and forks and direct commits - oh my!
319+
320+
```{note}
321+
This section needs a rewrite.
322+
Meanwhile we do not allow direct commits, except in very rare cases.
323+
```
324+
325+
Plone used to be in an svn repository, so everyone is familiar and accustomed to committing directly to the branches.
326+
After the migration to GitHub, the community decided to maintain this spirit.
327+
If you have signed the [contributor agreement](https://plone.org/foundation/contributors-agreement), you can commit directly to the branch.
328+
For Plone, this would be the version branch, whereas for most other packages this would be `main`.
329+
330+
HOWEVER, there are a few situations where a branch is appropriate.
331+
If you:
332+
333+
- are just getting started
334+
- are not sure about your changes
335+
- want feedback or code review
336+
- are implementing a non-trivial change
337+
338+
then you should create a branch of whatever packages you are using, and then use the [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) feature of GitHub to get review.
339+
Everything about this process would be the same except you need to work on a branch.
340+
Take the `plone.app.caching` example.
341+
After checking it out with `mr.developer`, create your own branch with:
342+
343+
```shell
344+
cd src/plone.app.caching
345+
git checkout -b my_descriptive_branch_name
346+
```
347+
348+
```{note}
349+
Branching or forking is your choice.
350+
I prefer branching, and I'm writing the docs so this uses the branch method.
351+
If you branch, it helps us because we *know* that you have committer rights.
352+
Either way it's your call.
353+
```
354+
355+
Proceed as normal.
356+
When you are ready to push your fix, push to a remote branch with:
357+
358+
```shell
359+
git push origin my_descriptive_branch_name
360+
```
361+
362+
This will make a remote branch in GitHub.
363+
Navigate to this branch in the GitHub user interface, and on the top right, there will be a button that says {guilabel}`Pull Request`.
364+
This will turn your request into a pull request on the main branch.
365+
There are people who look once a week or more for pending pull requests and will confirm whether or not it's a good fix, and give you feedback where necessary.
366+
The reviewers are informal and very nice, so don't worry.
367+
They are there to help!
368+
If you want immediate feedback, visit https://community.plone.org/ with the pull request link and ask for a review.
369+
370+
```{note}
371+
You still need to update the file {file}`checkouts.cfg` in the correct branches of `buildout.coredev`!
372+
```
373+
374+
375+
## Finalize issues
376+
377+
If you are working from an issue, please don't forget to go back to the issue, and add a link to the change set.
378+
We don't have integration with GitHub yet so it's a nice way to track changes.
379+
It also lets the reporter know that you care.
380+
If the bug is really bad, consider pinging the release manager and asking them to make a release.
381+
382+
383+
## FAQ
384+
385+
How do I know when my package got made?
386+
: You can follow the project on GitHub, and watch its [timeline](https://github.com/orgs/plone/dashboard).
387+
You can also check the {file}`CHANGES.rst` of every plone release for a comprehensive list of all changes, and validate that yours is present.

coredev/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Please don't put the code reviewers at risk and by ignoring this.
2929
guidelines
3030
agreement
3131
culture
32-
intro
32+
getting-started-with-development
3333
documentation
3434
plips
3535
issues

0 commit comments

Comments
 (0)