5

There is the following simple pipeline:
buildtestdeploy
that uses specified python version for all stages, for example 3.8.

How can I scale (parametrize) it for python with versions: 3.7, 3.8 and 3.9?
Simplest solution that comes to mind is to create 3 different pipelines with hardcoded python versions:
build_37test_37deploy_37
build_38test_38deploy_38
build_39test_39deploy_39.

I know this is a very bad solution.
What is the right way?

030
  • 13,383
  • 17
  • 76
  • 178
Arseny
  • 51
  • 1

3 Answers3

3

I would suggest to use the parallel matrix feature of GitLab CI (see also here). As Bruce Becker suggested utilizing tox is also a valid option and exactly designed for your use case.

build:
  image: python:${PY_VERSION}
  parallel:
    matrix:
      - PY_VERSION: ["3.7", "3.8", "3.9"]
  script: poetry build
YoshiMbele
  • 246
  • 1
  • 6
1

One could use Gitlab templates in conjunction with an environment variable that sets the python version.

030
  • 13,383
  • 17
  • 76
  • 178
0

You can parametrize GitLab pipeline using variables keyword in gitlab-ci.yaml:

variables:
  PYTHON_VERSION:
    value: "3.7"
    options:
      - "3.7"
      - "3.8"
      - "3.9"
    description: "Python version"

You can see a sample GitLab gitlab-ci.yaml using variables keyword at my GitLab or read an article about GitLab Parameterized Pipelines.

Disclaimer: I wrote the above article.

rokpoto.com
  • 266
  • 3
  • 9