From 0872d4a716f201a1ff6c567dc78f4d3805108450 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Tue, 20 Aug 2019 11:46:31 -0400 Subject: [PATCH] Add python templates to run tox on merge Makes the Python job groups and templates parallel to the maven job groups and templates. Although no build is required by most Python projects, re-testing after merge is a chance to reveal failures in the new tree. Change-Id: I1fb793e08deb435a838d76d634dbbad730a3d7fa Signed-off-by: Lott, Christopher (cl778h) --- docs/jjb/lf-python-jobs.rst | 67 ++++++++++++++-- jjb/lf-python-job-groups.yaml | 2 + jjb/lf-python-jobs.yaml | 90 ++++++++++++++++++++-- ...python-tox-merge-template-c965c8b9ab644b20.yaml | 7 ++ 4 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/add-python-tox-merge-template-c965c8b9ab644b20.yaml diff --git a/docs/jjb/lf-python-jobs.rst b/docs/jjb/lf-python-jobs.rst index 15c5b088..8f940e8c 100644 --- a/docs/jjb/lf-python-jobs.rst +++ b/docs/jjb/lf-python-jobs.rst @@ -192,10 +192,10 @@ https://docs.sonarqube.org/display/PLUG/Python+Coverage+Results+Import Tox Verify ---------- -Tox runner to verify a project. This job is pyenv aware so if the image -contains an installation of pyenv at /opt/pyenv it will pick it up and run -Python tests with the appropriate Python versions. This job will set the -following pyenv variables before running. +Tox runner to verify a project on creation of a patch set. +This job is pyenv aware so if the image contains an installation of pyenv +at /opt/pyenv it will pick it up and run Python tests with the appropriate +Python versions. This job will set the following pyenv variables before running. .. code:: bash @@ -240,7 +240,64 @@ following pyenv variables before running. (default: '') :tox-envs: Tox environments to run. If blank run everything described in tox.ini. (default: '') - :gerrit_trigger_file_paths: Override file paths which used to filter which + :gerrit_trigger_file_paths: Override file paths used to filter which + file modifications will trigger a build. Refer to JJB documentation for + "file-path" details. + https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit + + +Tox Merge +--------- + +Tox runner to verify a project after merge of a patch set. +This job is pyenv aware so if the image contains an installation of pyenv +at /opt/pyenv it will pick it up and run Python tests with the appropriate +Python versions. This job will set the following pyenv variables before running. + +.. code:: bash + + export PYENV_ROOT="/opt/pyenv" + export PATH="$PYENV_ROOT/bin:$PATH" + +:Template Names: + + - {project-name}-tox-merge-{stream} + - gerrit-tox-merge + - github-tox-merge + +:Comment Trigger: remerge + +:Required Parameters: + + :build-node: The node to run build on. + :jenkins-ssh-credential: Credential to use for SSH. (Generally set + in defaults.yaml) + +:Optional Parameters: + + :branch: The branch to build against. (default: master) + :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7) + :build-timeout: Timeout in minutes before aborting build. (default: 10) + :git-url: URL clone project from. (default: $GIT_URL/$PROJECT) + :pre-build-script: Shell script to execute before the CLM builder. + For example, install prerequisites or move files to the repo root. + (default: a string with only a comment) + :python-version: Version of Python to configure as a base in virtualenv. + (default: python3) + :stream: Keyword representing a release code-name. + Often the same as the branch. (default: master) + :submodule-recursive: Whether to checkout submodules recursively. + (default: true) + :submodule-timeout: Timeout (in minutes) for checkout operation. + (default: 10) + :submodule-disable: Disable submodule checkout operation. + (default: false) + :tox-dir: Directory containing the project's tox.ini relative to + the workspace. Empty works if tox.ini is at project root. + (default: '') + :tox-envs: Tox environments to run. If blank run everything described + in tox.ini. (default: '') + :gerrit_trigger_file_paths: Override file paths used to filter which file modifications will trigger a build. Refer to JJB documentation for "file-path" details. https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit diff --git a/jjb/lf-python-job-groups.yaml b/jjb/lf-python-job-groups.yaml index 388eaa3b..59066f93 100644 --- a/jjb/lf-python-job-groups.yaml +++ b/jjb/lf-python-job-groups.yaml @@ -8,6 +8,7 @@ jobs: - gerrit-python-xc-clm - gerrit-tox-verify + - gerrit-tox-merge - job-group: name: "{project-name}-github-python-jobs" @@ -18,3 +19,4 @@ jobs: - github-python-xc-clm - github-tox-verify + - github-tox-merge diff --git a/jjb/lf-python-jobs.yaml b/jjb/lf-python-jobs.yaml index 0f38b035..9cd6d798 100644 --- a/jjb/lf-python-jobs.yaml +++ b/jjb/lf-python-jobs.yaml @@ -391,11 +391,11 @@ included-regions: "{obj:github_included_regions}" ############## -# Tox Verify # +# Tox Common # ############## -- lf_tox_verify: &lf_tox_verify - name: lf-tox-verify +- lf_tox_common: &lf_tox_common + name: lf-tox-common ###################### # Default parameters # @@ -470,7 +470,7 @@ # Python projects typically use tox to run testing. name: "{project-name}-tox-verify-{stream}" id: gerrit-tox-verify - <<: *lf_tox_verify + <<: *lf_tox_common ###################### # Default parameters # @@ -522,7 +522,7 @@ # Python projects typically use tox to run testing. name: "{project-name}-tox-verify-{stream}" id: github-tox-verify - <<: *lf_tox_verify + <<: *lf_tox_common properties: - lf-infra-properties: @@ -551,3 +551,83 @@ white-list-target-branches: - "{branch}" included-regions: "{obj:github_included_regions}" + +- job-template: + # Run tox after merge of gerrit change set + name: "{project-name}-tox-merge-{stream}" + id: gerrit-tox-merge + <<: *lf_tox_common + + ###################### + # Default parameters # + ###################### + + gerrit_merge_triggers: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$' + + ##################### + # Job Configuration # + ##################### + + scm: + - lf-infra-gerrit-scm: + jenkins-ssh-credential: "{jenkins-ssh-credential}" + git-url: "{git-url}" + refspec: "$GERRIT_REFSPEC" + branch: "$GERRIT_BRANCH" + submodule-recursive: "{submodule-recursive}" + submodule-timeout: "{submodule-timeout}" + submodule-disable: "{submodule-disable}" + choosing-strategy: gerrit + + triggers: + - gerrit: + server-name: "{gerrit-server-name}" + trigger-on: "{obj:gerrit_merge_triggers}" + projects: + - project-compare-type: ANT + project-pattern: "{project}" + branches: + - branch-compare-type: ANT + branch-pattern: "**/{branch}" + file-paths: "{obj:gerrit_trigger_file_paths}" + +- job-template: + # Run tox after merge of github pull request + name: "{project-name}-tox-merge-{stream}" + id: github-tox-merge + <<: *lf_tox_common + + properties: + - lf-infra-properties: + build-days-to-keep: "{build-days-to-keep}" + - github: + url: "{github-url}/{github-org}/{project}" + + scm: + - lf-infra-github-scm: + url: "{git-clone-url}{github-org}/{project}" + refspec: "" + branch: "refs/heads/{branch}" + submodule-recursive: "{submodule-recursive}" + submodule-timeout: "{submodule-timeout}" + submodule-disable: "{submodule-disable}" + choosing-strategy: default + jenkins-ssh-credential: "{jenkins-ssh-credential}" + + triggers: + - github-pull-request: + trigger-phrase: "^remerge$" + only-trigger-phrase: true + status-context: "Tox Merge" + permit-all: true + github-hooks: true + org-list: + - "{github-org}" + white-list: "{obj:github_pr_whitelist}" + admin-list: "{obj:github_pr_admin_list}" + white-list-target-branches: + - "{branch}" + included-regions: "{obj:github_included_regions}" diff --git a/releasenotes/notes/add-python-tox-merge-template-c965c8b9ab644b20.yaml b/releasenotes/notes/add-python-tox-merge-template-c965c8b9ab644b20.yaml new file mode 100644 index 00000000..94c30f1d --- /dev/null +++ b/releasenotes/notes/add-python-tox-merge-template-c965c8b9ab644b20.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add python tox merge job templates for gerrit and github. + These templates are triggered by merge events to test + the Python code on the branch that received the merge. + Renamed tox-verify macro to tox-common. -- 2.16.6