61 lines
976 B
Bash
Executable File
61 lines
976 B
Bash
Executable File
#!/bin/bash
|
|
|
|
BASE_DIR="$(mktemp -d '/tmp/platypush-ci-tests-XXXXX')"
|
|
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"
|
|
rm -rf "$BASE_DIR"
|
|
}
|
|
|
|
prepare_venv() {
|
|
echo "Preparing virtual environment"
|
|
python -m venv "$VENV_DIR"
|
|
cd "$VENV_DIR"
|
|
source ./bin/activate
|
|
cd -
|
|
}
|
|
|
|
install_repo() {
|
|
echo "Installing latest version of the repository"
|
|
pip install '.[http]'
|
|
}
|
|
|
|
run_tests() {
|
|
echo "Running tests"
|
|
pytest 2>&1 | tee "$TEST_LOG"
|
|
deactivate
|
|
|
|
grep -e '^FAILED ' "$TEST_LOG"
|
|
if [[ $? == 0 ]]; then
|
|
return 2 # FAILURE
|
|
fi
|
|
|
|
return 0 # PASSED
|
|
}
|
|
|
|
########
|
|
# MAIN #
|
|
########
|
|
|
|
cleanup
|
|
prepare_venv
|
|
install_repo
|
|
run_tests
|
|
ret=$?
|
|
cleanup
|
|
|
|
if [[ $ret == 0 ]]; then
|
|
echo "Status: PASSED"
|
|
export CI_PASSED=1
|
|
else
|
|
echo "Status: FAILED"
|
|
export CI_PASSED=0
|
|
fi
|
|
|
|
exit $ret
|
|
|