Project

General

Profile

PrProcessor » History » Version 8

Dominic Cleal, 12/21/2016 06:31 AM
webhook

1 1 Dominic Cleal
h1. PR Processor
2
3
prprocessor is a web service hosted on the project's OpenShift account, which receives GitHub webhooks/notifications and helps sync PRs to Redmine and Jenkins.
4
5
It's a simple Sinatra app, and the source is available here: https://github.com/theforeman/prprocessor.
6
7
h2. OpenShift
8
9
It runs on OpenShift using a group account, to which a few developers have push access to.  When merging into the GitHub repository, please keep this in sync with OpenShift's repo by pushing to both.
10
11
h2. GitHub integration
12
13 8 Dominic Cleal
It receives requests from GitHub when pull requests are opened or synchronized (updated).  These contain lots of info about the PR, including the author, branches etc.  A repository admin needs to add the webhook to send these events:
14 1 Dominic Cleal
15 8 Dominic Cleal
* run @GITHUB_SECRET_TOKEN=... scripts/add_webhook.sh theforeman/foreman_example@
16 1 Dominic Cleal
17 8 Dominic Cleal
All repositories must then be added to the prprocessor configuration file:
18
19
* edit "config/repos.yaml":https://github.com/theforeman/prprocessor/blob/master/config/repos.yaml
20
21 2 Dominic Cleal
h3. Labels
22
23
When a PR is first opened, it sets:
24
25
* _Not yet reviewed_
26
* _Needs testing_
27
28 6 Dominic Cleal
When a "needs changes" (rejected) PR review is filed, it:
29
30
* Removes any _Not yet reviewed_ or _Needs re-review_ labels
31
* Sets _Waiting on contributor_
32
33 2 Dominic Cleal
When a PR is updated, it:
34
35
* Removes any _Waiting on contributor_ label
36 3 Dominic Cleal
* Sets _Needs testing_
37 2 Dominic Cleal
* If the _Not yet reviewed_ label is missing, it sets _Needs re-review_
38
39
This encourages the workflow for reviewers to remove the _Not yet reviewed_ label when they've made the first review.  When the PR is updated, it gets _Needs re-review_ so they can attend to it sooner, before starting on new PRs.
40
41 4 Lukas Zapletal
When a PR is not updated for six months with _Waiting on contributor_ label, it:
42
43
* Adds a comment
44
* Sets _Inactive_ label
45
* Closes the PR
46
47
Every week, maximum of five inactive pull requests are closed.
48
49 1 Dominic Cleal
h3. Commit message styles
50
51 5 Dominic Cleal
For repositories in "repos.yaml":https://github.com/theforeman/prprocessor/blob/master/config/repos.yaml where @redmine_required@ is true, it enforces that:
52 1 Dominic Cleal
53
# Commit messages match the style in [[Reviewing_patches-commit_message_format]]
54
# A Redmine ticket is referenced in the commit message
55 7 Dominic Cleal
# Any Redmine tickets are filed in the same project as the repo
56 1 Dominic Cleal
57 2 Dominic Cleal
If it fails this check, it will add the _Waiting on contributor_ label and leave a comment.
58
59 1 Dominic Cleal
h3. PR is mergeable
60
61
It checks whether the PR is mergeable against the branch it's proposed for.  This will only pick up this error when the PR is updated because the service is event-driven, so it won't notify authors when a PR goes out of sync due to master/develop being changed, and the PR is not updated.
62 2 Dominic Cleal
63
If it fails this check, it will replace any waiting review labels with the _Waiting on contributor_ label and leave a comment.
64 1 Dominic Cleal
65
h2. Redmine integration
66
67
When it receives an event, the corresponding Redmine ticket is updated to link it to the pull request.  The script updates these fields:
68
69
# _Status_ is changed to _Ready for Testing_
70
# _Assigned To_ is changed to the PR author - update "users.yaml":https://github.com/theforeman/prprocessor/blob/master/config/users.yaml for new or unknown developers
71
# _Target version_ (usually sprints) is set to the latest available version
72
# _Pull request_ is set to the URL of the PR
73 5 Dominic Cleal
74 1 Dominic Cleal
The repositories listed in repos.yaml will also be synchronised on the Redmine instance using an hourly cronjob, and Redmine will associate commits and close tickets based on what's merged. Use "fixes #99999" to add the commit and close the ticket or "refs #99999" to only add the commit.
75
76 8 Dominic Cleal
The default repository branch (as defined in the GitHub repo settings) is the only branch that will be synchronised to Redmine. To add more, edit @branches@ in "repos.yaml":https://github.com/theforeman/prprocessor/blob/master/config/repos.yaml.
77
78 1 Dominic Cleal
h2. Jenkins integration
79
80
A "PR scanner" job runs regularly on Jenkins and is responsible for all checking, testing and updating of pull requests.  Since it uses a lot of API queries, it only runs every 30 minutes.  More about this job is on the "Jenkins wiki page":http://projects.theforeman.org/projects/foreman/wiki/Jenkins#PR-scanner.
81
82 8 Dominic Cleal
To get faster PR testing, when a PR hook is received by the prprocessor, it triggers an immediate run/build of the Jenkins scanner job against the relevant PR when the "pr_scanner" config entry is enabled.  No further action is taken by the prprocessor.