Skip to content

Commit

Permalink
Rebuild tox environment after change requirements
Browse files Browse the repository at this point in the history
Tox does not detect changes in requirements, and will fail with missing
imports.
[example](https://saml.buildvm.openshift.eng.bos.redhat.com:8888/job/art-tools/job/elliott/job/master/6/console)
[tox bug](tox-dev/tox#149)

This PR looks at the files that have changed in the last 5 commits, and
if one of the files that might contain requirements have changed, will
add the argument `--recreate` to the `tox` invocation.

The magical number 5 was chosen, as it is conceivable that there are
multiple commits locally which contain the change, and the change in
dependencies is not detected.

Alternative approaches are:
- install a tox plugin
- always recreate in Jenkins
  • Loading branch information
joepvd committed Sep 1, 2020
1 parent 7024be6 commit d642e92
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ pipeline {
steps {
script {
catchError(stageResult: 'FAILURE') {
sh "tox > results.txt 2>&1"
sh """
tox_args="\$(git diff --name-only HEAD~5 | grep -Fxq -e requirements.txt -e requirements-dev.txt -e MANIFEST.in -e setup.py && echo '--recreate')"
tox \$tox_args > results.txt 2>&1
"""
}
results = readFile("results.txt").trim()
echo results
Expand Down

0 comments on commit d642e92

Please sign in to comment.