platypush-ci/bin/run_ci_tests.sh

62 lines
932 B
Bash
Raw Permalink Normal View History

2021-02-24 01:58:43 +01:00
#!/bin/bash
BASE_DIR="$(mktemp -d '/tmp/platypush-ci-tests-XXXXX')"
2021-02-24 01:58:43 +01:00
VENV_DIR="$BASE_DIR/venv"
2023-05-04 00:31:03 +02:00
REPO_DIR="/opt/repos/platypush"
2021-02-24 01:58:43 +01:00
TEST_LOG="$BASE_DIR/test.log"
cleanup() {
echo "Cleaning up environment"
rm -rf "$BASE_DIR"
2021-02-24 01:58:43 +01:00
}
prepare_venv() {
echo "Preparing virtual environment"
python -m venv "$VENV_DIR"
cd "$VENV_DIR"
source ./bin/activate
cd -
2021-02-24 01:58:43 +01:00
}
install_repo() {
echo "Installing latest version of the repository"
2023-05-04 00:31:03 +02:00
cd "$REPO_DIR"
2021-02-24 01:58:43 +01:00
pip install '.[http]'
2023-05-04 00:31:03 +02:00
cd -
2021-02-24 01:58:43 +01:00
}
run_tests() {
echo "Running tests"
2023-05-04 00:31:03 +02:00
cd "$REPO_DIR"
pytest 2>&1 | tee "$TEST_LOG"
2021-09-19 23:40:40 +02:00
deactivate
grep -e '^FAILED ' "$TEST_LOG"
if [[ $? == 0 ]]; then
return 2 # FAILURE
fi
2023-05-04 00:31:03 +02:00
cd -
return 0 # PASSED
2021-02-24 01:58:43 +01:00
}
########
# MAIN #
########
cleanup
prepare_venv
install_repo
run_tests
ret=$?
2021-03-06 19:49:42 +01:00
cleanup
if [[ $ret == 0 ]]; then
echo "Status: PASSED"
else
echo "Status: FAILED"
fi
exit $ret
2021-02-24 01:58:43 +01:00