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' |
Zack Williams | ccc1474 | 2020-01-22 13:15:59 -0700 | [diff] [blame] | 35 | submodule-disable: '{submodule-disable}' |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 36 | submodule-recursive: 'false' |
Zack Williams | ccc1474 | 2020-01-22 13:15:59 -0700 | [diff] [blame] | 37 | submodule-timeout: '{submodule-timeout}' |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 38 | 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 Williams | 06590b6 | 2018-10-18 22:16:27 -0700 | [diff] [blame] | 49 | |
Zack Williams | 42200aa | 2019-04-12 13:27:44 -0700 | [diff] [blame] | 50 | # setup for go-based testing |
| 51 | mkdir -p ~/go/src |
| 52 | export GOPATH=~/go |
Zack Williams | c9abcdc | 2019-05-09 21:23:38 -0700 | [diff] [blame] | 53 | 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] | 54 | |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 55 | if [ -f 'Makefile' ]; then |
| 56 | echo "Makefile found, running 'make test'" |
| 57 | make test |
| 58 | |
| 59 | elif [ -f 'tox.ini' ]; then |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 60 | echo "tox.ini found, running tox for Python2/3 unit tests" |
| 61 | tox |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 62 | |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 63 | else |
Zack Williams | 9d93597 | 2019-03-01 14:27:46 -0700 | [diff] [blame] | 64 | echo "Makefile or tox.ini not found, running nose2 unit tests" |
Zack Williams | 06590b6 | 2018-10-18 22:16:27 -0700 | [diff] [blame] | 65 | |
Zack Williams | a31016a | 2018-10-22 13:00:04 -0700 | [diff] [blame] | 66 | 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 Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 74 | |
| 75 | publishers: |
| 76 | - junit: |
Zack Williams | c880108 | 2019-02-13 13:49:17 -0700 | [diff] [blame] | 77 | results: "**/*junit.xml,**/*results.xml,**/*report.xml" |
Zack Williams | 0cb7846 | 2019-04-09 18:13:28 -0700 | [diff] [blame] | 78 | allow-empty-results: '{junit-allow-empty-results}' |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 79 | - cobertura: |
Zack Williams | c880108 | 2019-02-13 13:49:17 -0700 | [diff] [blame] | 80 | report-file: "**/*coverage.xml" |
Zack Williams | cc58c67 | 2018-10-18 19:51:06 -0700 | [diff] [blame] | 81 | targets: |
| 82 | - files: |
| 83 | healthy: 80 |
| 84 | unhealthy: 0 |
| 85 | failing: 0 |
| 86 | - method: |
| 87 | healthy: 50 |
| 88 | unhealthy: 0 |
| 89 | failing: 0 |