Chilled Geek's Blog

Always curious, always learning

Basic DevOps with git repos (free for open source!)

Posted at — Nov 13, 2019

Background

I love automating boring things, and that’s why I got into programming. When I then first heard of devops I got quite excited, as it automates parts of the software development life cycle, allowing for continuous integration/continuous deployment.

Though I’ve only explored some basic devops practices and really haven’t covered the full spectrum of available tools, I wanted to share what I’ve learned and have been able to implement on my hobby projects. For demo purposes I used my lilypond-web github repo, which I have a separate post that describes what this repo does (which is a simple web service that converts lovely LilyPond code into music scores!).

The tools that I’ve implemented and am covering in this blog is CodeFactor, CircleCI, Codecov, which can all be found on the GitHub marketplace free for open source projects and repos:

Setup for github repos

Continuous Integration (with CircleCI)

Quick overview of the Continuous Integration practice (cherry picked from wikipedia):

To achieve this with CircleCI:

There are more options on the CircleCI dashboard to adjust, and you can alter the .yml file to your needs, but a config file is all you need for a basic CI pipeline, which is set to run when commits are pushed.

Benefits of CI:

After the CI pipeline is set up for automated builds and tests, more components can be added to this pipeline. One very useful thing to add is some analysis of the code quality and test coverage, which are described below.

Assessing test coverage with Codecov

To add a code coverage report:

To incorporated these steps to the build and test CI pipeline from above, there are two things to do:

Assessing code quality with CodeFactor

There is a spectrum of good and bad ways to write code that can carry out the same desirable process. One extreme (the bad side) is writing code that runs today, but the code itself is completely not understandable when reading it again after a month. On the good side, if general software engineering practices and principles are applied, the code quality can be made much better, which CodeFactor can be used to provide such assessments. Factors that are taken into account include maintainability, readability, reliability, modularity, reusability. One can learn a lot just by getting these code quality reports to know how to adapt better coding practices!

Adding this function with CodeFactor is easy. After registering and logging into CodeFactor, Just go to https://www.codefactor.io/repository/new and add your repository so the CodeFactor can access and assess it.

Showing badges on your repo

Each of the above tools provide badges for each project that you have scanned, which I find very useful to show on the readme files of my github repos. I suppose one can use these to show off, but for me it is a good reminder that enforces me to try maintaining good coding standards (and providing myself a certain degree of satisfaction and achievement)

The badges are easy to find in your correponding repo project settings in each tool’s dashboard page:

And these can be added easily to the readme, resulting in something like this:

Tool Badge
CodeFactor Codefactor
CircleCI CircleCI
Codecov codecov