From 30984640edc909df1527515c16bd1fd88f8b6eb5 Mon Sep 17 00:00:00 2001 From: Guillaume Lambert Date: Thu, 17 Jun 2021 14:43:00 +0200 Subject: [PATCH] Feat: allow more tox parallel mode configurations Signed-off-by: Guillaume Lambert Change-Id: I8a812ed25f3836c100704914f08491a61642679f --- docs/jjb/lf-python-jobs.rst | 55 ++++++++++++++-------- ...allel-mode-configurations-d3848eb605b3bdc5.yaml | 8 ++++ shell/tox-run.sh | 12 +++-- 3 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/allow-more-tox-parallel-mode-configurations-d3848eb605b3bdc5.yaml diff --git a/docs/jjb/lf-python-jobs.rst b/docs/jjb/lf-python-jobs.rst index 48f35884..daf755aa 100644 --- a/docs/jjb/lf-python-jobs.rst +++ b/docs/jjb/lf-python-jobs.rst @@ -43,8 +43,11 @@ Creates a Tox virtual environment and invokes tox. :Required Parameters: - :parallel: Boolean. If true use tox with the options "--parallel auto" - and "--parallel-live" to parallelize jobs in the envlist; + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". Job Templates @@ -200,10 +203,12 @@ https://docs.sonarqube.org/display/PLUG/Python+Coverage+Results+Import :mvn-global-settings: The name of the Maven global settings to use :mvn-goals: The Maven goal to run first. (default: validate) :mvn-version: Version of maven to use. (default: mvn35) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :pre-build-script: Shell script to execute before the Sonar builder. For example, install prerequisites or move files to the repo root. (default: a string with a shell comment) @@ -293,10 +298,12 @@ Plug-in configurations :disable-job: Whether to disable the job (default: false) :git-url: URL clone project from. (default: $GIT_URL/$PROJECT) :github-url: URL for Github. (default: https://github.com) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :pre-build-script: Shell script to run before tox. Useful for setting up dependencies. (default: a string with a shell comment) :python-version: Python version to invoke pip install of tox-pyenv @@ -405,10 +412,12 @@ variables before running. :pre-build-script: Shell script to execute before the Tox builder. For example, install prerequisites or move files to the repo root. (default: a string with a shell comment) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :python-version: Python version to invoke pip install of tox-pyenv (default: python2) :stream: Keyword representing a release code-name. @@ -574,10 +583,12 @@ is optional, it defaults to pypi.org. :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '') :mvn-params: Parameters to pass to the mvn CLI. (default: '') :mvn-version: Version of maven to use. (default: mvn35) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :pre-build-script: Shell script to execute before the tox builder. For example, install system prerequisites. (default: a shell comment) :pypi-repo: Key for the PyPI target repository in the .pypirc file, @@ -688,10 +699,12 @@ is optional, it defaults to pypi.org. :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '') :mvn-params: Parameters to pass to the mvn CLI. (default: '') :mvn-version: Version of maven to use. (default: mvn35) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :pre-build-script: Shell script to execute before the tox builder. For example, install system prerequisites. (default: a shell comment) :pypi-repo: Key for the PyPI target repository in the .pypirc file, @@ -806,10 +819,12 @@ pyenv variables before running. :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '') :mvn-params: Parameters to pass to the mvn CLI. (default: '') :mvn-version: Version of maven to use. (default: mvn35) - :parallel: Boolean indicator for tox to run tests in parallel or series. + :parallel: If different from false, try pass this parameter to tox option + "--parallel" to parallelize jobs in the envlist (and then activate the + option "--parallel-live" to display output in logs). + Possible values are "auto" (equivalent to "true" for legacy), + "all" or any integer. Any other value is equivalent to "false". (default: false, in series) - If true use tox with the options "--parallel auto" and "--parallel-live" - to parallelize jobs in the envlist. :pre-build-script: Shell script to execute before the tox builder. For example, install system prerequisites. (default: a shell comment) :python-version: Python version to invoke pip install of tox-pyenv diff --git a/releasenotes/notes/allow-more-tox-parallel-mode-configurations-d3848eb605b3bdc5.yaml b/releasenotes/notes/allow-more-tox-parallel-mode-configurations-d3848eb605b3bdc5.yaml new file mode 100644 index 00000000..38ebc044 --- /dev/null +++ b/releasenotes/notes/allow-more-tox-parallel-mode-configurations-d3848eb605b3bdc5.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Parallel jobs are now natively supported by tox since version 3.7.0 + thanks to the option "-p" / "--parallel". + This new option offers more possibilities than detox and other options + have also been introduced to tune tox behavior in parallel mode. This + evolution allows more tox parallel mode configurations in yaml templates. diff --git a/shell/tox-run.sh b/shell/tox-run.sh index 682650c9..4321ea68 100644 --- a/shell/tox-run.sh +++ b/shell/tox-run.sh @@ -40,9 +40,15 @@ if [[ -n ${TOX_ENVS:-} ]]; then TOX_OPTIONS_LIST=$TOX_OPTIONS_LIST" -e $TOX_ENVS" fi; -if [[ ${PARALLEL,,} = true ]]; then - TOX_OPTIONS_LIST=$TOX_OPTIONS_LIST" --parallel auto --parallel-live" -fi; +case ${PARALLEL,,} in + true|auto ) + TOX_OPTIONS_LIST=$TOX_OPTIONS_LIST" --parallel auto --parallel-live";; + all ) + TOX_OPTIONS_LIST=$TOX_OPTIONS_LIST" --parallel all --parallel-live";; + [0-9]* ) + TOX_OPTIONS_LIST=$TOX_OPTIONS_LIST" --parallel ${PARALLEL} --parallel-live";; +esac + # $TOX_OPTIONS_LIST are intentionnaly not surrounded by quotes # to correcly pass options to tox -- 2.16.6