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!
Top comments (4)
Great work! It looks really useful. One question, though. How often does Pierre check to see if the dependent issues are closed? Let's say my PR depends on rails/rails#523, but this issue is still open when I submit it. A couple of days pass, and the Rails issue is closed, does Pierre automatically change the status of my PR to OK? Does it check for the status periodically, and updates it on the next run?
Thanks!
Thanks, Patricio! I hope it proves to be useful!
To answer your question: No. Currently Pierre only checks upon two events: PR creation and comments (added or deleted). I thought about adding a feature similar to one Jenkins have, where it re-runs the tests if you add a comment with "Jenkins please". Also, based on similar features of other GitHub apps, that seems to be the preferred choice.
But feel free to open an issue requesting this feature, and we can talk about it on GitHub!
Cheers!
Having a cron job that periodically checks the status of the dependencies would be a great feature to add. If it would also notify the user that a dependent issue just got addressed, it would be great.
I feel like this feature should be part of the core of GitHub... ๐
The cron job is a possible solution, which would also require some sort of storage, which we haven't yet. I've created an issue for this, so that we can continue the discussion there and even start some development: github.com/alvarocavalcanti/pierre...
:)
I feel the same way about this being a GitHub feature...