Badger

A tool to generate badges without the need to grant access to the source code to a third party. Only the relevant metric is submitted to the badge-generating service.

Generating your badges

Test coverage

Manually

cov=`pytest --cov=./ | grep TOTAL | awk '{print $4}'`
curl -X POST -F repo_name=<Organisation>/<Repo name> -F badge_name=coverage -F value=$cov https://nautilus-badger.appspot.com/build_badge

Embedded in a GitHub workflow

Add a step in your workflow YAML file

- name: Test with pytest, upload coverage.
  run: |
    pip install pytest-cov
    pytest --cov=./
    cov=`pytest --cov=./ | grep TOTAL | awk '{print $4}'`
    curl -X POST -F repo_name=${{ github.repository }} -F badge_name=coverage -F value=$cov https://nautilus-badger.appspot.com/build_badge

PyLint

Manually

export pl=`pylint . | grep 'Your code has been rated at ' | awk '{print $7}'`
curl -X POST -F repo_name=<Organisation>/<Repo name> -F badge_name=pylint -F value=$pl https://nautilus-badger.appspot.com/build_badge

Embedded in a GitHub workflow

Add a step in your workflow YAML file

- name: Get pylint note
  run: |
    pip install pylint
    pylint . --exit-zero
    pl=`pylint . | grep 'Your code has been rated at ' | awk '{print $7}'`
    curl -X POST -F repo_name=${{ github.repository }} -F badge_name=pylint -F value=$pl https://nautilus-badger.appspot.com/build_badge     

Radon

Manually

export rad=`radon cc --average . | tail -1 | awk '{print $3}'`
curl -X POST -F repo_name=<Organisation>/<Repo name> -F badge_name=complexity -F value=$rad https://nautilus-badger.appspot.com/build_badge

Embedded in a GitHub Actions CI workflow

Add a step in your workflow YAML file

- name: Get cyclomatic complexity
  run: |
    pip install radon
    rad=`radon cc --average . | tail -1 | awk '{print $3}'`
    curl -X POST -F repo_name=<Organisation>/<Repo name> -F badge_name=complexity -F value=$rad https://nautilus-badger.appspot.com/build_badge   

Gitleaks

Manually

# you can change the url that downloads the gitleaks.toml file below to the url of a raw file that is specific to your security needs
curl https://raw.githubusercontent.com/zricethezav/gitleaks/master/examples/leaky-repo.toml >> gitleaks.toml
leaks=`gitleaks --repo-path=$(pwd) -v --config=gitleaks.toml | grep 'leaks detected' | awk '{print $2}'`
if [[ $leaks -eq "No" ]]; then leaks="0"; fi
rm gitleaks.toml
curl -X POST -F repo_name=<Organisation>/<Repo name> -F badge_name=gitleaks -F value=$leaks https://nautilus-badger.appspot.com/build_badge

Embedded in a GitHub workflow

Add a step in your workflow YAML file

# you can change the url that downloads the gitleaks.toml file below to the url of a raw file that is specific to your security needs
- name: Get leaks from gitleaks
  run: |
    curl https://raw.githubusercontent.com/zricethezav/gitleaks/master/examples/leaky-repo.toml >> gitleaks.toml
    leaks=`docker run --rm --name gitleaks -v $(pwd):/code/ zricethezav/gitleaks --repo-path=/code/ -v --config=/code/gitleaks.toml | grep 'leaks detected' | awk '{print $2}'`
    if [[ $leaks -eq "No" ]]; then leaks="0"; fi
    rm gitleaks.toml
    curl -X POST -F repo_name=${{ github.repository }} -F badge_name=gitleaks -F value=$leaks https://nautilus-badger.appspot.com/build_badge 

Retrieving your badges

The API will return your badge token.

Get your badge at https://nautilus-badger.appspot.com/get_badge/<your-token>

Your badge URL will not change, so the badge will update automatically when you run your pipeline again.

Nautilus Badger

A tool to generate test coverage badges without the need to grant access to the source code to a third party.

Nautilus Badger Info

⭐ Stars 11
🔗 Source Code github.com
🕒 Last Update a year ago
🕒 Created 2 years ago
🐞 Open Issues 8
➗ Star-Issue Ratio 1
😎 Author artefactory