How to add some badges in your git readme (GitHub, Gitlab etc.)

How to add some badges in your git readme (GitHub, Gitlab etc.)

ยท

3 min read

While I published this repo I was looking for some badges to add in my readme. And found some interesting services worth sharing.

The most amazing place to make your badges is the shields.io. But I will explain each category to use them in the shield.

Build

First, the badge you will look for is the build passing badge. You have written some amazing tests and you need to show that they are passing. There are several good services for that, I used Travis CI.

The integration is really easy. You need to add a .travis.yml file in your repo. Mine was pretty straight-forward -

language: python
python:
  - "3.7"
install:
  - pip install -r requirements.txt
script: 
  - python -m pytest  --cov-report term --cov=app
after_success:
  - codecov

I will talk about the after_success part next. Before that, you need the badge, right? You can get it by simply clicking the build passing button.

Code Coverage

You have the tests passing, and the earned the badge. Now you need some coverage for your tests. You already know it by running tests with coverage option. For Python you may run this python -m pytest --cov-report term --cov=app. But how to get the badge?

You can use Codecov. For Python you need to install the codecov package by pip install codecov. Then just add this line in your .travis.yml -

after_success:
  - codecov

You can find the badge in the settings page.

You can also use Coveralls for the same purpose. In that case, you need to install coveralls package in Python. You can find the badge in the bottom of your repo page in coveralls.

Dependency monitor

This is really useful, not only for the badge but you can also manage your dependencies with the coming updates.

For Python you can use requires.io. To get PR for new package changes you need to configure it by these steps: Hooks -> New pull request -> (configure as you like) -> save changes. And you can find the badge in specific repo page.

For Node.js Depfu is a good service. You will get PR automatically, don't need to setup any hooks. You can find the badge in the settings of the specific repo page.

Code Quality

There's a few services for that. I used both lgtm and Code Climate. I won't comapre or judge them as they both marked my code A ๐Ÿ˜…

You can find lgtm badges in the specific repo's integration page and the codeclimate badges can be found in the repo settings page.

There are also other services specific to your needs. You can know about them from shields actually. Making badge is really easy with them. Have a try!

ย