Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.cfg parsed differently on Jenkins #1428

Closed
rsokl opened this issue Sep 25, 2019 · 6 comments · Fixed by #1466
Closed

setup.cfg parsed differently on Jenkins #1428

rsokl opened this issue Sep 25, 2019 · 6 comments · Fixed by #1466
Labels
bug:normal affects many people or has quite an impact pr-merged

Comments

@rsokl
Copy link

rsokl commented Sep 25, 2019

This bug can be reproduced using this trivial repo: https://github.com/rsokl/tox-bug

Context

  • Using a setup.cfg file instead of tox.ini
  • Running tox on Jenkins (i.e. JENKINS_URL or HUDSON_URL are environment variables are set)

Problem

The documentation specifies that the setup.cfg file should contain a [tox:tox] section. However, on Jenkins, the file is parsed to look for a [tox] section instead.

Example

Consider the simple setup.cfg

# contents of setup.cfg
[tox:tox]  # does not work on Jenkins; [tox] does work                          
envlist = py37
toxworkdir = build/tox

The toxworkdir is set as-expected when tox is run locally (off-Jenkins):

>>> tox
GLOB sdist-make: /home/rsokl/tox_dummy/setup.py
py37 create: /home/rsokl/tox_dummy/build/tox/py37

Running this "on Jenkins", the [tox:tox] section is not found and toxworkdir fails to get set:

>>> env JENKINS_URL="" tox
GLOB sdist-make: /home/ry26099/tox_dummy/setup.py
python create: /home/ry26099/tox_dummy/.tox/python

Now we can modify the setup.cfg to contain a [tox] section, and find inverted behavior

# adapted setup.cfg
[tox]  # works on Jenkins; does not work locally                          
envlist = py37
toxworkdir = build/tox

Running locally, no tox section is found, which is to be expected since we deviate from the documented [tox:tox] form (note that the toxworkdir is not set):

>>> tox
GLOB sdist-make: /home/ry26099/tox_dummy/setup.py
python create: /home/ry26099/tox_dummy/.tox/python

But Jenkins does see this tox section (note that the toxworkdir is properly set):

>>> env JENKINS_URL="" tox
GLOB sdist-make: /home/ry26099/tox_dummy/setup.py
py37 create: /home/ry26099/tox_dummy/build/tox/py37
@rsokl rsokl added the bug:normal affects many people or has quite an impact label Sep 25, 2019
@asottile
Copy link
Contributor

that is weird, it's probably due to the custom behaviour documented here

@daneah
Copy link

daneah commented Nov 27, 2019

@asottile The documentation seems to state that [tox:jenkins] can override global configuration, implying that if you don't override anything you'll still get the global configuration. But when using setup.cfg, global configuration does not appear to be honored. I was able to confirm this by moving my (not working) [tox:tox] section from setup.cfg to a [tox] section in a tox.ini file and see it start working again. A workaround is to specify [tox:tox:jenkins] in setup.cfg, but this requires duplicating some config which is non-ideal (unless I'm missing an easy way to say "copy config from _____"?)

Hopefully this helps exemplify the issue:

# Running locally with setup.cfg:
#
# [tox:tox]
# envlist = py37

$ docker run -it --rm -v $(pwd):/code quay.io/python-devs/ci-image sh -c 'python3.7 -m pip install --user tox && cd /code && python3.7 -m tox -v -a'
using tox.ini: /code/tox.ini (pid 12)
using tox-3.14.1 from /home/runner/.local/lib/python3.7/site-packages/tox/__init__.py (pid 12)
default environments:
py37 -> [no description]

# Simulating Jenkins (by adding `-e JENKINS_URL=...`) with setup.cfg:
#
# [tox:tox]
# envlist = py37

$ docker run -it --rm -e JENKINS_URL='http://iam.jenkins' -v $(pwd):/code quay.io/python-devs/ci-image sh -c 'python3.7 -m pip install --user tox && cd /code && python3.7 -m tox -v -a'
using tox.ini: /code/tox.ini (pid 40)
using tox-3.14.1 from /home/runner/.local/lib/python3.7/site-packages/tox/__init__.py (pid 40)
additional environments:
python -> [no description]

# Simulating Jenkins after moving config to tox.ini:
#
# [tox]
# envlist = py37
#
# OR duplicating in setup.cfg:
#
# [tox:tox:jenkins]
# envlist = py37

$ docker run -it --rm -e JENKINS_URL='http://iam.jenkins' -v $(pwd):/code quay.io/python-devs/ci-image sh -c 'python3.7 -m pip install --user tox && cd /code && python3.7 -m tox -v -a'
using tox.ini: /code/tox.ini (pid 40)
using tox-3.14.1 from /home/runner/.local/lib/python3.7/site-packages/tox/__init__.py (pid 40)
additional environments:
py37 -> [no description]

@asottile
Copy link
Contributor

oh yeah to be clear I'm pretty sure there's a bug here :) was hopefully giving a contributor a pointer to look for in the code

@daneah
Copy link

daneah commented Nov 27, 2019

The TL;DR from my comment for the moment is that duplicating [tox:tox] to [tox:tox:jenkins] appears to be a sufficient workaround 😄

@helpr helpr bot added the pr-available label Nov 28, 2019
gaborbernat pushed a commit that referenced this issue Nov 28, 2019
Fixes #1428

When running in Jenkins and using `setup.cfg`, tox would not fall back
to the [tox:tox] configuration properly. This was due to how the
fallback section name was calculated in this specific combination of
characteristics.

on-behalf-of: @ithaka <dane.hillard@ithaka.org>
@helpr helpr bot added pr-merged and removed pr-available labels Nov 28, 2019
@gaborbernat
Copy link
Member

gaborbernat commented Dec 2, 2019

Released as 3.14.2 - see https://tox.readthedocs.io/en/latest/changelog.html#v3-14-2-2019-12-02

@daneah
Copy link

daneah commented Dec 2, 2019

Thanks for the update @gaborbernat!

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact pr-merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants