From fb8d54f960805845b6f578c5c28fed2258e3ec9f Mon Sep 17 00:00:00 2001 From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com> Date: Mon, 17 Jul 2023 17:41:19 +0200 Subject: [PATCH] pytest template test --- .gitlab-ci.yml | 2 +- templates/python/code_quality/flake8/flake8.yml | 4 ---- templates/python/testing/pytest/pytest.yml | 11 ++++++----- tests/pytest_project/pyproject.toml | 5 +++++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09a0912..ed1bc02 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,12 +10,12 @@ pytest: stage: templates variables: PROJECT_PATH: "tests/pytest_project" - PYTHON_SETUP: "pip install ${PROJECT_PATH} pytest" only: changes: - .gitlab-ci.yml - pyproject.toml - templates/python/testing/pytest/**/* + - tests/pytest_project/**/* flake8: stage: templates diff --git a/templates/python/code_quality/flake8/flake8.yml b/templates/python/code_quality/flake8/flake8.yml index 46343d0..f60bda1 100644 --- a/templates/python/code_quality/flake8/flake8.yml +++ b/templates/python/code_quality/flake8/flake8.yml @@ -1,6 +1,3 @@ -stages: - - code_quality - include: - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/python_install@latest.yaml' @@ -19,5 +16,4 @@ flake8: - ${PROJECT_PATH}/**/*.py - .gitlab-ci.yml - ${PROJECT_PATH}/pyproject.toml - - ${PROJECT_PATH}/setup.cfg - ${PROJECT_PATH}/.flake8 diff --git a/templates/python/testing/pytest/pytest.yml b/templates/python/testing/pytest/pytest.yml index e106196..a9bb8b5 100644 --- a/templates/python/testing/pytest/pytest.yml +++ b/templates/python/testing/pytest/pytest.yml @@ -1,18 +1,19 @@ +include: + - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/python_install@latest.yaml' + pytest: image: python:${IMAGE_TAG} stage: test variables: - IMAGE_TAG: "latest" + IMAGE_TAG: !reference [.python_install, variables, IMAGE_TAG] PROJECT_PATH: "." PYTHON_SETUP: "pip install ${PROJECT_PATH}[TESTS]" script: - - python --version # Debug - - python -m venv venv --upgrade-deps || python -m venv venv # upgrade-deps is not supported before 3.9 - - source venv/bin/activate - - ${PYTHON_SETUP} + - !reference [.python_install, script] - pytest ${PROJECT_PATH} only: changes: - ${PROJECT_PATH}/**/*.py - .gitlab-ci.yml - ${PROJECT_PATH}/pyproject.toml + - ${PROJECT_PATH}/pytest.ini diff --git a/tests/pytest_project/pyproject.toml b/tests/pytest_project/pyproject.toml index b72bdac..c27397b 100644 --- a/tests/pytest_project/pyproject.toml +++ b/tests/pytest_project/pyproject.toml @@ -17,3 +17,8 @@ testpaths = [ "tests", "integration", ] + +[project.optional-dependencies] +TESTS = [ + "pytest", +] -- GitLab