Project

General

Profile

PrProcessor » History » Revision 6

Revision 5 (Dominic Cleal, 09/09/2016 09:53 AM) → Revision 6/9 (Dominic Cleal, 10/13/2016 06:19 AM)

h1. 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. 

 h2. 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. 

 h2. 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 - more information on the "Jenkins":http://projects.theforeman.org/projects/foreman/wiki/Jenkins#PR-scanner-repo-hooks wiki page. 

 It sets labels and performs checks on the PR to ensure it meets our usual standards. 

 h3. 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. 

 h3. Commit message styles 

 For repositories in "repos.yaml":https://github.com/theforeman/prprocessor/blob/master/config/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 

 If it fails this check, it will add the _Waiting on contributor_ label and leave a comment. 

 h3. 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. 

 h2. 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":https://github.com/theforeman/prprocessor/blob/master/config/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. 

 h2. 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":http://projects.theforeman.org/projects/foreman/wiki/Jenkins#PR-scanner. 

 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.    No further action is taken by the prprocessor.