Giter VIP home page Giter VIP logo

cf-bottom's Introduction

Northern.tech Bot, Tom

I'm your friendly neighbourhood bot, Tom. I trigger pull requests when someone mentions me in a GitHub Pull Request.

Usage

Command line

If you have valid config and secrets in the current working directory, you can run:

$ python3 -m tom --directory . --log-level info --interactive

(This assumes running in the repo folder, ., and interactive so you will be prompted before any actions are taken).

Example on our (private) Jenkins:

$ ssh ci.cfengine.com
olehermanse@jenkins:~$ sudo su tom
tom@jenkins:/home/olehermanse$ cd ~/
tom@jenkins:/home/tom$ python3 self/tom --log-level INFO
[INFO] Fetching pull requests for cfengine/documentation
[INFO] Fetching pull requests for cfengine/starter_pack
[INFO] Fetching pull requests for cfengine/masterfiles
[INFO] Fetching pull requests for cfengine/buildscripts
[INFO] Fetching pull requests for cfengine/core
[INFO] Fetching pull requests for cf-bottom/self
[...]

CFEngine policy

See the example policy for an automated way to update and run Tom.

To disable policy when testing, you can delete this flag file:

$ cd /home/tom
$ rm TOM_ENABLE

The TOM_ENABLE file is checked by the policy, not the python code. To re-enable:

$ cd /home/tom
$ touch TOM_ENABLE

Config

See our commited config file for an example of what the JSON config file looks like. Note that one config file has multiple "bots", with unique GitHub usernames. Each of those "bots" can be configured to use different Jenkins instances, and separate secrets.

Secrets

Secrets should be kept separate from the rest of the config. The filenames are specified in config.json. It is generally recommended to not commit secrets to git repos. Here is an example of what the secrets file can look like:

{
  "GITHUB_TOKEN": "46fb3751dd0d84cb02f8d8fc68d34ffed3247c4b",
  "JENKINS_USER": "a10062",
  "JENKINS_TOKEN": "de351e7ad2bcb3b2bdca23c5537e054c",
  "JENKINS_CRUMB": "814eeba4337de1f669643c1091aecb59"
}

(The secrets above are fake).

Explanation:

Technical details

Webhooks / polling

Most of the codebase works by polling open pull requests, rather than having a web server wait for Webhooks. There is one exception, the optional slack bot, which can be triggered from mentions in Slack.

development / testing

See run_tests.sh here for a development workflow working with pytest unit tests.

Open htmlcov/index.html to see python code coverage information after test runs.

pass a test name to run_tests.sh and it will only run that one test.

cf-bottom's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.