#!/bin/bash BASE_DIR="$(mktemp -d)" 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 } install_repo() { echo "Installing latest version of the repository" git clone "$REPO_URL" "$REPO_DIR" cd "$REPO_DIR" pip install '.[http]' } run_tests() { echo "Running tests" cd "$REPO_DIR" ./run_tests.sh 2>&1 | tee "$TEST_LOG" } check_test_results() { failed_tests=$(grep -e '^FAILED' "$TEST_LOG") ret=0 if [[ ! -z "$failed_tests" ]]; then echo "------------------" echo "Some tests failed!" echo "------------------" ret=2 else echo "All tests passed" fi return $ret } ######## # MAIN # ######## cleanup prepare_venv install_repo run_tests check_test_results ret=$? cleanup exit $ret