c78c833400
* github-ci: color unit test output and logs * new config option: force_color_logs (useful in CI) * bats: show sqlite/mysql dump at the end * removed "-v" (print package names) from "go build" * general workflow cleanup
50 lines
1.1 KiB
Bash
Executable file
50 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
# shellcheck disable=SC1007
|
|
TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
# shellcheck source=./.environment.sh
|
|
. "${TEST_DIR}/.environment.sh"
|
|
|
|
cscli() {
|
|
"${CSCLI}" "$@"
|
|
}
|
|
|
|
"${TEST_DIR}/instance-data" load
|
|
|
|
hubdir="${LOCAL_DIR}/hub-tests"
|
|
git clone --depth 1 https://github.com/crowdsecurity/hub.git "${hubdir}" >/dev/null 2>&1 || (cd "${hubdir}"; git pull)
|
|
|
|
HUBTESTS_BATS="${TEST_DIR}/dyn-bats/hub.bats"
|
|
|
|
cat << EOT > "${HUBTESTS_BATS}"
|
|
set -u
|
|
|
|
setup_file() {
|
|
load "../lib/setup_file.sh" >&3 2>&1
|
|
}
|
|
|
|
teardown_file() {
|
|
load "../lib/teardown_file.sh" >&3 2>&1
|
|
}
|
|
|
|
setup() {
|
|
load "../lib/setup.sh"
|
|
}
|
|
|
|
EOT
|
|
|
|
echo "Generating hub tests..."
|
|
|
|
for testname in $("${CSCLI}" --crowdsec "${CROWDSEC}" --cscli "${CSCLI}" hubtest --hub "${hubdir}" list -o json | grep -v NAME | grep -v -- '-------' | awk '{print $1}'); do
|
|
cat << EOT >> "${HUBTESTS_BATS}"
|
|
|
|
@test "${testname}" {
|
|
run "\${CSCLI}" --crowdsec "\${CROWDSEC}" --cscli "\${CSCLI}" --hub "${hubdir}" hubtest run "${testname}" --clean
|
|
# in case of error, need to see what went wrong
|
|
echo "\$output"
|
|
assert_success
|
|
}
|
|
EOT
|
|
done
|