Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

w3c/prbuildbot

Repository files navigation

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

  • Python 2.7

Process

  1. Install the requests and pyOpenSSL modules into your Python environment.
  • pyOpenSSL requires a dev version of OpenSSL (e.g. libssl-dev)
  1. Install wptserve.
  • Clone from GitHub
  • Run sudo python setup.py install from the cloned directory.
  1. Clone this project and cd into the cloned directory.
  2. Configure the application for your project. See Configuration, below.
  3. Run python wptserve_app.py
  • 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

  • Ubuntu-like server environment
  • git
  • Ansible >= 2.2.1.0
    • Note: on Ubuntu, this requires installing ansible via pip, not apt.

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.
  • adduser prbuildbot as root
  • You will create a password for this user. Keep it secret. Keep it safe.
  1. Ensure the new user is able to sudo.
  • adduser prbuildbot sudo as root
  1. Log into the server as the new user.
  2. Update apt repositories
  • sudo apt-get update
  1. Install pip. sudo apt install python-pip
  2. Upgrade pip.
  • sudo -H pip install --upgrade pip
  1. Install libssl-dev.
  • sudo apt install libssl-dev
  1. Install Ansible.
  • sudo -H pip install ansible
  1. Fork this repository and clone it into the user's home directory.
  • git clone https://github.com/<your user name>/prbuildbot.git
  • You will be editing a file under version control, so you should create your own fork and store your changes there.
  1. Configure the application for your project. See Configuration, below.
  2. Change into the ansible directory and run the provisioning script.
  • cd prbuildbot/ansible
  • ansible-playbook provision.yml
  • Note: this must be run from the prbuildbot/ansible directory, or it will fail.
  • 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.
  1. Set up the configuration file on the server.
  • In the application directory: cp config.sample.txt config.txt
  • Edit the config properties as necessary (see below for descriptions)
  1. Edit log_parser.py to parse the Travis CI job logs in whatever way you require.
  • The included log_parser.py includes the logic for parsing log files for w3c/web-platform-tests as an example.
  • You should commit this file back into your fork so that you don't lose it in case you lose or change your server.
  • Do not ever commit your config.txt, as it contains your Personal Access Token.
  1. Add a webhook notification in your main project's .travis.yml file:
  • notifications:
      webhooks: http://<your-server-here>/prbuildbot/travis
    
  • Your server can be referenced by either an IP address or a fully-qualified domain name.
  1. Once your updated .travis.yml file is in your project, you should start receiving comments on pull requests from this bot.

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages