From 27705f7bdf96f6d04b105f7b891fc88ed7c8bbe0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Jul 2023 11:05:38 +0200 Subject: [PATCH] Test pipelines migrated to Drone CI --- .drone.yml | 15 +++++++++++ .gitlab/rebuild_docs.sh | 33 ----------------------- .gitlab/run_ci_tests.sh | 60 ----------------------------------------- requirements-tests.txt | 1 + 4 files changed, 16 insertions(+), 93 deletions(-) create mode 100644 .drone.yml delete mode 100755 .gitlab/rebuild_docs.sh delete mode 100755 .gitlab/run_ci_tests.sh create mode 100644 requirements-tests.txt diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 000000000..a94ba4455 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,15 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: run-tests + image: python:3.11-alpine + commands: + - apk add --update --no-cache redis + - apk add --update --no-cache --virtual build-base g++ rust + - pip install -U pip + - pip install . + - pip install -r requirements-tests.txt + - apk del build-base g++ rust + - pytest tests diff --git a/.gitlab/rebuild_docs.sh b/.gitlab/rebuild_docs.sh deleted file mode 100755 index 4e843a8bc..000000000 --- a/.gitlab/rebuild_docs.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -LOGFILE="./docs.log" -STATUS_IMG_PATH="./docs-status.svg" - -build_docs() { - cd ./docs || exit 1 - make html 2>&1 | tee "../$LOGFILE" - ret=$? - cd .. || exit 1 - return $? -} - -######## -# MAIN # -######## - -build_docs -ret=$? - -log_base_path="$(date +/opt/tests/platypush/logs/docs/%Y-%m-%dT%H:%M:%S.%m)" -if [[ $ret == 0 ]]; then - wget -O "$STATUS_IMG_PATH" https://ci.platypush.tech/docs/passed.svg - cp "$LOGFILE" "${log_base_path}_PASSED.log" -else - wget -O "$STATUS_IMG_PATH" https://ci.platypush.tech/docs/failed.svg - cp "$LOGFILE" "${log_base_path}_FAILED.log" -fi - -mv "$STATUS_IMG_PATH" /opt/tests/platypush/logs/docs/ -mv "$LOGFILE" /opt/tests/platypush/logs/latest.log -cp -r docs/build/html /opt/repos/platypush/docs/build/ -exit $ret diff --git a/.gitlab/run_ci_tests.sh b/.gitlab/run_ci_tests.sh deleted file mode 100755 index c4aee4434..000000000 --- a/.gitlab/run_ci_tests.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -BASE_DIR="$(mktemp -d '/tmp/platypush-ci-tests-XXXXX')" -VENV_DIR="$BASE_DIR/venv" -TEST_LOG="./test.log" -STATUS_IMG_PATH="./status.svg" - -cleanup() { - echo "Cleaning up environment" - rm -rf "$BASE_DIR" -} - -prepare_venv() { - echo "Preparing virtual environment" - python -m venv "$VENV_DIR" - cd "$VENV_DIR" || exit 1 - source ./bin/activate - cd - || exit 1 -} - -install_repo() { - echo "Installing latest version of the repository" - pip install '.[http]' -} - -run_tests() { - echo "Running tests" - pytest 2>&1 | tee "$TEST_LOG" - deactivate - - if grep -e '^FAILED ' "$TEST_LOG"; then - return 2 - fi - - return 0 # PASSED -} - -######## -# MAIN # -######## - -cleanup -prepare_venv -install_repo -run_tests -ret=$? -cleanup - -log_base_path="$(date +/opt/tests/platypush/logs/%Y-%m-%dT%H:%M:%S.%m)" -if [[ $ret == 0 ]]; then - wget -O "$STATUS_IMG_PATH" https://ci.platypush.tech/passed.svg - cp "$TEST_LOG" "${log_base_path}_PASSED.log" -else - wget -O "$STATUS_IMG_PATH" https://ci.platypush.tech/failed.svg - cp "$TEST_LOG" "${log_base_path}_FAILED.log" -fi - -mv "$STATUS_IMG_PATH" /opt/tests/platypush/logs/status.svg -mv "$TEST_LOG" /opt/tests/platypush/logs/latest.log -exit $ret diff --git a/requirements-tests.txt b/requirements-tests.txt new file mode 100644 index 000000000..e079f8a60 --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1 @@ +pytest