Pytest
Objective
Run Pytest on your Python project.
Available components
-
pytest
: run Pytest on a specific version of Python of your choice. -
pytest:toxify:py3
: run Pytest on all live versions of Python 3
Features
Both jobs supports:
- Configurable Inputs
- Custom stage, image and many other
- The following project configuration files:
pyproject.toml
- Automatic installation of missing dependencies
- Fail fast: jobs do not depend on anything and will start as soon as possible
- Code coverage integrated with Gitlab
- Unit test reports integrated with Gitlab
Pytest
This component provide a pytest
job to test your project on the Python version of your choice.
To use it, you need to add the following include to your .gitlab-ci.yml
file.
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/pytest/pytest@2.1.0
You can customize the job by overriding specific inputs and variables. How to define inputs?
Available component inputs (lowercase name) and variables (uppercase name):
Name of input/VARIABLE | Description | Default |
---|---|---|
dependencies /PYTEST_DEPENDENCIES
|
Additional Python dependencies installed in the environment. | pytest coverage |
image |
Image for the job. | ghcr.io/astral-sh/uv:0.6.14-python3.13-alpine |
options /PYTEST_OPTIONS
|
Options for pytest. | --junitxml=report.xml |
project-path /PYTEST_PROJECT_PATH
|
Path to the project. | . |
python /PYTEST_PYTHON
|
Version of Python to use. | "3.13" |
stage |
Stage of the job. | test |
tests-paths /PYTEST_TESTS_PATHS
|
Path to file or folder where tests are located. Separate paths with a space. | . |
Internal dependencies
The following jobs are internal dependencies, do not override it.
Name | Description | Origin |
---|---|---|
.uv-base |
Environment setup. | $CI_SERVER_FQDN/swepy/cicd-templates/uv-base/uv-base |
The following variables are internal dependencies, do not override it.
Name | Description | Default |
---|---|---|
UV_ADD_PACKAGES |
Internal UV. Job Python dependencies. | $PYTEST_DEPENDENCIES |
UV_CACHE_DIR |
Internal UV. Path to the cache directory. | .uv-cache |
UV_LINK_MODE |
Internal UV. Gitlab constraint. | copy |
UV_PROJECT |
Internal UV. Run pytest within the given project directory. | $PYTEST_PROJECT_PATH |
UV_PYTHON |
Internal UV. Version of Python to use. | $PYTEST_PYTHON |
Pytest Toxify
This component provide a pytest:toxify
job to test your project on all live Python versions.
To use it, you need to add the following include to your .gitlab-ci.yml
file.
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/pytest/toxify@2.1.0
You can customize the job by overriding specific inputs and variables. How to define inputs?
Available component inputs (lowercase name) and variables (uppercase name):
Name of input/VARIABLE | Description | Default |
---|---|---|
dependencies /PYTEST_DEPENDENCIES
|
Additional Python dependencies installed in the environment. | pytest coverage |
image-namespace |
Image namespace for the job. | ghcr.io/astral-sh/uv |
image-uv-version |
Version of uv used by job. | 0.6.14 |
image-base |
Image base for the job. | -alpine |
options /PYTEST_OPTIONS
|
Options for pytest. | --junitxml=pytest-test-report.xml |
project-path /PYTEST_PROJECT_PATH
|
Path to the project. | . |
version-to-test |
Versions of Python to run the tests on. | [ "3.9", "3.10", "3.11", "3.12", "3.13" ] |
stage |
The stage of the job. | test |
tests-paths /PYTEST_TESTS_PATHS
|
Path to file or folder where tests are located. Separate paths with a space. | . |
Internal dependencies
The following jobs are internal dependencies, do not override it.
Name | Description | Origin |
---|---|---|
.uv-base |
Environment setup. | $CI_SERVER_FQDN/swepy/cicd-templates/uv-base/uv-base |
The following variables are internal dependencies, do not override it.
Name | Description | Default |
---|---|---|
UV_ADD_PACKAGES |
Internal UV. Job Python dependencies. | $PYTEST_DEPENDENCIES |
UV_CACHE_DIR |
Internal UV. Path to the cache directory. | .uv-cache |
UV_LINK_MODE |
Internal UV. Gitlab constraint. | copy |
UV_PROJECT |
Internal UV. Run pytest within the given project directory. | $PYTEST_PROJECT_PATH |
UV_PYTHON |
Internal UV. Version of Python to use. | $PYTEST_PYTHON |