0003-jenkins-adopt-authentic-way-of-doing-tox.ini-and-Jen.patch
Jenkinsfile | ||
---|---|---|
2 | 2 | |
3 | 3 |
pipeline { |
4 | 4 |
agent any |
5 |
options { disableConcurrentBuilds() } |
|
6 |
environment { |
|
7 |
TMPDIR = "/tmp/$BUILD_TAG" |
|
8 |
} |
|
5 | 9 |
stages { |
6 | 10 |
stage('Unit Tests') { |
7 | 11 |
steps { |
8 |
sh 'tox -rv' |
|
12 |
sh "mkdir ${env.TMPDIR}" |
|
13 |
sh """ |
|
14 |
virtualenv -p python3 ${env.TMPDIR}/venv/ |
|
15 |
${env.TMPDIR}/venv/bin/pip install tox "virtualenv<=20.0.5" "importlib-resources<=1.0.2" |
|
16 |
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -r""" |
|
9 | 17 |
} |
10 | 18 |
post { |
11 | 19 |
always { |
12 | 20 |
script { |
13 | 21 |
utils = new Utils() |
14 | 22 |
utils.publish_coverage('coverage.xml') |
15 |
utils.publish_coverage_native() |
|
23 |
utils.publish_coverage_native('index.html') |
|
24 |
utils.publish_pylint('pylint.out') |
|
16 | 25 |
} |
17 |
junit 'junit.xml'
|
|
26 |
mergeJunitResults()
|
|
18 | 27 |
} |
19 | 28 |
} |
20 | 29 |
} |
... | ... | |
36 | 45 |
} |
37 | 46 |
} |
38 | 47 |
success { |
48 |
sh "rm -rf ${env.TMPDIR}" |
|
39 | 49 |
cleanWs() |
40 | 50 |
} |
41 | 51 |
} |
pylint.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 | ||
3 |
set -e |
|
4 | ||
5 |
pylint -f parseable "$@" > pylint.out || /bin/true |
tox.ini | ||
---|---|---|
5 | 5 | |
6 | 6 |
[tox] |
7 | 7 |
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs-olap/{env:BRANCH_NAME:} |
8 |
envlist = py3-coverage |
|
8 |
envlist = py3 |
|
9 | ||
10 |
[tox:jenkins] |
|
11 |
envlist = |
|
12 |
pylint |
|
13 |
py3 |
|
9 | 14 | |
10 | 15 |
[testenv] |
11 | 16 |
usedevelop = true |
12 | 17 |
setenv = |
13 |
coverage: COVERAGE=--junit-xml=junit.xml --cov=wcs_olap --cov-report xml --cov-report html |
|
14 |
WCS_MANAGE=wcs/manage.py |
|
18 |
COVERAGE={tty::--cov=src --cov-branch --cov-append --cov-report xml --cov-report html} |
|
19 |
JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml} |
|
20 |
WCS_MANAGE=wcs/manage.py |
|
21 |
deps = |
|
22 |
pytest |
|
23 |
pytest-cov |
|
24 |
pytest-random |
|
25 |
httmock |
|
26 | ||
27 |
# w.c.s. dependencies, as it cannot b installed through pip |
|
28 |
quixote>=3 |
|
29 |
psycopg2-binary |
|
30 |
vobject |
|
31 |
pyproj |
|
32 |
django-ratelimit<3 |
|
33 |
gadjo |
|
34 |
django>=1.11,<1.12 |
|
35 |
passenv= |
|
36 |
BRANCH_NAME |
|
37 |
# support for pg_virtualenv |
|
38 |
PGPORT |
|
39 |
PGHOST |
|
40 |
PGUSER |
|
41 |
PGPASSWORD |
|
42 |
commands = |
|
43 |
./get_wcs.sh |
|
44 |
py.test --sw {env:JUNIT:} {env:COVERAGE:} {posargs:--random-group tests} |
|
45 | ||
46 |
[testenv:pylint] |
|
47 |
basepython = python3 |
|
15 | 48 |
deps = |
16 |
coverage |
|
17 |
pytest |
|
18 |
pytest-cov |
|
19 |
pytest-random |
|
20 |
quixote>=3 |
|
21 |
psycopg2-binary |
|
22 |
vobject |
|
23 |
pyproj |
|
24 |
django-ratelimit<3 |
|
25 |
gadjo |
|
26 |
httmock |
|
27 |
django>=1.11,<1.12 |
|
49 |
pylint |
|
28 | 50 |
commands = |
29 |
./get_wcs.sh |
|
30 |
py.test {env:COVERAGE:} {posargs:--random-group tests} |
|
51 |
/bin/bash -c "./pylint.sh wcs_olap" |
|
31 | 52 | |
32 | 53 |
[pytest] |
33 | 54 |
junit_family=xunit2 |
34 |
- |