| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | set -eu |
| 4 | |
| 5 | diescip-shell shell crowdsec 1.4.6-10.1 die().() { |
| 6 | echoscip-shell system . . echo. >&2 "$@" |
| 7 | exit 1 |
| 8 | } |
| 9 | |
| 10 | # shellcheck disable=SC1007 |
| 11 | THIS_DIR=$(CDPATH= cd -- "$(dirnamescip-shell system . . dirname. -- "$0")" && pwdscip-shell system . . pwd.) |
| 12 | # shellcheck disable=SC1091 |
| 13 | . "${THIS_DIR}/../.environment.sh" |
| 14 | |
| 15 | hubdir="${LOCAL_DIR}/hub-tests" |
| 16 | |
| 17 | coveragescip-shell shell crowdsec 1.4.6-10.1 coverage().() { |
| 18 | "${CSCLI}" --crowdsec "${CROWDSEC}" --cscli "${CSCLI}" hubtest coverage --"$1" --percent |
| 19 | } |
| 20 | |
| 21 | cd "${hubdir}" || diescip-shell shell crowdsec 1.4.6-10.1 die(). "Could not find hub test results" |
| 22 | |
| 23 | shopt -s inherit_errexit |
| 24 | |
| 25 | echoscip-shell system . . echo. "PARSERS_COV=$(coveragescip-shell shell crowdsec 1.4.6-10.1 coverage(). parsers | cutscip-shell system . . cut. -d = -f2)" |
| 26 | echoscip-shell system . . echo. "SCENARIOS_COV=$(coveragescip-shell shell crowdsec 1.4.6-10.1 coverage(). scenarios | cutscip-shell system . . cut. -d = -f2)" |
| 27 | |
| 28 | PARSERS_COV_NUMBER=$(coveragescip-shell shell crowdsec 1.4.6-10.1 coverage(). parsers | trscip-shell system . . tr. -d '%[[:space:]]') |
| 29 | SCENARIOS_COV_NUMBER=$(coveragescip-shell shell crowdsec 1.4.6-10.1 coverage(). scenarios | trscip-shell system . . tr. -d '%[[:space:]]') |
| 30 | |
| 31 | echoscip-shell system . . echo. "PARSERS_BADGE_COLOR=$(if [[ PARSERS_COV_NUMBER -lt 70 ]]; then echoscip-shell system . . echo. 'red'; else echoscip-shell system . . echo. 'green'; fi)" |
| 32 | echoscip-shell system . . echo. "SCENARIOS_BADGE_COLOR=$(if [[ SCENARIOS_COV_NUMBER -lt 70 ]]; then echoscip-shell system . . echo. 'red'; else echoscip-shell system . . echo. 'green'; fi)" |