PR-MOD: An advanced pull-request reviewing tool

Surya Saini
IMG IIT Roorkee
Published in
5 min readJan 15, 2019

“Reviewing pull requests made much easier now!”

Open source community is increasing at a rapid rate. The sole reason for this exponential growth is the continuous contribution of many individuals all across the globe. This process of continuous integration of code generation and addition to the main source code is a daunting process. Any individual who has ever contributed to open source must be familiar with the concept of Pull Requests. Addition of small chunks of your code to the main source code branch is done by opening a pull request.

Patches of code are added to the main branch via pull requests, where the open source project maintainers inspect and review your code (Checking the quality of your code, it’s functionality, and the effect it is having on the current code). Reviewing a PR is one of the most important processes of open source software development, which is as difficult as it is essential. Reviewing a PR can include the process of setting up the main code base on your local system and then adding the respective branch of the Pull Request author. This entire process proves to be a daunting task, taking a lot of labour to deploy the application, thus rendering the process of review a bit difficult and almost impossible to do it on the go.

While reviewing a Pull Request of a project, I came across the same problem. At the time I was using a chrome extension called Gitpod, that deploys the pull requests code on a remotely hosted Theia-ide code editor, allowing easy review of code changes. This had me thinking about how easy the entire process would be, if by a single click of the button, I could test the exact functionality of the code for which the pull request was added, without the setup.

This led me to develop PR-Mod, an application that redefines the process of reviewing a Pull Request, entirely removing the manual procedure of deploying the application on your local server.

How is PR-mod used?

PR-mod is composed of a chrome extension and a server side software which helps serve it’s purpose.

The chrome extension adds a green button by the name “PR-mod” on any Github pull request page.

Notice the new green button added by the chrome extension

After deploying PR-mod by following the instructions specified in the README file of the repo, you need to configure the server IP and port in the chrome extension.

The prompt after clicking on the PR-mod icon on the chrome navbar

And bingo! You are ready to review any pull-request easily.

So, How does PR-Mod work?

PR-Mod clones the code of the repository from the pull request author and deploys the application which allows to authenticate the user and clone the private application on the remote server, directing you to a URL where the application is deployed. Here, you can actually test the functioning of the Pull Request, and all this with just a single click of a button.

Cherry on top, it works with private repositories too!

PR-Mod works using the GitHub API v3 which allows it to authenticate the user and clone the private or public code repository. Another dependency of PR-Mod is that it looks for a file called Testfile in the repo which acts as the configuration file for PR-Mod, which instructs the deployment of the application.

A Testfile may look something like this:

Another key feature of PR-Mod is docker:dind (docker in docker) based image, that has a sole purpose of sandboxing an application from other applications currently being tested on PR-Mod’s server. The Testfile contains the config parameters by which the docker:dind container is deployed. Deciding the container’s working directory, volumes where it will be mounted, the services to run inside the container and assigning a randomly chosen port to handle TCP/IP requests are the tasks achieved by using the docker package for python which directly interacts with docker API on the pr-mod server.

Thus the most integral part of PR-Mod is the Testfile. This concept is similar to the well-known Dockerfile and is the heart of PR-Mod. PR-Mod boasts of working with any application that is capable of having a Testfile. A Testfile allows pip, git, docker, docker-compose and shell commands. If an application can be deployed using the above mentioned, then PR-Mod is always ready to help in its PR testing.

An interesting feature of PR-Mod has been derived from the properties of docker. All the docker:dind containers share the same daemon, so if a docker-image is already pulled inside one of the containers and another application requires the same image, then it can use the pre-existing image rather than pulling a new fresh image. This accelerates the deployment of applications on PR-Mod.

Clone the PR-Mod github repository

To interact with the PR-Mod server, I developed a chrome extension which adds an interface on the Github Pull Request page of the corresponding repository. It also allows PR-Mod to gather information like pull request number, the repository name and the repository owner. PR-Mod is built using the flask python framework and can be easily deployed on a local server for testing and development server. The chrome extension is also configurable, allowing users to add the Server-IP and port on which they have PR-Mod server deployed. These credentials are stored in local storage of the browser and can be easily re-configured.

To prevent misuse of server-space, PR-Mod provides a feature of user authentication, where the PR-Mod server admin can register a user with the PR-Mod server and thus access is only provided to them. Any request from an unregistered user would not be entertained by the server.

PR-Mod was initially developed by me to reduce the burden of PR review, but its development has helped me learn a lot of new exciting things. Working with the GitHub and docker API (the heart and soul of PR-Mod) was really challenging and enthralling. Using this tool with my project has significantly improved the code integration speed, thus making the work a lot easier!

Check the source code and contribute to our github repository.
Download the chrome extension and contribute to our github repository.

Suggestions and criticism are welcome.

Follow the repository to see further developments on the project and our medium publication for more blogs like this.

Happy open source development :D

--

--