Commit 9eb34997 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix/doc_matrix' into 'master'

fix: add documentation about Use Multiple Python Versions

See merge request to-be-continuous/python!150
parents 275402a8 b2c15cac
Loading
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -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