From b2c15cac86bf41349e55cb4b5cfb4ae963f75323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Montury?= <10528250-pytgaen@users.noreply.gitlab.com> Date: Mon, 28 Apr 2025 16:07:43 +0200 Subject: [PATCH] docs: document how to use multiple Python versions --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e53a639..7c2b877 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,37 @@ dependencies = [ "pytest>=8.0.0,<9", ... ] -```` +``` + +## Use Multiple Python Versions + +For some jobs, it can be relevant to use multiple Python versions, such as: + +- Test jobs: `py-unittest`, `py-pytest`, `py-nosetest` +- `py-publish` jobs (especially if you're not generating a pure Python package) + +This setup is done by defining the PYTHON_IMAGE variable with a parallel/matrix strategy in your .gitlab-ci.yml. + +For example, to run py-test jobs using both python:3.13-slim and python:3.12-alpine: + +```yaml +py-pytest: + parallel: + matrix: + - PYTHON_IMAGE: python:3.13-slim + - PYTHON_IMAGE: python:3.12-alpine +``` + +If your tests cannot be executed concurrently due to shared resources (e.g. database access), you can use the `resource_group` feature to limit parallel execution: + +```yaml +py-pytest: + parallel: + matrix: + - PYTHON_IMAGE: python:3.13-slim + - PYTHON_IMAGE: python:3.12-alpine + resource_group: db_access_tests +``` ## Jobs -- GitLab