| 1 |
This directory contains the Github webhook for verifying that all |
| 2 |
commits on an ofiwg PR contain a "Signed-off-by" line, and its |
| 3 |
relevant configuration. |
| 4 |
|
| 5 |
The bot runs as a Ruby Sinatra server on flatbed.openfabrics.org. It |
| 6 |
was initially heavily inspired by |
| 7 |
http://git-scm.com/book/en/v2/GitHub-Scripting-GitHub. |
| 8 |
|
| 9 |
The original flatbed server was running RHEL (CentOS, actually, but |
| 10 |
close enough). As of Feb 2016, it is now Ubuntu. So this README |
| 11 |
shows info about both Ubunutu and RHEL (mainly for hysterical |
| 12 |
raisins). |
| 13 |
|
| 14 |
=================== |
| 15 |
|
| 16 |
RHEL background: |
| 17 |
|
| 18 |
Sadly, I did not take good notes about how to get Sinatra installed on |
| 19 |
Flatbed. Looking on flatbed on 17 Feb 2016, I see the following RPMs |
| 20 |
installed: |
| 21 |
|
| 22 |
- rubygems |
| 23 |
- rubygem-sinatra |
| 24 |
|
| 25 |
These seem to be the key RPMs to install. Hopefully, they're in the |
| 26 |
CentOS yum repo -- I do not have any notes on where I got them from. |
| 27 |
The following RPMs seem to be dependencies of Sinatra; hopefully yum |
| 28 |
just pull them in: |
| 29 |
|
| 30 |
- rubygem-crack |
| 31 |
- rubygem-daemons |
| 32 |
- rubygem-rack-test |
| 33 |
- rubygem-httparty |
| 34 |
- rubygem-eventmachine |
| 35 |
- rubygem-thin |
| 36 |
- rubygem-rack |
| 37 |
- rubygem-json |
| 38 |
|
| 39 |
Ubuntu backgruond: |
| 40 |
|
| 41 |
On Ubuntu, it was straightforward to install the Sinatra server: |
| 42 |
|
| 43 |
# apt-get install ruby-sinatra ruby-htttparty |
| 44 |
|
| 45 |
=================== |
| 46 |
|
| 47 |
There are several important files in this directory: |
| 48 |
|
| 49 |
1. github-webhook-ofiwg-init.d-rhel and |
| 50 |
github-webhook-ofiwg-init.d-ubuntu |
| 51 |
|
| 52 |
The /etc/init.d/github-webhook-ofiwg (one for RHEL and one for Ubuntu) |
| 53 |
script that starts and stops the Ruby Sinatra server script that |
| 54 |
actually listens for the incoming Github webhook pings. |
| 55 |
|
| 56 |
2. verify-signed-off.rb |
| 57 |
|
| 58 |
The Ruby Sinatra server (i.e., a Ruby script that uses the Sinatra |
| 59 |
framework for listening for incoming HTTP requests) that listens for |
| 60 |
Github webhook pings. When it gets an incoming ping, if it's for a |
| 61 |
pull request, the script gets a listing of all the commits on that |
| 62 |
pull request and verifies that they all have a "Signed-off-by" line in |
| 63 |
them. If they all do, all commits have a "success" status set (at |
| 64 |
Github). If any are missing this line, then those commits have a |
| 65 |
"failed" status set, and the last commit on the PR also has a "failed" |
| 66 |
status set (because Github shows the overall status of the PR as the |
| 67 |
last commit's status). |
| 68 |
|
| 69 |
Every time commits are pushed to the PR, all the commits will be |
| 70 |
checked again. This ensures that even if you replace all the commits, |
| 71 |
we'll check them all (it's one HTTP request to get all the commit |
| 72 |
messages, anyway, so it's not like it makes the check take |
| 73 |
significantly longer). |
| 74 |
|
| 75 |
Note that the Ruby Sinatra server listens on localhost port 5000; it |
| 76 |
is not directly accessible to the outside world. |
| 77 |
|
| 78 |
On flatbed.openfabrics.org, the file is located in: |
| 79 |
|
| 80 |
RHEL: /var/www/github-webhooks/ofiwg/verify-signed-off.rb |
| 81 |
Ubuntu: /var/www/html/github-webhooks/ofiwg/verify-signed-off.rb |
| 82 |
|
| 83 |
3. apache-config.txt |
| 84 |
|
| 85 |
This is a snipit from flatbed.openfabrics.org: |
| 86 |
|
| 87 |
RHEL: /etc/httpd/conf.d/20-ssl.conf |
| 88 |
Ubuntu: etc/apache2/mods-enabled/proxy.conf |
| 89 |
|
| 90 |
This snipit is inserted in the SSL version of www.openfabrics.org |
| 91 |
config to enable the reverse proxy (i.e., incoming web requests to |
| 92 |
https://www.openfabrics.org/github-webhooks/ofiwg get routed |
| 93 |
internally to http://localhost:5000/ -- i.e., the Ruby Sinatra |
| 94 |
server). |
| 95 |
|
| 96 |
On Ubuntu, I had to load the mod_proxy Apache module by: |
| 97 |
|
| 98 |
# a2enmod proxy |
| 99 |
# a2enmod proxy_http |
| 100 |
# cd /etc/apache2/mods-enabled |
| 101 |
# ln -s ../mods-available/proxy.conf |
| 102 |
^^ This is the file to add the apache proxy config |
| 103 |
|
| 104 |
=================== |
| 105 |
|
| 106 |
There is one additional file needed on flatbed.openfabrics.org: |
| 107 |
|
| 108 |
RHEL: /etc/sysconfig/github-webhook-ofiwg |
| 109 |
Ubuntu: /etc/default/github-webhook-ofiwg |
| 110 |
|
| 111 |
The init.d script will source this file; it needs to set an |
| 112 |
environment variable that verify-signed-off.rb will look for: |
| 113 |
$GITHUB_AUTH_TOKEN. |
| 114 |
|
| 115 |
Specifically, this file should contain a line like this: |
| 116 |
|
| 117 |
export GITHUB_AUTH_TOKEN="...the token..." |
| 118 |
|
| 119 |
(this file is not here in the git repo, of course -- because then |
| 120 |
everyone could see our auth token!) |
| 121 |
|
| 122 |
A Github auth token can be obtained from |
| 123 |
https://github.com/settings/tokens of a user who has commit access to |
| 124 |
the target Github repo(s). The token needs to have the following |
| 125 |
permissions when you create it: |
| 126 |
|
| 127 |
- repo |
| 128 |
- public_repo |
| 129 |
- repo:status |