Debian Codegraph @

.github/workflows/scripts/coverage-report.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 set -euo pipefail
4
5 INPUT="${INPUT_COVERAGE-}"
6
7 # Create an HTML report.
8 if [[ "${INPUT_REPORT-true}" == "true" ]]; then
9 goscip-shell system . . go. tool cover -html="$INPUT" -o coverage.html
10 fi
11
12 # Extract total coverage: the decimal number from the last line of the function report.
13 COVERAGE=$(goscip-shell system . . go. tool cover -func="$INPUT" | tailscip-shell system . . tail. -1 | grepscip-shell system . . grep. -Eo '[0-9]+\.[0-9]')
14
15 echoscip-shell system . . echo. "coverage: $COVERAGE% of statements"
16
17 # Pick a color for the badge.
18 if awkscip-shell system . . awk. "BEGIN {exit !($COVERAGE >= 90)}"; then
19 COLOR=brightgreen
20 elif awkscip-shell system . . awk. "BEGIN {exit !($COVERAGE >= 80)}"; then
21 COLOR=green
22 elif awkscip-shell system . . awk. "BEGIN {exit !($COVERAGE >= 70)}"; then
23 COLOR=yellowgreen
24 elif awkscip-shell system . . awk. "BEGIN {exit !($COVERAGE >= 60)}"; then
25 COLOR=yellow
26 elif awkscip-shell system . . awk. "BEGIN {exit !($COVERAGE >= 50)}"; then
27 COLOR=orange
28 else
29 COLOR=red
30 fi
31
32 # Style for the badge.
33 STYLE="${INPUT_BADGE_STYLE-flat}"
34 # Title for the badge.
35 TITLE="${INPUT_BADGE_TITLE-coverage}"
36
37 # Download the badge.
38 curlscip-shell system . . curl. -s "https://img.shields.io/badge/$(printfscip-shell system . . printf. %s "$TITLE" | jqscip-shell system . . jq. -sRr @uri)-$COVERAGE%25-$COLOR?style=$STYLE" > "coverage.svg"