ci(pytest): Added pytest job to run tests against build.

This CI job runs all tests in the tests/ directory.

MR !2
This commit is contained in:
2022-01-27 13:16:03 +09:30
parent 0d51c8d10b
commit 7e99d55bda
3 changed files with 48 additions and 1 deletions

10
.gitignore vendored
View File

@ -1,3 +1,13 @@
# Ignore build Directory
build/
aux/
# ignore dev env
dev_env
__pycache__
# ignore junit
*.junit.xml
# ignore log files
*.log

View File

@ -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

5
pytest.ini Normal file
View File

@ -0,0 +1,5 @@
[pytest]
#junit_suite_name=Unit Test
junit_log_passing_tests=true
#enable_assertion_pass_hook=true
junit_logging=all