Add python templates to run tox on merge
[releng/global-jjb.git] / jjb / lf-python-jobs.yaml
1 ---
2 ##########
3 # Macros #
4 ##########
5
6 - builder:
7     name: lf-infra-tox-install
8     builders:
9       - inject:
10           properties-content: "PYTHON_VERSION={python-version}"
11       - shell: !include-raw-escape: ../shell/tox-install.sh
12
13 - builder:
14     name: lf-infra-clm-python
15     builders:
16       - inject:
17           properties-content: "CLM_PROJECT_NAME={clm-project-name}"
18       - shell: !include-raw-escape:
19           - ../shell/nexus-iq-cli.sh
20
21 ####################
22 # COMMON FUNCTIONS #
23 ####################
24
25 - lf_python_common: &lf_python_common
26     name: lf-python-common
27
28     ######################
29     # Default parameters #
30     ######################
31
32     archive-artifacts: >
33       **/*.log
34
35     #####################
36     # Job Configuration #
37     #####################
38
39     project-type: freestyle
40     node: "{build-node}"
41
42     properties:
43       - lf-infra-properties:
44           build-days-to-keep: "{build-days-to-keep}"
45
46     parameters:
47       - lf-infra-parameters:
48           project: "{project}"
49           branch: "{branch}"
50           stream: "{stream}"
51
52     wrappers:
53       - lf-infra-wrappers:
54           build-timeout: "{build-timeout}"
55           jenkins-ssh-credential: "{jenkins-ssh-credential}"
56
57     publishers:
58       - lf-infra-publish
59
60 #################
61 # Python XC CLM #
62 #################
63
64 - lf_python_clm_xc: &lf_python_xc_clm
65     name: lf-python-xc-clm
66
67     ######################
68     # Default parameters #
69     ######################
70
71     branch: master
72     build-days-to-keep: 30 # 30 days for troubleshooting purposes
73     build-timeout: 60
74     disable-job: false
75     git-url: "$GIT_URL/$PROJECT"
76     github-url: "https://github.com"
77     java-version: openjdk8
78     nexus-iq-cli-version: 1.44.0-01
79     nexus-iq-namespace: "" # Recommend a trailing dash when set. Example: odl-
80     pre-build-script: "# pre-build script goes here"
81     stream: master
82     submodule-recursive: true
83     submodule-timeout: 10
84     submodule-disable: false
85
86     gerrit_trigger_file_paths:
87       - compare-type: ANT
88         pattern: ".*"
89
90     # github_included_regions MUST match gerrit_trigger_file_paths
91     github_included_regions:
92       - ".*"
93
94     #####################
95     # Job Configuration #
96     #####################
97
98     disabled: "{disable-job}"
99
100     parameters:
101       - lf-infra-parameters:
102           project: "{project}"
103           branch: "{branch}"
104           stream: "{stream}"
105       - string:
106           name: NEXUS_IQ_CLI_VERSION
107           default: "{nexus-iq-cli-version}"
108           description: Nexus IQ CLI package to download and use.
109
110     wrappers:
111       - credentials-binding:
112           - username-password-separated:
113               credential-id: nexus-iq-xc-clm
114               username: CLM_USER
115               password: CLM_PASSWORD
116     builders:
117       - lf-update-java-alternatives:
118           java-version: "{java-version}"
119       - shell: "{pre-build-script}"
120       - lf-infra-clm-python:
121           clm-project-name: "{nexus-iq-namespace}{project-name}"
122
123 - job-template:
124     name: "{project-name}-python-clm-{stream}"
125     id: gerrit-python-xc-clm
126     <<: *lf_python_common
127     # yamllint disable-line rule:key-duplicates
128     <<: *lf_python_xc_clm
129
130     ######################
131     # Default parameters #
132     ######################
133
134     gerrit_clm_triggers:
135       - comment-added-contains-event:
136           comment-contains-value: '^Patch Set\s+\d+:\s+run-clm\s*$'
137
138     #####################
139     # Job Configuration #
140     #####################
141
142     scm:
143       - lf-infra-gerrit-scm:
144           jenkins-ssh-credential: "{jenkins-ssh-credential}"
145           git-url: "{git-url}"
146           refspec: "$GERRIT_REFSPEC"
147           branch: "$GERRIT_BRANCH"
148           submodule-recursive: "{submodule-recursive}"
149           submodule-timeout: "{submodule-timeout}"
150           submodule-disable: "{submodule-disable}"
151           choosing-strategy: default
152
153     triggers:
154       # Build weekly on Saturdays
155       - timed: "H H * * 6"
156       - gerrit:
157           server-name: "{gerrit-server-name}"
158           trigger-on: "{obj:gerrit_clm_triggers}"
159           projects:
160             - project-compare-type: ANT
161               project-pattern: "{project}"
162               branches:
163                 - branch-compare-type: ANT
164                   branch-pattern: "**/{branch}"
165               file-paths: "{obj:gerrit_trigger_file_paths}"
166           skip-vote:
167             successful: true
168             failed: true
169             unstable: true
170             notbuilt: true
171
172 - job-template:
173     name: "{project-name}-python-clm-{stream}"
174     id: github-python-xc-clm
175     <<: *lf_python_common
176     # yamllint disable-line rule:key-duplicates
177     <<: *lf_python_xc_clm
178
179     properties:
180       - lf-infra-properties:
181           build-days-to-keep: "{build-days-to-keep}"
182       - github:
183           url: "{github-url}/{github-org}/{project}"
184
185     scm:
186       - lf-infra-github-scm:
187           url: "{git-clone-url}{github-org}/{project}"
188           refspec: ""
189           branch: "refs/heads/{branch}"
190           submodule-recursive: "{submodule-recursive}"
191           submodule-timeout: "{submodule-timeout}"
192           submodule-disable: "{submodule-disable}"
193           choosing-strategy: default
194           jenkins-ssh-credential: "{jenkins-ssh-credential}"
195
196     triggers:
197       # Build weekly on Saturdays
198       - timed: "H H * * 6"
199       - github-pull-request:
200           trigger-phrase: "^run-clm$"
201           only-trigger-phrase: false
202           status-context: "CLM"
203           permit-all: true
204           github-hooks: true
205           white-list-target-branches:
206             - "{branch}"
207           included-regions: "{obj:github_included_regions}"
208
209 ########################
210 # Python Sonar with Tox #
211 ########################
212
213 - lf_tox_sonar: &lf_tox_sonar
214     name: lf-tox_sonar
215
216     ######################
217     # Default parameters #
218     ######################
219
220     branch: master # Sonar should always be run on master branch
221     build-days-to-keep: 7
222     build-timeout: 60
223     cron: "H H * * *" # run daily
224     disable-job: false
225     git-url: "$GIT_URL/$PROJECT"
226     github-url: "https://github.com"
227     java-version: openjdk8
228     pre-build-script: "# pre-build script goes here"
229     python-version: python2
230     mvn-global-settings: global-settings
231     mvn-settings: "{mvn-settings}"
232     mvn-version: mvn35
233     sonar-mvn-goal: "sonar:sonar"
234     stream: master
235     submodule-recursive: true
236     submodule-timeout: 10
237     submodule-disable: false
238
239     gerrit_trigger_file_paths:
240       - compare-type: REG_EXP
241         pattern: ".*"
242
243     # github_included_regions MUST match gerrit_trigger_file_paths
244     github_included_regions:
245       - ".*"
246
247     #####################
248     # Job Configuration #
249     #####################
250
251     disabled: "{disable-job}"
252
253     parameters:
254       - lf-infra-parameters:
255           project: "{project}"
256           branch: "{branch}"
257           stream: "{stream}"
258       - string:
259           name: ARCHIVE_ARTIFACTS
260           default: "{archive-artifacts}"
261           description: Artifacts to archive to the logs server.
262       - string:
263           name: MVN
264           # Sets an env var for shell scripts to be able to call the dynamically
265           # installed maven without having to calculate the path themselves.
266           # yamllint disable-line rule:line-length
267           default: "/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn"
268           description: "Maven selector to be used by shell scripts"
269       - string:
270           name: SONAR_MAVEN_GOAL
271           default: "{sonar-mvn-goal}"
272           description: |
273             Maven goals to pass to the Sonar call. Typically sonar:sonar
274             however to use a specific version of the sonar-maven-plugin we
275             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
276
277     builders:
278       - lf-infra-pre-build
279       - lf-infra-tox-install:
280           python-version: "{python-version}"
281       - shell: "{pre-build-script}"
282       - shell: !include-raw-escape: ../shell/tox-run.sh
283       - lf-provide-maven-settings:
284           global-settings-file: "{mvn-global-settings}"
285           settings-file: "{mvn-settings}"
286       - lf-infra-tox-sonar:
287           java-version: "{java-version}"
288           mvn-settings: "{mvn-settings}"
289           mvn-version: "{mvn-version}"
290
291     publishers:
292       - lf-infra-publish
293
294 - builder:
295     name: lf-infra-tox-sonar
296     # Run a Sonar build with Maven
297     builders:
298       - lf-maven-install:
299           mvn-version: "{mvn-version}"
300       - lf-update-java-alternatives:
301           java-version: "{java-version}"
302       - inject:
303           # TODO: Switch this to the sonar wrapper when JJB 2.0 is available
304           properties-content: SONAR_HOST_URL=$SONAR_URL
305       - shell: !include-raw-escape:
306           - ../shell/common-variables.sh
307           - ../shell/maven-sonar.sh
308       - lf-provide-maven-settings-cleanup
309
310 - job-template:
311     name: "{project-name}-tox-sonar"
312     id: gerrit-tox-sonar
313     <<: *lf_python_common
314     # yamllint disable-line rule:key-duplicates
315     <<: *lf_tox_sonar
316
317     ######################
318     # Default parameters #
319     ######################
320
321     gerrit_sonar_triggers:
322       - comment-added-contains-event:
323           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
324
325     #####################
326     # Job Configuration #
327     #####################
328
329     scm:
330       - lf-infra-gerrit-scm:
331           jenkins-ssh-credential: "{jenkins-ssh-credential}"
332           git-url: "{git-url}"
333           refspec: $GERRIT_REFSPEC
334           branch: $GERRIT_BRANCH
335           submodule-recursive: "{submodule-recursive}"
336           submodule-timeout: "{submodule-timeout}"
337           submodule-disable: "{submodule-disable}"
338           choosing-strategy: default
339
340     triggers:
341       - timed: "{obj:cron}"
342       - gerrit:
343           server-name: "{gerrit-server-name}"
344           trigger-on: "{obj:gerrit_sonar_triggers}"
345           projects:
346             - project-compare-type: "ANT"
347               project-pattern: "{project}"
348               branches:
349                 - branch-compare-type: "ANT"
350                   branch-pattern: "**/{branch}"
351               file-paths: "{obj:gerrit_trigger_file_paths}"
352           skip-vote:
353             successful: true
354             failed: true
355             unstable: true
356             notbuilt: true
357
358 - job-template:
359     name: "{project-name}-tox-sonar"
360     id: github-tox-sonar
361     <<: *lf_python_common
362     # yamllint disable-line rule:key-duplicates
363     <<: *lf_tox_sonar
364
365     properties:
366       - lf-infra-properties:
367           build-days-to-keep: "{build-days-to-keep}"
368       - github:
369           url: "{github-url}/{github-org}/{project}"
370
371     scm:
372       - lf-infra-github-scm:
373           url: "{git-clone-url}{github-org}/{project}"
374           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
375           branch: "$sha1"
376           submodule-recursive: "{submodule-recursive}"
377           submodule-timeout: "{submodule-timeout}"
378           submodule-disable: "{submodule-disable}"
379           choosing-strategy: default
380           jenkins-ssh-credential: "{jenkins-ssh-credential}"
381
382     triggers:
383       - github-pull-request:
384           trigger-phrase: "^run-sonar$"
385           only-trigger-phrase: false
386           status-context: "Python Sonar"
387           permit-all: true
388           github-hooks: true
389           white-list-target-branches:
390             - "{branch}"
391           included-regions: "{obj:github_included_regions}"
392
393 ##############
394 # Tox Common #
395 ##############
396
397 - lf_tox_common: &lf_tox_common
398     name: lf-tox-common
399
400     ######################
401     # Default parameters #
402     ######################
403
404     branch: master
405     build-days-to-keep: 7
406     build-timeout: 15
407     disable-job: false
408     git-url: "$GIT_URL/$GERRIT_PROJECT"
409     github-url: "https://github.com"
410     parallel: true
411     pre-build-script: "# pre-build script goes here"
412     python-version: python2
413     stream: master
414     submodule-recursive: true
415     submodule-timeout: 10
416     submodule-disable: false
417     tox-dir: ""
418     tox-envs: ""
419
420     gerrit_trigger_file_paths:
421       - compare-type: REG_EXP
422         pattern: ".*"
423
424     # github_included_regions MUST match gerrit_trigger_file_paths
425     github_included_regions:
426       - ".*"
427
428     #####################
429     # Job Configuration #
430     #####################
431
432     project-type: freestyle
433     node: "{build-node}"
434     concurrent: true
435     disabled: "{disable-job}"
436
437     properties:
438       - lf-infra-properties:
439           build-days-to-keep: "{build-days-to-keep}"
440
441     parameters:
442       - lf-infra-parameters:
443           project: "{project}"
444           branch: "{branch}"
445           stream: "{stream}"
446       - lf-infra-tox-parameters:
447           tox-dir: "{tox-dir}"
448           tox-envs: "{tox-envs}"
449       - bool:
450           name: PARALLEL
451           default: "{parallel}"
452           description: Tox test type used to configure serial or parallel testing.
453
454     wrappers:
455       - lf-infra-wrappers:
456           build-timeout: "{build-timeout}"
457           jenkins-ssh-credential: "{jenkins-ssh-credential}"
458
459     builders:
460       - lf-infra-pre-build
461       - lf-infra-tox-install:
462           python-version: "{python-version}"
463       - shell: "{pre-build-script}"
464       - shell: !include-raw-escape: ../shell/tox-run.sh
465
466     publishers:
467       - lf-infra-publish
468
469 - job-template:
470     # Python projects typically use tox to run testing.
471     name: "{project-name}-tox-verify-{stream}"
472     id: gerrit-tox-verify
473     <<: *lf_tox_common
474
475     ######################
476     # Default parameters #
477     ######################
478
479     gerrit-skip-vote: false
480     gerrit_verify_triggers:
481       - patchset-created-event:
482           exclude-drafts: true
483           exclude-trivial-rebase: false
484           exclude-no-code-change: false
485       - draft-published-event
486       - comment-added-contains-event:
487           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
488
489     #####################
490     # Job Configuration #
491     #####################
492
493     scm:
494       - lf-infra-gerrit-scm:
495           jenkins-ssh-credential: "{jenkins-ssh-credential}"
496           git-url: "{git-url}"
497           refspec: "$GERRIT_REFSPEC"
498           branch: "$GERRIT_BRANCH"
499           submodule-recursive: "{submodule-recursive}"
500           submodule-timeout: "{submodule-timeout}"
501           submodule-disable: "{submodule-disable}"
502           choosing-strategy: gerrit
503
504     triggers:
505       - gerrit:
506           server-name: "{gerrit-server-name}"
507           trigger-on: "{obj:gerrit_verify_triggers}"
508           projects:
509             - project-compare-type: ANT
510               project-pattern: "{project}"
511               branches:
512                 - branch-compare-type: ANT
513                   branch-pattern: "**/{branch}"
514               file-paths: "{obj:gerrit_trigger_file_paths}"
515           skip-vote:
516             successful: "{gerrit-skip-vote}"
517             failed: "{gerrit-skip-vote}"
518             unstable: "{gerrit-skip-vote}"
519             notbuilt: "{gerrit-skip-vote}"
520
521 - job-template:
522     # Python projects typically use tox to run testing.
523     name: "{project-name}-tox-verify-{stream}"
524     id: github-tox-verify
525     <<: *lf_tox_common
526
527     properties:
528       - lf-infra-properties:
529           build-days-to-keep: "{build-days-to-keep}"
530       - github:
531           url: "{github-url}/{github-org}/{project}"
532
533     scm:
534       - lf-infra-github-scm:
535           url: "{git-clone-url}{github-org}/{project}"
536           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
537           branch: "$sha1"
538           submodule-recursive: "{submodule-recursive}"
539           submodule-timeout: "{submodule-timeout}"
540           submodule-disable: "{submodule-disable}"
541           choosing-strategy: default
542           jenkins-ssh-credential: "{jenkins-ssh-credential}"
543
544     triggers:
545       - github-pull-request:
546           trigger-phrase: "^(recheck|reverify)$"
547           only-trigger-phrase: false
548           status-context: "Tox Verify"
549           permit-all: true
550           github-hooks: true
551           white-list-target-branches:
552             - "{branch}"
553           included-regions: "{obj:github_included_regions}"
554
555 - job-template:
556     # Run tox after merge of gerrit change set
557     name: "{project-name}-tox-merge-{stream}"
558     id: gerrit-tox-merge
559     <<: *lf_tox_common
560
561     ######################
562     # Default parameters #
563     ######################
564
565     gerrit_merge_triggers:
566       - change-merged-event
567       - comment-added-contains-event:
568           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
569
570     #####################
571     # Job Configuration #
572     #####################
573
574     scm:
575       - lf-infra-gerrit-scm:
576           jenkins-ssh-credential: "{jenkins-ssh-credential}"
577           git-url: "{git-url}"
578           refspec: "$GERRIT_REFSPEC"
579           branch: "$GERRIT_BRANCH"
580           submodule-recursive: "{submodule-recursive}"
581           submodule-timeout: "{submodule-timeout}"
582           submodule-disable: "{submodule-disable}"
583           choosing-strategy: gerrit
584
585     triggers:
586       - gerrit:
587           server-name: "{gerrit-server-name}"
588           trigger-on: "{obj:gerrit_merge_triggers}"
589           projects:
590             - project-compare-type: ANT
591               project-pattern: "{project}"
592               branches:
593                 - branch-compare-type: ANT
594                   branch-pattern: "**/{branch}"
595               file-paths: "{obj:gerrit_trigger_file_paths}"
596
597 - job-template:
598     # Run tox after merge of github pull request
599     name: "{project-name}-tox-merge-{stream}"
600     id: github-tox-merge
601     <<: *lf_tox_common
602
603     properties:
604       - lf-infra-properties:
605           build-days-to-keep: "{build-days-to-keep}"
606       - github:
607           url: "{github-url}/{github-org}/{project}"
608
609     scm:
610       - lf-infra-github-scm:
611           url: "{git-clone-url}{github-org}/{project}"
612           refspec: ""
613           branch: "refs/heads/{branch}"
614           submodule-recursive: "{submodule-recursive}"
615           submodule-timeout: "{submodule-timeout}"
616           submodule-disable: "{submodule-disable}"
617           choosing-strategy: default
618           jenkins-ssh-credential: "{jenkins-ssh-credential}"
619
620     triggers:
621       - github-pull-request:
622           trigger-phrase: "^remerge$"
623           only-trigger-phrase: true
624           status-context: "Tox Merge"
625           permit-all: true
626           github-hooks: true
627           org-list:
628             - "{github-org}"
629           white-list: "{obj:github_pr_whitelist}"
630           admin-list: "{obj:github_pr_admin_list}"
631           white-list-target-branches:
632             - "{branch}"
633           included-regions: "{obj:github_included_regions}"