diff --git a/templates/python/testing/pytest/README.md b/templates/python/testing/pytest/README.md index a46b64373b63cff0a7782929e52670c60ee3dff9..4e9065ba07f3aa2c78bd83ad6fd8022edd4acc60 100644 --- a/templates/python/testing/pytest/README.md +++ b/templates/python/testing/pytest/README.md @@ -10,15 +10,16 @@ automation, modular fixtures, parameterized testing, and many other features. desired rules. 2. Include the pytest template in your CI/CD configuration (see quick use above). 3. If you need to customize the job, check - the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization). + the [job customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization). ## Variables -| Name | Description | Default | -|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------| -| `PROJECT_PATH` | The path to the project root directory. | `"."` | -| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links | `"latest"` | -| `PYTHON_SETUP` | Bash commands to setup your python environment. Default rely on `pyproject.toml` to install project and test dependencies. | `"pip install .[TESTS]"` | +| Name | Description | Default | +|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------| +| `PROJECT_PATH` | The path to the project root directory. | `"."` | +| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links | `"latest"` | +| `PYTHON_SETUP` | Bash commands to setup your python environment. Default rely on `pyproject.toml` to install project and test dependencies. | `"pip install .[TESTS]"` | +| `PYTEST_RUN_CMD` | Bash command to run pytest. | `"pytest ${PROJECT_PATH}"` | ## Global Configuration of pytest @@ -28,7 +29,8 @@ about [pytest configuration](https://docs.pytest.org/en/stable/customize.html) f ## Multiple pytest Jobs in the same pipeline -You can run this pytest job multiple times in the same pipeline (e.g. to test multiple python version +You can run this pytest job multiple times in the same pipeline (e.g. to test multiple python +version or different namespaces) using extends GitLab keyword. ```yaml @@ -36,7 +38,7 @@ stages: - test include: - - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/pytest@1.0.0.yaml' + - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/pytest@1.0.0.yaml' # Compatibility tests pytest_3.10: diff --git a/templates/python/testing/pytest/pytest.yml b/templates/python/testing/pytest/pytest.yml index d0331768a1b764b820733cb671b0674ed6fb10bd..d646bad5329d80f19bd1144d25aeff22e9a3da87 100644 --- a/templates/python/testing/pytest/pytest.yml +++ b/templates/python/testing/pytest/pytest.yml @@ -7,10 +7,11 @@ pytest: variables: IMAGE_TAG: !reference [.python_install, variables, IMAGE_TAG] PROJECT_PATH: "." - PYTHON_SETUP: "pip install ${PROJECT_PATH}[TESTS]" + PYTHON_SETUP: "pip install -r ${PROJECT_PATH}/requirements.txt" + PYTEST_RUN_CMD: "pytest ${PROJECT_PATH}" script: - !reference [.python_install, script] - - pytest ${PROJECT_PATH} + - ${PYTEST_RUN_CMD} only: changes: - ${PROJECT_PATH}/**/*.py