Commit b2c15cac authored by Gaëtan Montury's avatar Gaëtan Montury Committed by Pierre Smeyers
Browse files

docs: document how to use multiple Python versions

parent 275402a8
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