Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
/ LOCCounterBadge Public archive

A webserver serving LoC for your repositories

Notifications You must be signed in to change notification settings

Sh1nku/LOCCounterBadge

Repository files navigation

Lines of Code counter badge


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

Installation

You will need the following packages

  • sudo apt install cloc git
  • pip3 install -r requirements.txt

Usage

  1. Make conf.d/config.cfg out of conf.d/config.cfg.template
    • Setup your repositories
  2. 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
  3. 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

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