Newer
Older
The objective of the `python_install` job is to provide a Python environment with all requirements
installed for CI jobs. This reusable job can help speed up other jobs creation and ensure
consistent configuration across CI jobs that rely on a python environment.
1. Include the pytest template in your CI/CD configuration (see quick use above).
2. Create a job that extend the `python_install` job template.
3. If you need to customize the job, check
the [jobs 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 `requirements.txt` to install all dependencies. | `"pip install -r ${PROJECT_PATH}/requirements.txt"` |
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/python_install@1.0.0.yaml'
flake8:
extend: python_install
stage: code_quality
PYTHON_SETUP: "pip install ${PROJECT_PATH}[CODE_QUALITY]"
script:
python_install
- flake8 ${PROJECT_PATH} -v
```
## Add a <a href="https://docs.pytest.org/en/latest/"><img alt="Tested with pytest" src="https://img.shields.io/badge/Tested%20with-pytest-green"></a> Badge to your project README.md
To display the use of pytest in your project, you can add the following badge to your README.md:
```markdown
<a href="https://docs.pytest.org/en/latest/">
<img alt="Tested with pytest" src="https://img.shields.io/badge/Tested%20with-pytest-green">
</a>
```
Please note that the `src` URL in the pytest badge will need to be updated to reflect the actual
testing status of your project in your continuous integration pipeline.