debian-koji-osbuild/run-tests.sh
Christian Kellner 07b376e02f test: run-test.sh now works inside a container
The `run-test.sh` helper is meant to execute the tests as if it
was CI but using a container. If it is detected that we are
already running inside a container assume it is prepare so that
we can exectue the tests directly and do so.
2022-01-19 20:45:23 +01:00

27 lines
659 B
Bash
Executable file

#!/usr/bin/bash
set -euo pipefail
SHELLCHECK_SEVERITY=${SHELLCHECK_SEVERITY:-warning}
run_test() {
if [ -f /.dockerenv ]; then
eval "$1"
return
fi
podman run --rm -it -v "$(pwd)":/github/workspace:z --env "GITHUB_WORKSPACE=/github/workspace" koji.test "$1"
}
if [ ! -f /.dockerenv ]; then
pushd test
podman build -t koji.test -f Dockerfile .
popd
else
echo "Container detected, direct mode."
fi
SCRIPTS="$(git ls-files --exclude='*.sh' --ignored | xargs echo)"
run_test "shellcheck -S ${SHELLCHECK_SEVERITY} ${SCRIPTS}"
run_test "pytest -v --cov-report=term --cov=osbuild test/unit/"
run_test "pylint plugins/**/*.py test/**/*.py"