Giter Club home page Giter Club logo

slack-prbot's Introduction

PR Bot

DEPRECATION NOTICE

Using this slack bot to list your open PRs is not recommended, because in the past it has exhausted the free tier on Heroku, so it sometimes doesn't work.

In the time since this bot was created, GitHub have acquired Pull Panda, which offers a superset of this functionality. Pull panda is free to use, so that is now the recommended approach.

Pull Panda is available via the GitHub Marketplace.

Introduction

This is a simple ruby slack bot to announce open github pull requests for selected repositories into slack. It is based on the examples found in the repo https://github.com/slack-ruby/slack-ruby-bot.git

Setup

  • Host this app somewhere - heroku is fine.
  • You'll need to add it in slack (you will need suitable permissions for this):
    • Set up an outgoing webhook
    • Set the URL
    • Set up some suitable trigger words. open prs, open pulls, open pull requests is a sensible default.
    • Set some appropriate channels to listen in, or use Any.
  • Set up environment variables for the app as below (you can find the value for the token from your slack outgoing hook setup)
  • Optionally set up a reminder in some slack channels - something like: /remind #<channel> every weekday at 9am open prs for team <X>. If you want to use reminders, you'll need to add Reminder: open prs (or similar) to the list of trigger words.

Configuration

In the spirit of 12 factor, configuration is done via the environment. Needed settings are:

  • WEBHOOK_TOKEN - a token for the bot to use to authenticate to the Slack API.
  • GH_ORG - which github organisation to poll.
  • GH_TOKEN - a token for the above username. Read access to your org repos is needed.

Development

See the makefile for details of how to run the bot code locally, during development.

Usage

If you use the automated reminders then this will trigger a message which in turn will be sent to your bot. But you can also perform manual queries by sending a channel message:

  • open prs - a default list of repositories
  • open prs in repo <x> - queries a specific repository
  • open prs for team <x> - queries all repos to which the team has access

Updating gems

To update specific gems, you can follow this procedure:

  • comment out the USER appuser line in the Dockerfile (we need access to /usr/local to update gems, so do it as root)
  • run make clean; make build
  • run mkdir tmp
  • run docker run --rm -it -v $(pwd)/tmp:/tmp cloud-platform-slack-prbot bash
  • inside the container, run bundle update graphql-client
  • inside the container, run cp Gemfile.lock /tmp
  • outside the container, run cp tmp/Gemfile.lock Gemfile.lock
  • uncomment the USER appuser line in the Dockerfile
  • bump the version tag in the makefile
  • commit the updated makefile and Gemfile.lock
  • run make clean; make build; make docker-push

slack-prbot's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar digitalronin avatar stevemarshall avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-prbot's Issues

A branch protection setting is not enabled: administrators require review

Hi there
The default branch protection setting called administrators require review is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require a pull request before merging option
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Default branch is not main

Hi there
The default branch for this repository is not set to main
See repository settings/settings/branches to rename the default branch to main and ensure the Branch protection rules is set to main as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Teams with many repos can't be queried

If there is a team which has many repos then it could take more than 30 seconds to compile the results (due to the number of subqueries). The problem with this is that heroku times out after 30 seconds after no response from the app and thus a 500 is returned (which doesn't get inserted into slack)

Several solutions come to mind, though I invite additional ideas (or discussion of these)

  1. Have a timeout and return a partial response (perhaps with a message indicating that the results are truncated). This is the simplest solution with the caveat of incomplete visibility.
  2. Introduce a queue whereby jobs (i.e. queries) are added and then the results compiled by a job runner. This would then give an asynchronous message back to slack (presumably via an outgoing webhook). This is massively more complex and would mean that we couldn't use the free heroku tier, but would at least give full results.
  3. Perform the queries in parallel to the individual repos of a team (function read_team_prs in web.rb, currently defined at https://github.com/ministryofjustice/slack-prbot/blob/master/web.rb#L16). This might end up hitting some rate limiting - either inbound at GitHub or outbound from heroku.

A branch protection setting is not enabled: codeowners require reviews

Hi there
The default branch protection setting called codeowners require review is not enabled for this repository
This option affects a pull request, i.e a PR will need to be reviewed and approved by a CODEOWNER before it can be merged.
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require review from Code Owners option
Create a .github/CODEOWNERS file
Add a or multiple entries of @ministryofjustice/team_name to the CODEOWNERS file
The team_name shall be a team from within the MoJ teams: https://github.com/orgs/ministryofjustice/teams
See GH Codeowners documentation: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

A branch protection setting is not enabled: requires approving reviews

Hi there
The default branch protection setting called requires approving reviews is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require approvals option
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

A branch protection setting is not enabled: Include administrators

Hi there
The default branch protection setting called Include administrators is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Include administrators option
This will enable the branch protection rules to admin uses as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

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.