diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76c7b2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/venv +/repo diff --git a/bin/run_ci_tests.sh b/bin/run_ci_tests.sh new file mode 100755 index 0000000..bdff56d --- /dev/null +++ b/bin/run_ci_tests.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +BASE_DIR=$(pwd) +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 "$VENV_DIR" "$REPO_DIR" "$TEST_LOG" +} + +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" + pytest 2>&1 | tee "$TEST_LOG" +} + +check_test_results() { + grep -e '^FAILED' "$TEST_LOG" >/dev/null + if [[ $? == 0 ]]; then + echo "------------------" + echo "Some tests failed!" + echo "------------------" + cat "$LOGFILE" + else + echo "All tests passed" + fi +} + +######## +# MAIN # +######## + +cleanup +prepare_venv +install_repo +run_tests +check_test_results +cleanup +