2021-02-24 01:58:43 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-09-19 23:28:05 +02:00
|
|
|
BASE_DIR="$(mktemp -d '/tmp/platypush-ci-tests-XXXXX')"
|
2021-02-24 01:58:43 +01:00
|
|
|
VENV_DIR="$BASE_DIR/venv"
|
|
|
|
REPO_DIR="$BASE_DIR/repo"
|
|
|
|
TEST_LOG="$BASE_DIR/test.log"
|
|
|
|
REPO_URL=https://git.platypush.tech/platypush/platypush.git
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
echo "Cleaning up environment"
|
2021-02-24 22:34:35 +01:00
|
|
|
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
|
2021-09-19 23:28:05 +02:00
|
|
|
cd -
|
2021-02-24 01:58:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_repo() {
|
|
|
|
echo "Installing latest version of the repository"
|
|
|
|
pip install '.[http]'
|
|
|
|
}
|
|
|
|
|
|
|
|
run_tests() {
|
|
|
|
echo "Running tests"
|
2021-03-06 16:15:45 +01:00
|
|
|
pytest 2>&1 | tee "$TEST_LOG"
|
2021-09-19 23:28:05 +02:00
|
|
|
|
2021-03-06 16:20:53 +01:00
|
|
|
grep -e '^FAILED ' "$TEST_LOG"
|
|
|
|
if [[ $? == 0 ]]; then
|
|
|
|
return 2 # FAILURE
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0 # PASSED
|
2021-02-24 01:58:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
########
|
|
|
|
# MAIN #
|
|
|
|
########
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
prepare_venv
|
|
|
|
install_repo
|
|
|
|
run_tests
|
2021-02-24 21:45:18 +01:00
|
|
|
ret=$?
|
2021-03-06 19:49:42 +01:00
|
|
|
cleanup
|
2021-02-24 19:58:24 +01:00
|
|
|
|
2021-03-06 16:15:45 +01:00
|
|
|
if [[ $ret == 0 ]]; then
|
|
|
|
echo "Status: PASSED"
|
|
|
|
else
|
|
|
|
echo "Status: FAILED"
|
|
|
|
fi
|
|
|
|
|
2021-02-24 21:45:18 +01:00
|
|
|
exit $ret
|
2021-02-24 01:58:43 +01:00
|
|
|
|