Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 1 | --- |
| 2 | # python module unit test |
| 3 | |
| 4 | - job-template: |
| 5 | id: 'python-unit-test' |
| 6 | name: 'verify_{project}_unit-test' |
| 7 | |
| 8 | description: | |
Zack Williams | 42200aa | 2019-04-12 13:27:44 -0700 | [diff] [blame] | 9 | Created by {id} job-template from ci-management/jjb/python-unit.yaml<br/> |
| 10 | Unit tests for Python (or Go w/Makefile) projects |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 11 | |
| 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 Williams | dbdd236 | 2019-03-11 11:15:31 -0700 | [diff] [blame] | 27 | build-timeout: '{build-timeout}' |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 28 | 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 Williams | 06590b6 | 2018-10-18 22:16:27 -0700 | [diff] [blame] | 47 | |
Zack Williams | 42200aa | 2019-04-12 13:27:44 -0700 | [diff] [blame] | 48 | # setup for go-based testing |
| 49 | mkdir -p ~/go/src |
| 50 | export GOPATH=~/go |
Zack Williams | c9abcdc | 2019-05-09 21:23:38 -0700 | [diff] [blame] | 51 | export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:~/go/bin |
Zack Williams | 42200aa | 2019-04-12 13:27:44 -0700 | [diff] [blame] | 52 | |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 53 | if [ -f 'Makefile' ]; then |
| 54 | echo "Makefile found, running 'make test'" |
| 55 | make test |
| 56 | |
| 57 | elif [ -f 'tox.ini' ]; then |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 58 | echo "tox.ini found, running tox for Python2/3 unit tests" |
| 59 | tox |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 60 | |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 61 | else |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 62 | echo "Makefile or tox.ini not found, running nose2 unit tests" |
Zack Williams | 06590b6 | 2018-10-18 22:16:27 -0700 | [diff] [blame] | 63 | |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 64 | 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 Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 72 | |
| 73 | publishers: |
| 74 | - junit: |
Zack Williams | c880108 | 2019-02-13 13:49:17 -0700 | [diff] [blame] | 75 | results: "**/*junit.xml,**/*results.xml,**/*report.xml" |
Zack Williams | 0cb7846 | 2019-04-09 18:13:28 -0700 | [diff] [blame] | 76 | allow-empty-results: '{junit-allow-empty-results}' |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 77 | - cobertura: |
Zack Williams | c880108 | 2019-02-13 13:49:17 -0700 | [diff] [blame] | 78 | report-file: "**/*coverage.xml" |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 79 | targets: |
| 80 | - files: |
| 81 | healthy: 80 |
| 82 | unhealthy: 0 |
| 83 | failing: 0 |
| 84 | - method: |
| 85 | healthy: 50 |
| 86 | unhealthy: 0 |
| 87 | failing: 0 |