w3c/prbuildbot

Name: prbuildbot

Owner: World Wide Web Consortium

Description: null

Created: 2017-01-19 13:55:17.0

Updated: 2017-12-17 07:13:30.0

Pushed: 2017-08-03 12:19:07.0

Homepage: null

Size: 41

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

PR Build Bot

The PR Build Bot is a Python web application that listens to Travis CI webhooks and posts selections from the build logs as comments on the GitHub PR. This allows commenting on PRs from both trusted and untrusted branches of the main repository without exposing the GitHub Personal Access Token of the commenting user.

Installation

This bot can be installed in any number of Python server environments. wptserve and Flask options are described below.

Installation as a wptserve application

wptserve is a server used throughout the W3C testing infrastructure. There is currently no Ansible configuration for this installation type. The following general instructions should get you running.

Requirements Process
  1. Install the requests and pyOpenSSL modules into your Python environment.
  2. pyOpenSSL requires a dev version of OpenSSL (e.g. libssl-dev)
  3. Install wptserve.
  4. Clone from GitHub
  5. Run sudo python setup.py install from the cloned directory.
  6. Clone this project and cd into the cloned directory.
  7. Configure the application for your project. See Configuration, below.
  8. Run python wptserve_app.py
  9. May require sudo if you receive a “Permission Denied” error.
Installation on Dedicated Server with nginx as a Flask application

This installation process uses Ansible to configure the server to use nginx and uWSGI to serve a Flask application. It expects nginx to be able to use port 80.

Requirements Process

This is how to install the dependencies and application on a base Ubuntu 16.04 box. Git should come out of the box.

  1. Create a server instance wherever you like.
  2. Add a non-root user to own the application.
  3. adduser prbuildbot as root
  4. You will create a password for this user. Keep it secret. Keep it safe.
  5. Ensure the new user is able to sudo.
  6. adduser prbuildbot sudo as root
  7. Log into the server as the new user.
  8. Update apt repositories
  9. sudo apt-get update
  10. Install pip. sudo apt install python-pip
  11. Upgrade pip.
  12. sudo -H pip install --upgrade pip
  13. Install libssl-dev.
  14. sudo apt install libssl-dev
  15. Install Ansible.
  16. sudo -H pip install ansible
  17. Fork this repository and clone it into the user's home directory.
  18. git clone https://github.com/<your user name>/prbuildbot.git
  19. You will be editing a file under version control, so you should create your own fork and store your changes there.
  20. Configure the application for your project. See Configuration, below.
  21. Change into the ansible directory and run the provisioning script.
  22. cd prbuildbot/ansible
  23. ansible-playbook provision.yml
  24. Note: this must be run from the prbuildbot/ansible directory, or it will fail.
  25. Note: This does not install any of the python modules into virtual_env, but at the system level. This is possible with Ansible, just not implemented yet.
Configuration

You will need to set up a user on GitHub, get a personal access token for them, and set up the configuration file for the application.

  1. Set up a user on GitHub that you want to be the “commenter.”
  2. Get a Personal Access Token for that user.
  3. Go to https://github.com/settings/tokens.
  4. Click “Generate new token”
  5. On the creation page, name the token and give it at least public_repo and user:email permissions.
  6. Set up the configuration file on the server.
  7. In the application directory: cp config.sample.txt config.txt
  8. Edit the config properties as necessary (see below for descriptions)
  9. Edit log_parser.py to parse the Travis CI job logs in whatever way you require.
  10. The included log_parser.py includes the logic for parsing log files for w3c/web-platform-tests as an example.
  11. You should commit this file back into your fork so that you don't lose it in case you lose or change your server.
  12. Do not ever commit your config.txt, as it contains your Personal Access Token.
  13. Add a webhook notification in your main project's .travis.yml file:
  14. fications:
    bhooks: http://<your-server-here>/prbuildbot/travis
    
  15. Your server can be referenced by either an IP address or a fully-qualified domain name.
  16. Once your updated .travis.yml file is in your project, you should start receiving comments on pull requests from this bot.
  17. Example: https://github.com/bobholt/web-platform-tests/pull/4
Configuration Properties

| Property | Description | |—————–|—————————————————————————————————————————————————–| | TRAVIS_DOMAIN | The Travis CI domain that applies to your application (either travis-ci.com or travis-ci.org) | | COMMENT_ENV_VAR | An environment variable used in your Travis CI build matrix that serves as a flag for whether or not the job's log should be parsed as a PR comment | | GH_TOKEN | The Personal Access Token created in Configuration Step 2, above | | ORG | The GitHub organization/owner of the main repository (this project's ORG would be “bobholt”) | | REPO | The main repository (this project's REPO would be “prbuildbot”) |

Testing

In the application root run python test. If you have changed the log_parser, you will have to update the log_parser.parse_logs tests for your own application.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.