blob: 82257a35e4f38011c059858e2a8473d08ba9c905 [file] [log] [blame]
Zack Williamscc58c672018-10-18 19:51:06 -07001---
2# python module unit test
3
4- job-template:
5 id: 'python-unit-test'
6 name: 'verify_{project}_unit-test'
7
8 description: |
Zack Williams42200aa2019-04-12 13:27:44 -07009 Created by {id} job-template from ci-management/jjb/python-unit.yaml<br/>
10 Unit tests for Python (or Go w/Makefile) projects
Zack Williamscc58c672018-10-18 19:51:06 -070011
12 triggers:
13 - cord-infra-gerrit-trigger-patchset:
14 gerrit-server-name: '{gerrit-server-name}'
15 project-regexp: '^{project}$'
16 branch-regexp: '{branch-regexp}'
17 dependency-jobs: '{dependency-jobs}'
18 file-include-regexp: '{all-files-regexp}'
19
20 properties:
21 - cord-infra-properties:
22 build-days-to-keep: '{build-days-to-keep}'
23 artifact-num-to-keep: '{artifact-num-to-keep}'
24
25 wrappers:
26 - lf-infra-wrappers:
Zack Williamsdbdd2362019-03-11 11:15:31 -070027 build-timeout: '{build-timeout}'
Zack Williamscc58c672018-10-18 19:51:06 -070028 jenkins-ssh-credential: '{jenkins-ssh-credential}'
29
30 scm:
31 - lf-infra-gerrit-scm:
32 git-url: '$GIT_URL/$GERRIT_PROJECT'
33 refspec: '$GERRIT_REFSPEC'
34 branch: '$GERRIT_BRANCH'
Zack Williamsccc14742020-01-22 13:15:59 -070035 submodule-disable: '{submodule-disable}'
Zack Williamscc58c672018-10-18 19:51:06 -070036 submodule-recursive: 'false'
Zack Williamsccc14742020-01-22 13:15:59 -070037 submodule-timeout: '{submodule-timeout}'
Zack Williamscc58c672018-10-18 19:51:06 -070038 choosing-strategy: gerrit
39 jenkins-ssh-credential: '{jenkins-ssh-credential}'
40
41 node: '{build-node}'
42 project-type: freestyle
43 concurrent: true
44
45 builders:
46 - shell: |
47 #!/usr/bin/env bash
48 set -eux -o pipefail
Zack Williams06590b62018-10-18 22:16:27 -070049
Zack Williams42200aa2019-04-12 13:27:44 -070050 # setup for go-based testing
51 mkdir -p ~/go/src
52 export GOPATH=~/go
Zack Williamsc9abcdc2019-05-09 21:23:38 -070053 export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:~/go/bin
Zack Williams42200aa2019-04-12 13:27:44 -070054
Zack Williams9d935972019-03-01 14:27:46 -070055 if [ -f 'Makefile' ]; then
56 echo "Makefile found, running 'make test'"
57 make test
58
59 elif [ -f 'tox.ini' ]; then
Zack Williamsa31016a2018-10-22 13:00:04 -070060 echo "tox.ini found, running tox for Python2/3 unit tests"
61 tox
Zack Williams9d935972019-03-01 14:27:46 -070062
Zack Williamsa31016a2018-10-22 13:00:04 -070063 else
Zack Williams9d935972019-03-01 14:27:46 -070064 echo "Makefile or tox.ini not found, running nose2 unit tests"
Zack Williams06590b62018-10-18 22:16:27 -070065
Zack Williamsa31016a2018-10-22 13:00:04 -070066 if [ -f 'requirements.txt' ]; then
67 echo "requirements.txt found, installing locally with pip"
68 pip install -r requirements.txt
69 fi
70
71 echo "Performing nose2 tests"
72 nose2 --verbose --coverage-report xml --coverage-report term --junit-xml
73 fi
Zack Williamscc58c672018-10-18 19:51:06 -070074
75 publishers:
76 - junit:
Zack Williamsc8801082019-02-13 13:49:17 -070077 results: "**/*junit.xml,**/*results.xml,**/*report.xml"
Zack Williams0cb78462019-04-09 18:13:28 -070078 allow-empty-results: '{junit-allow-empty-results}'
Zack Williamscc58c672018-10-18 19:51:06 -070079 - cobertura:
Zack Williamsc8801082019-02-13 13:49:17 -070080 report-file: "**/*coverage.xml"
Zack Williamscc58c672018-10-18 19:51:06 -070081 targets:
82 - files:
83 healthy: 80
84 unhealthy: 0
85 failing: 0
86 - method:
87 healthy: 50
88 unhealthy: 0
89 failing: 0
Joey Armstrongaf679da2023-01-31 14:22:41 -050090
91# [EOF]