Giter Club home page Giter Club logo

seal's Introduction

Seal

Build Status

##What is it?

This is a Slack bot that publishes a team's pull requests to their Slack Channel, once provided the organisation name, the team members' github names, and a list of repos to follow. It is my first 20% project at GDS.

image image

##How to use it? Fork the repo, and change the config file to put: your team's name, the github names of your team members, the list of repos to follow, and the Slack channel you want to post to.

In your shell profile, put in:

export SEAL_ORGANISATION="your_github_organisation"
export GITHUB_TOKEN="get_your_github_token_from_yourgithub_settings"
export SLACK_WEBHOOK="get_your_incoming_webhook_link_for_your_slack_group_channel"

To test the script locally, go to Slack and create a channel or private group called "#angry-seal-bot-test". Then run ./bin/informative_seal.rb your_team_name in your command line, and you should see the post in the #angry-seal-bot-test channel.

When that works, you can push the app to Heroku, add the GITHUB_TOKEN and SLACK_WEBHOOK environment variables to heroku, and use the Heroku scheduler add-on to create repeated rasks - I set Informative Seal to run at 9.30am every morning (the seal won't post on weekends), and will set Angry Seal to run every afternoon.

Any questions feel free to contact me on Twitter - my handle is binaryberry

##How to run the tests? Just run rspec in the command line

Diary of how this app was built

10th April:

  • Finalised what the app does:

    • Hourly, checks if any pull requests are over 6 hours old (angry seal)
    • at 9.45am prepares an overview of all pull requests that need reviewing (informative seal)
    • when a team member posts a new pull request, publishes it on slack (notification seal) (this feature was then abandoned, as I thought it's best for this not to be automated, it's more motivating when real people ask for a review, not a bot)
  • Researched what technologies and gems I could use and what the app structure would be like

  • Started the Rails app

17th April:

  • researched github_api

24th April:

  • got github_api working, first test with dummy data passing

1st of May

  • got github_listener to take into account organisations

8th of May:

  • tried stubbing Github API

15th of May:

21st of May:

  • Building Sinatra app for stubbing
  • Attempts to filter the 3,400 repo list by date the repo was modified - tests (and app) are still very slow

28th of May:

  • Due to new team structure that assigns a list of repos to each team, decided the manually enter the list of repos that belong to a team instead of scanning through all of them. That should sort the speed problem, the stubbing problem, a lot of things.
  • moved to a non-Rails app to make it lighter
  • got Github to list repos; works for my personal pull requests, but doesn't work with the GOV.UK stuff yet, need to figure out why

5th of June:

  • Github fetcher class now works with organisations, hence GOV.UK stuff

11th of June:

  • Stubbed Github API

12th of June:

  • Github Fetcher now also returns the link to the pull request
  • Started Slackbot poster class, it can post to Slack
  • Started Message builder class, not finished

13th of June:

  • finished Slackbot poster class
  • finished Message builder class
  • added name of repo to info sent by GithubFetcher
  • added options to the Slackbot poster class so each post comes from informative seal
  • Works locally in test room. YEAY!

17th of June:

  • refactoring of Github fetcher
  • pushed to Heroku

18th of June:

  • started Heroku scheduler and launched on core-formats team room!

22nd of June

  • Ensure Angry seal doesn't get triggered at the weekend

26th of June:

  • launched on finding-stuff team
  • investigated adding comments

3rd of July:

  • launched on custom team
  • added comments
  • investigating angry seal - stuck by a strange syntax error line 34 when trying to run the script

10th of July

  • Extracted config information to yaml files
  • fixed informative seal - mood_hash was causing issues

17th of July

  • Angry Seal!

21st of July

  • fix API stubbing

22nd of July

  • Add age of pull requests

24th of July

  • Optionally display labels for a pull request, if they exist (use_labels config option)
  • Optionally hide pull requests with certain labels (exclude_labels config list)
  • Optionally hide pull requests with certain phrases in the title (exclude_titles config list)

Tips

How to list your organisation's repositories modified within the last year:

In irb, from the folder of the project, run:

require 'octokit'
github = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'], auto_pagination: true)
response = github.repos(org: ENV['SEAL_ORGANISATION'])
repo_names = response.select { |repo| Date.parse(repo.updated_at.to_s) > (Date.today - 365) }.map(&:name)

CRC

Github fetcher:

  • queries Github's API

Message Builder:

  • produces message from Github API's content

Slack Poster:

  • posts message to Slack

Trello board: https://trello.com/b/sgakJmlY/moody-seal

seal's People

Contributors

johnsyweb avatar binaryberry avatar tommyp avatar issyl0 avatar tijmenb avatar

Watchers

James Cloos avatar Step1Profit 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.