Page MenuHomePhabricator

tox 4 no more support [tox:jenkins] configuration section
Closed, ResolvedPublic

Description


Reported upstream https://github.com/tox-dev/tox/issues/3115


Tox jobs got upgraded to tox 4 (T345152) and as part of the rewrite upstream dropped support for the tox:jenkins section. In the Upstream documentation for the breaking change:

People who still want Jenkins override support may create a tox plugin to achieve this functionality

We typically use tox:jenkins to override the list of environments and/or ensuring to not skip on missing interpreters.

Examples

https://gerrit.wikimedia.org/r/c/labs/tools/wikinity/+/954748

tox.ini
[tox]
envlist = lint,test
skipsdist = True

[tox:jenkins]
envlist = lint,jenkins

[testenv]
setenv = 
  jenkins: FLASK_CONFIG_FILE = wikimedia_config.yaml

[testenv:jenkins]

Under Jenkins tox runs test instead of jenkins and FLASK_CONFIG_FILE environment variable is not set which leads to the failure.

Another example is Quibble which has tox environment using whatever python3 version is available while on Jenkins we run against explicit python versions (3.7, 3.8, 3.9):

tox.ini
[tox]
envlist = check, py3-lint, black, py3-unit, integration

[tox:jenkins]
envlist = check, py{37,38,39}-{lint}, black, py{37,38,39}-{unit}, doc

Event Timeline

Change 954971 had a related patch set uploaded (by Hashar; author: Hashar):

[labs/tools/wikinity@master] Adjustement for tox 4

https://gerrit.wikimedia.org/r/954971

I gave it a try with a plugin which can be dropped in a toxfile.py in a repo:

toxfile.py
@impl
def tox_add_core_config(core_conf, state):
    if not 'JENKINS_URL' in os.environ:
        return
    core_conf.loaders.insert(0, state.conf._src.get_loader(IniSection('tox', 'jenkins'), {}))

In integration/quibble.git that gives me:

$ tox -l
check
py3-lint
black
py3-unit
integration
$ JENKINS_URL=1 tox -l
check
py37-lint
py38-lint
py39-lint
black
py37-unit
py38-unit
py39-unit
doc

Which looks promising but I dislike using state.conf._src variable which has an underscore prefix indicated it not part of the public API.

Change 954971 merged by jenkins-bot:

[labs/tools/wikinity@master] Adjustement for tox 4

https://gerrit.wikimedia.org/r/954971

Change 955323 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/quibble@master] Bring back support for [tox:jenkins]

https://gerrit.wikimedia.org/r/955323

hashar updated the task description. (Show Details)
hashar moved this task from Backlog to Reported Upstream on the Upstream board.

Change 955380 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/tox-jenkins-override@master] tox v4 support for [tox:jenkins] configuration

https://gerrit.wikimedia.org/r/955380

Change 955394 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] Setup tox for integration/tox-jenkins-override

https://gerrit.wikimedia.org/r/955394

Change 955394 merged by jenkins-bot:

[integration/config@master] Setup tox for integration/tox-jenkins-override

https://gerrit.wikimedia.org/r/955394

Change 955323 abandoned by Hashar:

[integration/quibble@master] Bring back support for [tox:jenkins]

Reason:

I have made it a plugin in the repository integration/tox-jenkins-override Ife15751da24f28a6479ec7bdd6a902c35f70ff63

The plugin will need to be installed in the Docker base image.

https://gerrit.wikimedia.org/r/955323

Change 955397 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] dockerfiles: upgrade tox to 4.8.0

https://gerrit.wikimedia.org/r/955397

Change 955380 merged by jenkins-bot:

[integration/tox-jenkins-override@master] tox v4 support for [tox:jenkins] configuration

https://gerrit.wikimedia.org/r/955380

Change 955780 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] dockerfiles: install python3 pip from source v23.2.1

https://gerrit.wikimedia.org/r/955780

Change 955780 merged by jenkins-bot:

[integration/config@master] dockerfiles: install python3 pip from source v23.2.1

https://gerrit.wikimedia.org/r/955780

Change 955919 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: switch tox jobs to pip v23.2.1

https://gerrit.wikimedia.org/r/955919

Change 955920 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: switch zuul-cloner job to pip v23.2.1

https://gerrit.wikimedia.org/r/955920

Change 955397 merged by jenkins-bot:

[integration/config@master] dockerfiles: upgrade tox to 4.8.0

https://gerrit.wikimedia.org/r/955397

The releng CI images having tox 4.8.0 and support for tox:jenkins tox configuration section are:

docker-registry.wikimedia.org/releng/tox-mysqld:4.8.0-1
docker-registry.wikimedia.org/releng/tox-buster:4.8.0-1
docker-registry.wikimedia.org/releng/zuul-cloner:0.3.0-s3
docker-registry.wikimedia.org/releng/tox-pyspark:4.8.0-1
docker-registry.wikimedia.org/releng/tox-acme-chief:4.8.0-1
docker-registry.wikimedia.org/releng/tox-java8:4.8.0-1
docker-registry.wikimedia.org/releng/tox-poolcounter:4.8.0-1
docker-registry.wikimedia.org/releng/tox-pywikibot:4.8.0-1