Add python templates to run tox on merge 21/16621/6
authorLott, Christopher (cl778h) <cl778h@att.com>
Tue, 20 Aug 2019 15:46:31 +0000 (11:46 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Wed, 11 Sep 2019 15:13:37 +0000 (11:13 -0400)
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) <cl778h@att.com>
docs/jjb/lf-python-jobs.rst
jjb/lf-python-job-groups.yaml
jjb/lf-python-jobs.yaml
releasenotes/notes/add-python-tox-merge-template-c965c8b9ab644b20.yaml [new file with mode: 0644]

index 15c5b08..8f940e8 100644 (file)
@@ -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
index 388eaa3..59066f9 100644 (file)
@@ -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
index 0f38b03..9cd6d79 100644 (file)
           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 #
     # 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 #
     # 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:
           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 (file)
index 0000000..94c30f1
--- /dev/null
@@ -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.