Commit 530c9294 authored by Tim Rühsen's avatar Tim Rühsen

Create SVG badge for fuzz coverage

parent 9a1ff0e4
......@@ -158,16 +158,18 @@ pages:
- mv doc/manual public/manual
- make clean
- make clean && make && make -C fuzz check && make code-coverage-capture
- contrib/make-coverage-badge "fuzz-coverage"
- rm -rf public/fuzz-coverage
- mv libidn2-*-coverage public/fuzz-coverage
- mv badge.svg public/fuzz-coverage/
tags:
- shared
artifacts:
when: on_success
paths:
- public
only:
- master
# only:
# - master
# Target to run code coverage on non-master branches. That is intended
# to ensure that compilation in master will not break the pages rule.
......
[![build status](https://gitlab.com/libidn/libidn2/badges/master/build.svg)](https://gitlab.com/libidn/libidn2/pipelines)
[![coverage status](https://gitlab.com/libidn/libidn2/badges/master/coverage.svg)](https://libidn.gitlab.io/libidn2/coverage)
[![fuzz coverage status](https://libidn.gitlab.io/libidn2/fuzz-coverage/badge.svg)](https://libidn.gitlab.io/libidn2/fuzz-coverage)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/12080/badge.svg)](https://scan.coverity.com/projects/libidn2)
......
#!/usr/bin/env bash
text=${1:-coverage}
textwidth=$(($(echo -n "$text"|wc -m) * 7 + 6))
numwidth=54
totalwidth=$(($textwidth + $numwidth))
coverage=$(grep -m 1 'headerCovTableEntryHi.*[0-9]*' libidn2-*-coverage/index.html|sed 's/^.*>\([0-9]\+\.[0-9]\+\).*/\1/');
coverage=$(printf %.2f $coverage)
inum=$(echo $coverage|cut -d'.' -f1)
if [ -z "$inum" ]; then inum="0"; fi
coverage="$coverage%"
# https://www.w3.org/TR/SVG11/types.html#ColorKeywords
if [ $inum -ge 90 ]; then
color="lawngreen"
elif [ $inum -ge 80 ]; then
color="yellow"
elif [ $inum -ge 70 ]; then
color="orange"
else
color="red"
fi
cat <<EOF >badge.svg
<svg xmlns="http://www.w3.org/2000/svg" width="${totalwidth}" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<mask id="a">
<rect width="${totalwidth}" height="20" rx="3" fill="#fff"/>
</mask>
<g mask="url(#a)">
<path fill="#555" d="M0 0h${textwidth}v20H0z"/>
<path fill="${color}" d="M${textwidth} 0h${numwidth}v20H${textwidth}z"/>
<path fill="url(#b)" d="M0 0h${totalwidth}v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,DejaVu Sans,Geneva,sans-serif" font-size="11">
<text x="$(($textwidth / 2))" y="15" fill="#010101" fill-opacity=".3">${text}</text>
<text x="$(($textwidth / 2))" y="14">${text}</text>
<text x="$(($textwidth + $numwidth / 2))" y="15" fill="#010101" fill-opacity=".3">${coverage}</text>
<text x="$(($textwidth + $numwidth / 2))" y="14">${coverage}</text>
</g>
</svg>
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment