Ever wished for a pull request dependency check? You've got it.
Alvaro Cavalcanti
Posted on March 6, 2018
Pull Requests are a thing (like it or not)
Those of us that work with GitHub, either contributing to some open-source projects or working on private repositories, are familiar with pull requests. Even if your team is adept of trunk based development you should have heard about PRs as "evil things".
But if you're on the first group, as myself, and deal with a couple of different repositories that have any kind of dependency between them you might have come around with merging a PR that depended on another repo's PR that wasn't merged yet. I know I have!
The Episode®
It was a RoR frontend that depended on a Django-Rest-Framework backend. We merged the former before the latter, thus some production bugs cropped up and we had to deal with them.
After that episode, I started looking for tools that could prevent that from happening again. And it would be awesome to have some tool that would publish against the PR status/check, the same way CI services as Jenkins and CircleCI and some GitHub features do.
To be honest, I did find a couple of tools/services that seemed to offer this feature. What I didn't like, tho, was that they had a truckload of features. And I didn't want that, I wanted a simple checker.
If you don't like, do it yourself
From that point I changed my research. Instead of looking for a tool, I started looking at GitHub API's documentation. I decided to create a tool myself and it felt quite achievable after my initial research.
As I felt really comfortable and productive with Python, it was my platform of choice. But instead of going with Django-Rest-Framework I chose Flask for two reasons, 1) a Flask app is way slimmer than a DRF one, and slim and simple is better, and 2) I wanted to try Flask out. :)
There you have it: Pierre DeCheck
After roughly 2 months, and a complete rewrite, I had a working version that was ready for real-world testing. Here I present to you: Pierre DeCheck
Pierre's concept is simple, it should be configured as a webhook for a given repository, then you add the dependencies to a PR using keywords like "Depends on #2" for same-repo issues/PRs, or "Depends on owner/repo#2" for external ones and then it will publish a check to your PR status, telling you if the dependencies are met or not:
The installation and usage details can be found on Pierre's GitHub page and the only caveat you should be aware of is that, for now, the dependency check is synchronous. Meaning that when GitHub sends an event to the webhook, the check and status update will be made during that request. Which isn't optimal at all, I know, but it's a start.
Edit: Pierre will perform checks only upon PR creation and Comment Activity (added/removed). In every case it will fetch all the PR's bodies (the PR body itself and from all its comments), extract the dependencies and perform the checks. Thus, it does not observe the dependencies themselves and re-run the checks if their status change. But who knows what future holds? Feel free to create an issue/feature request! :)
Help Wanted
So, if you think this tool could help your team, it would be great if you could test it, create issues for the bugs you find and even contribute!
Thanks a lot!
Posted on March 6, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.