Ever wished for a pull request dependency check? You've got it.
Tags: showdev, opensource, python, flask
Published: 2018-03-06 19:05:56

---
title: Ever wished for a pull request dependency check? You've got it.
published: true
description: Pierre DeCheck checks for the dependencies of a given pull request, publishing the status to the "checks" session no the PR
tags: showdev, opensource, python, flask
cover_image: https://github.com/alvarocavalcanti/pierre-decheck/blob/master/pull_request_checks_cover_image.png?raw=true
---

## Pull Requests are a thing (like it or not)

Those of us that work with [GitHub](http://github.com), 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](https://trunkbaseddevelopment.com) 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](https://jenkins.io) and [CircleCI](https://circleci.com) 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](http://www.django-rest-framework.org) I chose [Flask](http://flask.pocoo.org) 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](https://github.com/alvarocavalcanti/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:

![A Pull Request's checks](https://github.com/alvarocavalcanti/pierre-decheck/raw/master/pull_request_checks.png)

The installation and usage details can be found on [Pierre's GitHub page](https://github.com/alvarocavalcanti/pierre-decheck#installation) 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](https://github.com/alvarocavalcanti/pierre-decheck/issues/new)! :)

## 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!