blob: b44f83ec18a3aa5304089b3b0f28988f685f7d95 [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'
35 submodule-recursive: 'false'
36 choosing-strategy: gerrit
37 jenkins-ssh-credential: '{jenkins-ssh-credential}'
38
39 node: '{build-node}'
40 project-type: freestyle
41 concurrent: true
42
43 builders:
44 - shell: |
45 #!/usr/bin/env bash
46 set -eux -o pipefail
Zack Williams06590b62018-10-18 22:16:27 -070047
Zack Williams42200aa2019-04-12 13:27:44 -070048 # setup for go-based testing
49 mkdir -p ~/go/src
50 export GOPATH=~/go
Zack Williamsc9abcdc2019-05-09 21:23:38 -070051 export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:~/go/bin
Zack Williams42200aa2019-04-12 13:27:44 -070052
Zack Williams9d935972019-03-01 14:27:46 -070053 if [ -f 'Makefile' ]; then
54 echo "Makefile found, running 'make test'"
55 make test
56
57 elif [ -f 'tox.ini' ]; then
Zack Williamsa31016a2018-10-22 13:00:04 -070058 echo "tox.ini found, running tox for Python2/3 unit tests"
59 tox
Zack Williams9d935972019-03-01 14:27:46 -070060
Zack Williamsa31016a2018-10-22 13:00:04 -070061 else
Zack Williams9d935972019-03-01 14:27:46 -070062 echo "Makefile or tox.ini not found, running nose2 unit tests"
Zack Williams06590b62018-10-18 22:16:27 -070063
Zack Williamsa31016a2018-10-22 13:00:04 -070064 if [ -f 'requirements.txt' ]; then
65 echo "requirements.txt found, installing locally with pip"
66 pip install -r requirements.txt
67 fi
68
69 echo "Performing nose2 tests"
70 nose2 --verbose --coverage-report xml --coverage-report term --junit-xml
71 fi
Zack Williamscc58c672018-10-18 19:51:06 -070072
73 publishers:
74 - junit:
Zack Williamsc8801082019-02-13 13:49:17 -070075 results: "**/*junit.xml,**/*results.xml,**/*report.xml"
Zack Williams0cb78462019-04-09 18:13:28 -070076 allow-empty-results: '{junit-allow-empty-results}'
Zack Williamscc58c672018-10-18 19:51:06 -070077 - cobertura:
Zack Williamsc8801082019-02-13 13:49:17 -070078 report-file: "**/*coverage.xml"
Zack Williamscc58c672018-10-18 19:51:06 -070079 targets:
80 - files:
81 healthy: 80
82 unhealthy: 0
83 failing: 0
84 - method:
85 healthy: 50
86 unhealthy: 0
87 failing: 0