GSoC 2021 Final Report: Coding style checker bot for Gerrit

Blog post by ritz on Sun, 2021-08-22 22:44

Hey everyone! Since the GSoC period is nearing its end therefore here’s the final report on my GSoC project Coding Style Checker Bot.

Project Description:

Haiku has its own coding guidelines which describe how the code should be formatted. There is a tool (haiku-format tool) for reformatting or checking if code follows these guidelines, but it has to be compiled on the developer machine and then run manually. My project was to create a Coding Style Checker bot that runs haiku-review tool on files submitted as a patchset in our code review system and posts the report in the patchset comments.

GSoC 2021 Progress Update 3: Coding style checker bot for Gerrit

Blog post by ritz on Wed, 2021-07-21 17:55

Tl;dr I have completed the bot with basic functionality for my local gerrit instance

Link to Introductory blog
Link to Progress 1
Link to Progress 2

As I have said before I divided my project in the following parts

  • For every event (change, patch etc.), trigger the Concourse CI pipeline.
  • Implement pipeline in concourse CI for fetching the Git repo and running the haiku-format tool on the relevant files and creating appropriate reports out of the tool.
  • Implement REST API call to post the result back to Gerrit reviews as a robot comment.

Since last time I started working on creating a report that could be displayed under patchset comments by the bot. I started by looking at various flags of clang-format command out of which --dry-run, --Werror seemed to be working just fine. But I wanted to run the tool only on the files that have been updated/added since last commit and not the entire project. Eventually I found a better way for this i.e. git-clang-format python script which is already present in the llvm project. After installing clang-format, we just need to put this script in /usr/bin/ folder. We can invoke the script using git clang-format directly. git clang-format --diff --style=haiku HEAD~1 would run clang-format with haiku style on the files that have been updated/added since last commit and showcase the diff of it. In order to use this diff information later I dumped the output of the previous command in a file named diff.txt. To use it in my concourse workflow, I added the git-clang-format script on my local server that I created last time using golang to host the clang-format file. Now this seemed rather promising so I went ahead onto the next task i.e. Implement REST API call to post the result back to Gerrit reviews as a robot comment.

GSoC 2021 Progress Update 2: Coding style checker bot for Gerrit

Blog post by ritz on Sun, 2021-06-27 14:50

Link to Introductory blog
Link to Progress 1

On my quest to finding a way to trigger my jobs anytime a commit happens in gerrit I was looking into this repo and trying to make it work. I tried using it as a resource but it turns out either it’s not public anymore or it was deleted. Then I went through the list of forks in that repo and found this. He claimed to have a base for a somewhat working resource after he made some changes. I cloned his repo and tried building the Dockerfile but it threw some errors. After struggling on it for quite some time and making some minor changes to the files I finally managed to build it and upload it to dockerhub. Then I tried using it as a resource but it failed to fetch my local gerrit repo. Also, the whole thing was written in go which was totally new to me so I started by learning “go” and after some time when I got the hang of it, I started the debugging phase.

GSoC 2021 Progress Update 1: Coding style checker bot for Gerrit

Blog post by ritz on Sat, 2021-06-05 19:46

Hey everyone! I am Hrithik (ritz), You can find about my project in my introductory blog. Here’s what I have done so far.

I started by reading Concourse CI documentation in order to get myself familiarise with ci pipeline and various schema involved in it. I also looked at other resources provided by my mentors i.e. Suhel Mehta @suhel_mehta and Alexander von Gluck @kallisti5 . Below are some links if anyone wants to check out.

GSoC 2021: Coding style checker bot for Gerrit

Blog post by ritz on Sat, 2021-05-22 20:31

Introduction

Hey everyone! I am Hrithik Kumar, a sophomore at National Institute of Technology Agartala, India majoring in Computer Science and Engineering (CSE). I am happy to say that I will be working on creating a Coding style checker bot for Gerrit as part of the GSoC 2021 project. My mentors are Alexander von Gluck and Suhel Mehta.

  • IRC nick: ritz
  • Matrix: ritz (@ritzkr:matrix.org)

Project

Haiku has its own coding guidelines which describe how the code should be formatted. There is a tool (haiku-format tool) for reformatting or checking if code follows these guidelines, but it has to be compiled on the developer machine and then run manually. Now this is extra work but what if it could be automated! That’s what I’ll be working on this summer i.e. creating a Gerrit bot that would use haiku-format tool for checking whether the patch submitted follows the community guidelines of Haiku and post the report in the comments.