crowdsec/test/bin/collect-hub-coverage
mmetc cab99643d1
Parallel hubtest (#3509)
Hubtests are now much faster and have a --max-jobs option which defaults to the number of cpu cores.
2025-03-17 11:27:09 +01:00

35 lines
1,007 B
Bash
Executable file

#!/usr/bin/env bash
set -eu
die() {
echo >&2 "$@"
exit 1
}
# shellcheck disable=SC1007
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
# shellcheck disable=SC1091
. "${THIS_DIR}/../.environment.sh"
coverage() {
"${CSCLI}" --crowdsec "${CROWDSEC}" --cscli "${CSCLI}" hubtest coverage --"$1" --percent
}
hubdir="${LOCAL_DIR}/hub-tests"
hubdir="${1:-${hubdir}}"
[[ -d "${hubdir}" ]] || die "Could not find hub test results in $hubdir"
cd "${hubdir}" || die "Could not find hub test results in $hubdir"
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)"