Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Created January 17, 2023 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitHub30/caacfc861fba320597f620fecd5b320c to your computer and use it in GitHub Desktop.
Save GitHub30/caacfc861fba320597f620fecd5b320c to your computer and use it in GitHub Desktop.
# https://github.com/dbrgn/coverage-badge/blob/ea399fc586eb00ec7f77e355a2e4b2b7cebd24c1/tests/test_output.py#L49
p=$(printf %.0f $(grep -Pom1 '(?<=aria-valuenow=").*?(?=")' reports/index.html))
color=$([[ $p -gt 96 ]] && echo 4c1 || ([[ $p -gt 92 ]] && echo 97CA00 || ([[ $p -gt 79 ]] && echo a4a61d || ([[ $p -gt 64 ]] && echo dfb317 || ([[ $p -gt 44 ]] && echo fe7d37 || ([[ $p -gt 14 ]] && echo e05d44 || echo 9f9f9f))))))
wget -O reports/badge.svg https://shields.io/badge/coverage-$p%25-$color?logo=github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment