PR Processor¶
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.
It's a simple Sinatra app, and the source is available here: https://github.com/theforeman/prprocessor.
GitHub integration¶
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:
- run
GITHUB_SECRET_TOKEN=... scripts/add_webhook.sh theforeman/foreman_example
All repositories must then be added to the prprocessor configuration file:
- edit config/repos.yaml
Labels¶
When a PR is first opened, it sets:
- Not yet reviewed
- Needs testing
When a "needs changes" (rejected) PR review is filed, it:
- Removes any Not yet reviewed or Needs re-review labels
- Sets Waiting on contributor
When a PR is updated, it:
- Removes any Waiting on contributor label
- Sets Needs testing
- If the Not yet reviewed label is missing, it sets Needs re-review
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.
When a PR is not updated for six months with Waiting on contributor label, it:
- Adds a comment
- Sets Inactive label
- Closes the PR
Every week, maximum of five inactive pull requests are closed.
Commit message styles¶
For repositories in repos.yaml where redmine_required
is true, it enforces that:
- Commit messages match the style in Reviewing_patches-commit_message_format
- A Redmine ticket is referenced in the commit message
- Any Redmine tickets are filed in the same project as the repo
If it fails this check, it will add the Waiting on contributor label and leave a comment.
PR is mergeable¶
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.
If it fails this check, it will replace any waiting review labels with the Waiting on contributor label and leave a comment.
Redmine integration¶
When it receives an event, the corresponding Redmine ticket is updated to link it to the pull request. The script updates these fields:
- Status is changed to Ready for Testing
- Assigned To is changed to the PR author - update users.yaml for new or unknown developers
- Target version (usually sprints) is set to the latest available version
- Pull request is set to the URL of the PR
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.
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.
Jenkins integration¶
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.
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.
OpenShift¶
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.
Updated by Dominic Cleal about 8 years ago · 9 revisions