From 7e99d55bdab2263b224aa8297e43e5b156e2bc6b Mon Sep 17 00:00:00 2001 From: Jon Lockwood Date: Thu, 27 Jan 2022 13:16:03 +0930 Subject: [PATCH] ci(pytest): Added pytest job to run tests against build. This CI job runs all tests in the tests/ directory. MR !2 --- .gitignore | 10 ++++++++++ .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- pytest.ini | 5 +++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/.gitignore b/.gitignore index 30b80a2..093ffbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ # Ignore build Directory build/ aux/ + +# ignore dev env +dev_env +__pycache__ + +# ignore junit +*.junit.xml + +# ignore log files +*.log diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1910dbf..b1bfee1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,10 @@ stages: - validation - build + - test - release - publish - + - deploy variables: GIT_SUBMODULE_STRATEGY: recursive @@ -28,6 +29,37 @@ Static Pages: extends: .MKDocs_Build +Unit Tests: + image: ubuntu:18.04 + needs: ['Static Pages'] + before_script: + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" + - apt update + - apt install -y python3 python3-pip ca-certificates + - apt install --no-install-recommends -y chromium-chromedriver + - pip3 install --upgrade pip + - pip3 install -r test/requirements.txt + - mv "$CI_PROJECT_DIR/artifacts/build/Static Pages/build" build + script: + - pytest --junitxml=unit_test.junit.xml --tb=line -s + - cp *.junit.xml "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/" + - echo "[DEBUG] python_exit[$python_exit]" + artifacts: + expire_in: 24 hrs + when: always + paths: + - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/*" + reports: + junit: + - "*.junit.xml" + + + rules: + - if: '$CI_COMMIT_BRANCH' + when: always + - when: never + Gitlab Release: extends: - .gitlab_release diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..7e3723a --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +#junit_suite_name=Unit Test +junit_log_passing_tests=true +#enable_assertion_pass_hook=true +junit_logging=all