Skip to content

Commit 7605c31

Browse files
committed
feat: rewrite the continuous integration docs
1 parent 53e678b commit 7605c31

File tree

1 file changed

+29
-77
lines changed

1 file changed

+29
-77
lines changed

docs/contributing/core/continuous-integration.md

Lines changed: 29 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,103 +9,55 @@ myst:
99

1010
# Essential continuous integration practices
1111

12-
The {term}`CI` system at [jenkins.plone.org](https://jenkins.plone.org) is a shared resource for Plone core developers to notify them of regressions in Plone core code.
12+
As a complex system build out of hundreds of small packages, Plone can be easily broken, inadvertently, with any change on any of its packages.
1313

14-
Build breakages are a normal and expected part of the development process.
15-
The aim is to find errors and remove them as quickly as possible, without expecting perfection and zero errors.
16-
However, there are some essential practices that you need follow to achieve a stable build:
14+
For that a mix of a {term}`CI` system at [jenkins.plone.org](https://jenkins.plone.org) and GitHub Actions ensure that any change is thoroughly checked.
1715

16+
Even better, if we allow to test a given set of changes **before** integrating them, we can be much more confident, that our changes will not break.
1817

19-
## 1) Don't check in on a broken build
18+
That's exactly what we do at Plone, here is how:
2019

21-
Do not make things more complicated for the developer who is responsible for breaking the build.
20+
## Pull requests
2221

23-
If the build breaks, the developer has to identify the cause of the breakage as soon as possible and should fix it.
24-
This strategy gives the developer the best option to find out what caused the breakage and fix it immediately.
25-
Fixing the build is easier with a clear look at the problem.
26-
Checking in further changes and triggering new builds will complicate matters and lead to more problems.
22+
An essential, and basic, point for all that is explained here to work is that we **do not commit to the main branch directly**.
2723

28-
If the build is broken over a longer period of time (more than a couple of hours) you should either:
24+
Fortunately, GitHub, GitLab, and other source forgeries, have popularized the idea of pull/merge requests: rather than pushing your changes on the main branch, you push them to a separate branch.
2925

30-
- notify the developer who is responsible for the breakage
31-
- fix the problem yourself
32-
- revert the commit so you and others can continue to work
26+
This apparently simple change has plenty of postive effects:
3327

34-
```{note}
35-
There is one exception to this rule.
36-
Sometimes there are changes or tests that depend on changes in other packages.
37-
If this is the case, there is no way around breaking a single build for a certain period of time.
38-
In this case, run the all tests locally with all the changes and commit them within a time frame of ten minutes.
39-
```
40-
41-
42-
## 2) Always run all commit tests locally before committing
43-
44-
Follow this practice so the build stays green, and other developers can continue to work without breaking the first rule.
45-
46-
Remember that Plone development can happen all over the world, at all times.
47-
Other developers may have checked in changes since your last synchronization.
48-
These may interact with your work.
49-
50-
Therefore it's essential that you merge changes from the main branch into your feature branch, then run the tests again, before you push your changes to GitHub.
51-
52-
A common source of errors on check-in is to forget to add some files to the repository.
53-
Use {command}`git status` to check and correct for this.
54-
Also double-check to not check in files that should not be part of a package, such as editor configuration files and git submodules.
55-
56-
57-
## 3) Wait for commit tests to pass before moving on
58-
59-
Always monitor the build's progress, and fix the problem right away if it fails.
60-
If you introduced a regression, you have a far better chance of fixing the build sooner than later.
61-
Also another developer might have committed in the meantime (by breaking rule 1), making things more complicated for you.
28+
- code can be shared without the fear of breaking anything
29+
- changes can be reviewed and improved by peer developers
30+
- automated checks can be performed
31+
- external integrations can run and provide reports
6232

33+
## GitHub Actions
6334

64-
## 4) Never go home on a broken build
35+
The first quick feedback one gets when creating a pull request is the automated GitHub Actions configured on that repository.
6536

66-
Take into account the first rule of CI ("Don't check in on a broken build").
67-
Breaking the build essentially stops all other developers from working on it.
68-
Therefore going home on a broken build—or even on a build that has not finished yet—is _not_ acceptable.
69-
It will prevent all other developers from working, or they will need to fix the errors that you introduced.
37+
They can range from security checks (is the committer allowed to commit on this repository?) to full automation pipelines (create a docker image and automatically deploy it on a test server).
7038

39+
When it comes to continuous integration, GitHub Actions provides a first front line to ensure that the changes on the package itself remain valid: not only that tests do pass, but also that all quality checks configured are upheld.
7140

72-
## 5) Always be prepared to revert to the previous revision
41+
## Jenkins
7342

74-
For other developers to work on the build, you should always be prepared to revert to the previous passing revision.
43+
What GitHub Actions is for a single package, jenkins.plone.org is for the complete Plone packages.
7544

45+
It not only tests changes to be made, but also pull requests pending to be merged.
7646

77-
## 6) Time-box fixing before reverting
47+
Even better, when a set of changes span across multiple repositories, jenkins.plone.org still can test the combination of all the pull requests together.
7848

79-
When the build breaks on check-in, try to fix it for ten minutes.
80-
If, after ten minutes, you aren't finished with the solution, revert to the previous version from your version control system.
81-
This way you will allow other developers to continue to work.
49+
### As simple as a comment
8250

51+
For the usual use case of testing a single pull request, a special crafted comment on the pull request itself is the only step that you need to do to get jenkins to run the tests against your changes.
8352

84-
## 7) Don't comment out failing tests
53+
The special crafted comment is no secret, rather the other way around, the `mister-roboto` GitHub user greets you every time you create a new pull requests and reminding you of how to trigger jenkins:
8554

86-
Once you begin to enforce the previous rule, the result is often that developers start commenting out failing tests in order to get the build passing again as quickly as possible.
87-
While this impulse is understandable, it is _not acceptable_.
88-
89-
The tests were passing for a while and then start to fail.
90-
This means that you either caused a regression, made assumptions that are no longer valid, or the application has changed the functionality being tested for a valid reason.
91-
92-
You should always either fix the code (if a regression has been found), modify the test (if one of the assumptions has changed), or delete it (if the functionality under test no longer exists).
93-
94-
95-
## 8) Take responsibility for all breakages that result from your changes
96-
97-
If you commit a change and all the tests you wrote pass, but others break, the build is still broken.
98-
This also applies to tests that fail in `buildout.coredev` and don't belong directly to the package you worked on.
99-
This means that you have introduced a regression bug into the application.
100-
101-
It is _your responsibility_ to fix all tests that do not pass because of your changes.
102-
103-
There are some tests in Plone that fail randomly, and the community is always working on fixing those.
104-
If you think you hit such a test, try to fix it or re-run the Jenkins job to see if it passes again.
105-
106-
In any case, the developer who made the commit is responsible to make it pass.
55+
```text
56+
@jenkins-plone-org please run jobs
57+
```
10758

59+
With that comment on a pull request, jenkins will set up a matrix of jobs to ensure that your changes work across any Plone versions and python versions that we currently support.
10860

109-
## Further reading
61+
### mr.roboto
11062

111-
These rules were taken from the excellent book "Continuous Delivery" by Jez Humble and David Farley (Addison Wesley), and have been adopted and rewritten for the Plone community.
63+
The link between Jenkins and GitHub is encoded in mr.roboto, a service that is hooked into all Plone repositories and reacts at any change in them.

0 commit comments

Comments
 (0)