Code Review Lamp
About the project
A colorful lamp to notify the developer team for pending code reviews.
Project info
Difficulty: Easy
Platforms: Adafruit, Everything ESP, Google
Estimated time: 1 hour
License: Creative Commons Attribution CC BY version 4.0 or later (CC BY 4+)
Items used in this project
Hardware components
View all
Story
At work, we are a fast-paced team that likes to commit small and often. Every commit does not only have to pass the various tests run by our Continuous Integration machinery, but also gets extensively code reviewed before allowed to be merged. Since we are six and our internal code of conduct dictates two positive approvals for each new submission, the lack of responsiveness when it comes to reviewing, can impede the development process and speed.
In an ideal world, developers would check their notification emails and would proceed on with reviewing their peer's code. However, as they are too absorbed into their ongoing work and perhaps slightly overwhelmed by the amount of emails they receive, these emails tend to be ignored. The common belief is that someone else in the team is going to review the code, but often no one does. We have employed two different techniques so far to solve the problem. The first one includes shouting CODE REVIEW loudly and the second placing color-coded bean bags (I kid you not 😂) on each others' desks. The third that hopes to rule them all is the Code Review Lamp!
Code Review Lamp is a Neopixel-based, WiFi-enabled gadget that reminds developers to peer-review their colleagues' code. For each submission that has not been reviewed enough, it dims up and down at a color that is specific to the developer who is trying to introduce a new functionality to a project. The lamp stops shining once the code has either received enough reviews by the team, been merged or designated as Work In Progress. Currently, it is configured to work with Gerrit (v.2.15) but it could be programmed to fetch data from different tools such as Jenkins, GitHub, GitLab etc. Its advantage is that it continuously, and discretely, reminds developers that the team needs to review code and thus someone's work is being blocked as long as the lamp is shining. Additionally, they can see who is requesting the code review and how many reviews need to be conducted. But let's see how it works.
The gadget is comprised of an ESP8266 microcontroller module (Wemos D1 Mini) that connects wirelessly to the internet, as well as a Neopixel ring which displays various colors. Reaping its benefits is simple for the development team member. They merely need to push code to Gerrit, add the group which includes all team members to the review and set the review to Ready for review or Work in Progress depending on whether they want the team to start or stop reviewing the code.
We have included a special user in our team's Gerrit group, representing the lamp, which is added along the team to each review. This user is being utilized by the ESP8266 microcontroller which connects to WiFi and queries Gerrit for open reviews where this "lamp user" is a reviewer. Of course, it is not necessary to have a separate user for the lamp. Any team member's already existing account can be used and this way Code Review Lamps can be personalized. However, since we consider code reviews a team activity and the foundation of cross-functionality and knowledge-sharing, we have opted for the "team approach". Eventually, for each review the user is assigned to, we determine how many reviews have been conducted and if they fall short of our agreed threshold, a color that corresponds to the owner of the review is displayed on the Neopixel ring.
n the software side of things, the Code Review lamp utilizes the Adafruit Neopixel library to control the Neopixel ring. What is more, the ESP8266 SDK supports a considerable chunk of the C++11 STL which makes programming a joy. However, it also makes you prone to forget you are writing for a device with very limited resources. While trying to make everything work, I ran into a fair share of heap memory overflows while handling the incoming JSON stream which, to be fair, made the development a more didactic process. In any case, being able to use vectors and strings makes things easy as long as your are careful. Hardware-wise, there is a custom PCB which merely connects the Wemos D1 Mini to the Neopixel ring and a 3D printed case made from a translucent filament that houses everything.
As usual, you can find all necessary sources to reproduce the project on GitHub and do not forget to have a look at the demo video below.
Leave your feedback...