All Case Studies Design Development Interviews Our Way Project Management

Work Faster, Get Relaxed, Tidy Up Your GitHub Chaos. PRCoolBot Is Here

Every dev forgets to set correct Github labels on his/her pull request once in awhile, right? Not anymore. Thanks to a new bot created by Netguru you will never forget to set correct labels! Focus on your code and forget about everything else. PR cool bot will do it for you.

Problem: Too many labels and too little time

Working with pull requests has undoubtable advantages. The features are organized and separate from one another. All the tasks in a given branch are shown in one convenient interface. Since we need to follow some guidelines as a company, we keep all pull requests from different projects organised in a similar way. Each pull request must have a correct description and correct labels showing the current state of the work. But we’re all humans and we forget things. The PR Cool Bot is my attempt at solving this problem.

Process: How I tried to kill the labels

I started with some research on what I could achieve in the Github API and what would be the best way to inform a user if the format of their pull request is invalid. I had gone through many ideas: from notifications on Slack, to Github comments. Eventually, after a short consultation with my coworkers, I decided to use Github’s pull request status.

image00-5.png

Pull request status is a mechanism used to validate pull requests by many external tools, such as CircleCI or Hound. Whenever an error occurs, the status shows a short message saying what went wrong.

image01-4.png

I decided that this would be the most convenient way of informing a user. Both Slack notifications and Github comments have their disadvantages: hardly anyone reads every single Slack notification, whereas Github comments can sometimes be too intrusive.

Next, I started to think how I could come up with the most universal implementation possible. The bot was supposed to be easily reusable by different people in different cases. I created a validation system that consists of validators split into single files. For implementation, I used Ruby on Rails and a project generated by rails-api gem.

Solution: Open source PR validating system

The whole job took me around a week, from the research, through different implementations to testing and deployment. 

I’d like to thank Adam Nowak for his suggestions on project organisation and Wojciech Olejnik for referring me to good README and project configurations.

The end result is a pull request validation system with modular validators. The two validators provided with the bot are set specifically for Netguru’s purposes and can be removed or used as a reference for creating custom validators.

The process of creating a validator as well as the instalation instructions are described in the README.

If you follow the naming and formatting conventions, the validator will load automatically. All you need is some basic command of Ruby and Octokit gem for communication with Github. Each validator is provided with an Octokit client which can be used to fetch all the necessary data from a Pull Request or Issue.

Please leave a comment below if you like the bot or have a suggestion!

New Call-to-action
 
READ ALSO FROM GitHub
Read also
Need a successful project?
Estimate project or contact us