crowdsec/tests/collect-hub-coverage

33 lines
904 B
Text
Raw Normal View History

#!/usr/bin/env bash
set -eu
die() {
echo >&2 "$@"
exit 1
}
# shellcheck disable=SC1007
TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
# shellcheck source=./.environment.sh
. "${TEST_DIR}/.environment.sh"
hubdir="${LOCAL_DIR}/hub-tests"
coverage() {
"${CSCLI}" --crowdsec "${CROWDSEC}" --cscli "${CSCLI}" hubtest coverage --"$1" --percent
}
cd "${hubdir}" || die "Could not find hub test results"
shopt -s inherit_errexit
echo "PARSERS_COV=$(coverage parsers | cut -d = -f2)"
echo "SCENARIOS_COV=$(coverage scenarios | cut -d = -f2)"
PARSERS_COV_NUMBER=$(coverage parsers | tr -d '%[[:space:]]')
SCENARIOS_COV_NUMBER=$(coverage scenarios | tr -d '%[[:space:]]')
echo "PARSERS_BADGE_COLOR=$(if [[ PARSERS_COV_NUMBER -lt 70 ]]; then echo 'red'; else echo 'green'; fi)"
echo "SCENARIOS_BADGE_COLOR=$(if [[ SCENARIOS_COV_NUMBER -lt 70 ]]; then echo 'red'; else echo 'green'; fi)"