From e2f1a81da750546b86063c61d0ee4d1ebb7b3a8f Mon Sep 17 00:00:00 2001 From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com> Date: Mon, 28 Aug 2023 17:30:30 +0200 Subject: [PATCH] add test for python_install + dependencies --- .gitlab-ci.yml | 19 +++++++++++++++++++ r2_metadata/python_install.r2.yml | 4 ++-- .../partial/{ => python_install}/README.md | 0 .../{ => python_install}/python_install.yml | 0 tests/python_install_project/pyproject.toml | 11 +++++++++++ .../src/python_install_project/__init__.py | 3 +++ .../src/python_install_project/main.py | 11 +++++++++++ 7 files changed, 46 insertions(+), 2 deletions(-) rename templates/python/partial/{ => python_install}/README.md (100%) rename templates/python/partial/{ => python_install}/python_install.yml (100%) create mode 100644 tests/python_install_project/pyproject.toml create mode 100644 tests/python_install_project/src/python_install_project/__init__.py create mode 100644 tests/python_install_project/src/python_install_project/main.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9451895..c77ac8a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ stages: - templates include: + - local: 'templates/python/python_install.yml' - local: 'templates/python/testing/pytest/pytest.yml' - local: 'templates/python/code_quality/flake8/flake8.yml' - local: 'templates/python/code_quality/black/black.yml' @@ -9,8 +10,21 @@ include: - local: 'templates/python/code_quality/mypy/mypy.yml' - local: 'templates/python/code_quality/ruff/ruff.yml' +python_install: + stage: templates + variables: + PROJECT_PATH: "tests/python_install_project" + PYTHON_SETUP: "pip install ${PROJECT_PATH}" + only: + changes: + - .gitlab-ci.yml + - pyproject.toml + - templates/python/partial/python_install/**/* + - tests/python_install_project/**/* + pytest: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/pytest_project" PYTHON_SETUP: "pip install ${PROJECT_PATH}[TESTS]" @@ -23,6 +37,7 @@ pytest: flake8: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/flake8_project" only: @@ -34,6 +49,7 @@ flake8: black: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/black_project" only: @@ -46,6 +62,7 @@ black: isort: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/isort_project" only: @@ -57,6 +74,7 @@ isort: mypy: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/mypy_project" only: @@ -68,6 +86,7 @@ mypy: ruff: stage: templates + needs: ["python_install"] variables: PROJECT_PATH: "tests/ruff_project" only: diff --git a/r2_metadata/python_install.r2.yml b/r2_metadata/python_install.r2.yml index 3466403..da70b16 100644 --- a/r2_metadata/python_install.r2.yml +++ b/r2_metadata/python_install.r2.yml @@ -1,6 +1,6 @@ files: - template: ../templates/python/partial/python_install.yml - documentation: ../templates/python/partial/README.md + template: ../templates/python/partial/python_install/python_install.yml + documentation: ../templates/python/partial/python_install/README.md data: description: "Job that is meant to be extend by jobs that need a python environment." icon: ðŸ diff --git a/templates/python/partial/README.md b/templates/python/partial/python_install/README.md similarity index 100% rename from templates/python/partial/README.md rename to templates/python/partial/python_install/README.md diff --git a/templates/python/partial/python_install.yml b/templates/python/partial/python_install/python_install.yml similarity index 100% rename from templates/python/partial/python_install.yml rename to templates/python/partial/python_install/python_install.yml diff --git a/tests/python_install_project/pyproject.toml b/tests/python_install_project/pyproject.toml new file mode 100644 index 0000000..5a1a5eb --- /dev/null +++ b/tests/python_install_project/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "python_install_project" +version = "0.1.0" +authors = [ + { name = "Author Name", email = "author.name@example.com" }, +] +description = "A description of what the package is for." diff --git a/tests/python_install_project/src/python_install_project/__init__.py b/tests/python_install_project/src/python_install_project/__init__.py new file mode 100644 index 0000000..d4cc63e --- /dev/null +++ b/tests/python_install_project/src/python_install_project/__init__.py @@ -0,0 +1,3 @@ +from pytest_project.main import main + +__all__ = ['main'] diff --git a/tests/python_install_project/src/python_install_project/main.py b/tests/python_install_project/src/python_install_project/main.py new file mode 100644 index 0000000..28caf00 --- /dev/null +++ b/tests/python_install_project/src/python_install_project/main.py @@ -0,0 +1,11 @@ +"""Sample main module.""" + + +def main() -> bool: + """Sample main function.""" + print("Hello, world!") + return True + + +if __name__ == '__main__': + main() -- GitLab