Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit e5b7e15d authored by Dorian Turba's avatar Dorian Turba
Browse files

simplify pytest template

parent 00855fd8
No related branches found
No related tags found
No related merge requests found
Pipeline #23487 failed
......@@ -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:
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment