This application aims to allow you to create badges to display on github for lines of code in a repository.
It is a flask web-server that can be set up against github webhooks, so that when a push event happens the lines of code count served will update. This can be output through shields.io to show a badge for the response.
Since it is a self-hosted service, it also supports private repositories, and other CI pipelines or badge suppliers can be added relatively easily
You will need the following packages
sudo apt install cloc git
pip3 install -r requirements.txt
- Make
conf.d/config.cfg
out ofconf.d/config.cfg.template
- Setup your repositories
- Test that the server works
gunicorn --bind 0.0.0.0:5000 --preload --workers 8 wsgi:app
- On startup it should clone the repositories, and shutdown if any errors happen
- Create webhooks for your repositories, making sure that the
secret
in the config matches the webhook- Every time a push event is registered for the
branch
given in the config, the LoC will be updated - The endpoint for the webhook is
/<repository>/actions/github
- The endpoint for a shields response is
/<repository>/responses/shields_v1
which can be wrapped according to shields.io - custom endpoint
- Every time a push event is registered for the
Please take note that shields.io requires https, so I would recommend running the application through reverse proxy. In apache this can be achieved through this
ProxyPass /LOCCounterBadge/ http://127.0.0.1:5000/
ProxyPassReverse /LOCCounterBadge/ http://127.0.0.1:5000/
in my case giving me the endpoint used for this repository as
https://inobstudios.com/LOCCounterBadge/LOCCounterBadge/responses/shields_v1