af8c55330d
* target: tests/.environment.sh * don't pass BIN_DIR around * manage db backup/restore separately * don't export CONFIG_DIR, DATA_DIR (derive path locations from CONFIG_YAML); redirect stdout, stderr to &3 by default in setup_file, teardown_file
30 lines
876 B
Bash
Executable file
30 lines
876 B
Bash
Executable file
#!/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"
|
|
|
|
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)"
|