Skip to content

Commit 9bb5e6a

Browse files
author
khadijeh.alibabaei
committed
update jenkins
1 parent ab5ddc4 commit 9bb5e6a

File tree

5 files changed

+116
-156
lines changed

5 files changed

+116
-156
lines changed

.sqa/config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# .sqa/config.yml - jenkins-pipeline-library configuration file
2+
sqa_criteria:
3+
qc_style:
4+
repos:
5+
posenet-tf:
6+
container: testing
7+
tox:
8+
tox_file: tox.ini
9+
testenv:
10+
- qc.sty
11+
qc_coverage:
12+
repos:
13+
posenet-tf:
14+
container: testing
15+
tox:
16+
tox_file: tox.ini
17+
testenv:
18+
- qc.cov
19+
qc_security:
20+
repos:
21+
posenet-tf:
22+
container: testing
23+
tox:
24+
tox_file: tox.ini
25+
testenv:
26+
- qc.sec
27+
28+
environment:
29+
GIT_COMMITTER_NAME: "Lara Lloret (CSIC)"
30+
GIT_COMMITTER_EMAIL: "lloret@ifca.unican.es"
31+
LANG: C.UTF-8
32+
33+
timeout: 600

.sqa/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "3.6"
2+
3+
services:
4+
testing:
5+
container_name: testing
6+
working_dir: /srv
7+
build:
8+
context: ./.sqa
9+
volumes:
10+
- type: bind
11+
source: ./
12+
target: /srv

.sqa/dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Docker image for CI testing of the DEEPaaS API
2+
# Note there is probably no gpu in the CI server
3+
ARG tag=1.14.0-py3
4+
FROM tensorflow/tensorflow:${tag}
5+
RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel
6+
RUN pip3 install --no-cache-dir tox
7+
CMD ["sleep", "infinity"]

Jenkinsfile

Lines changed: 37 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,54 @@
1-
#!/usr/bin/groovy
1+
@Library(['github.com/indigo-dc/jenkins-pipeline-library@release/2.1.1']) _
22

3-
@Library(['github.com/indigo-dc/jenkins-pipeline-library@release/1.4.0']) _
4-
5-
def job_result_url = ''
3+
def projectConfig
64

75
pipeline {
8-
agent {
9-
label 'python3.6'
10-
}
11-
12-
environment {
13-
author_name = "Ignacio Heredia (CSIC)"
14-
author_email = "iheredia@ifca.unican.es"
15-
app_name = "image-classification-tf-dicom"
16-
job_location = "Pipeline-as-code/DEEP-OC-org/DEEP-OC-image-classification-tf-dicom/${env.BRANCH_NAME}"
17-
}
6+
agent any
187

198
stages {
20-
stage('Code fetching') {
21-
steps {
22-
checkout scm
23-
}
24-
}
25-
26-
stage('Style analysis') {
9+
stage('Application testing') {
2710
steps {
28-
ToxEnvRun('pep8')
29-
}
30-
post {
31-
always {
32-
WarningsReport('Pep8')
33-
}
34-
}
35-
}
36-
37-
stage('Security scanner') {
38-
steps {
39-
ToxEnvRun('bandit-report')
4011
script {
41-
if (currentBuild.result == 'FAILURE') {
42-
currentBuild.result = 'UNSTABLE'
43-
}
44-
}
45-
}
46-
post {
47-
always {
48-
HTMLReport("/tmp/bandit", 'index.html', 'Bandit report')
49-
}
50-
}
51-
}
52-
53-
stage("Re-build Docker image") {
54-
when {
55-
anyOf {
56-
branch 'master'
57-
branch 'test'
58-
buildingTag()
59-
}
60-
}
61-
steps {
62-
script {
63-
def job_result = JenkinsBuildJob("${env.job_location}")
64-
job_result_url = job_result.absoluteUrl
12+
projectConfig = pipelineConfig()
13+
buildStages(projectConfig)
6514
}
6615
}
6716
}
6817
}
69-
7018
post {
71-
failure {
19+
// publish results and clean-up
20+
always {
7221
script {
73-
currentBuild.result = 'FAILURE'
74-
}
75-
}
76-
77-
always {
78-
script { //stage("Email notification")
79-
def build_status = currentBuild.result
80-
build_status = build_status ?: 'SUCCESS'
81-
def subject = """
82-
New ${app_name} build in Jenkins@DEEP:\
83-
${build_status}: Job '${env.JOB_NAME}\
84-
[${env.BUILD_NUMBER}]'"""
85-
86-
def body = """
87-
Dear ${author_name},\n\n
88-
A new build of '${app_name} DEEP application is available in Jenkins at:\n\n
89-
* ${env.BUILD_URL}\n\n
90-
terminated with '${build_status}' status.\n\n
91-
Check console output at:\n\n
92-
* ${env.BUILD_URL}/console\n\n
93-
and resultant Docker image rebuilding job at (may be empty in case of FAILURE):\n\n
94-
* ${job_result_url}\n\n
95-
DEEP Jenkins CI service"""
96-
97-
EmailSend(subject, body, "${author_email}")
22+
if (fileExists("flake8.log")) {
23+
// file locations are defined in tox.ini
24+
// publish results of the style analysis
25+
recordIssues(tools: [flake8(pattern: 'flake8.log',
26+
name: 'PEP8 report',
27+
id: "flake8_pylint")])
28+
}
29+
if (fileExists("htmlcov/index.html")) {
30+
// publish results of the coverage test
31+
publishHTML([allowMissing: false,
32+
alwaysLinkToLastBuild: false,
33+
keepAll: true,
34+
reportDir: "htmlcov",
35+
reportFiles: 'index.html',
36+
reportName: 'Coverage report',
37+
reportTitles: ''])
38+
}
39+
if (fileExists("bandit/index.html")) {
40+
// publish results of the security check
41+
publishHTML([allowMissing: false,
42+
alwaysLinkToLastBuild: false,
43+
keepAll: true,
44+
reportDir: "bandit",
45+
reportFiles: 'index.html',
46+
reportName: 'Bandit report',
47+
reportTitles: ''])
48+
}
9849
}
50+
// Clean after build
51+
cleanWs()
9952
}
10053
}
10154
}

tox.ini

Lines changed: 27 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,41 @@
1+
12
[tox]
2-
minversion = 1.6
3-
envlist = py{35,36,27},pep8
4-
skipsdist = True
3+
minversion = 2.5.0
4+
isolated_build = True
5+
envlist = qc.sty,qc.cov,qc.sec,py37,py38,py36
56

67
[testenv]
78
usedevelop = True
8-
basepython = python3
9-
whitelist_externals =
10-
find
119
install_command = pip install -U {opts} {packages}
10+
# envdir = {toxworkdir}/shared # Comment out or remove this line
11+
commands = pytest --numprocesses=auto {posargs}
12+
allowlist_externals =
13+
mkdir
14+
passenv =
15+
RCLONERCLONE_CONFIG_RSHARE_VENDOR
16+
RCLONE_CONFIG
17+
RCLONE_CONFIG_RSHARE_PASS
18+
RCLONE_CONFIG_RSHARE_URL
19+
RCLONE_CONFIG_RSHARE_TYPE
20+
RCLONE_CONFIG_RSHARE_USER
1221
setenv =
13-
VIRTUAL_ENV={envdir}
1422
LC_ALL=C.UTF-8
1523
OS_STDOUT_CAPTURE=1
1624
OS_STDERR_CAPTURE=1
17-
OS_TEST_TIMEOUT=160
18-
deps = -r{toxinidir}/requirements.txt
19-
-r{toxinidir}/test-requirements.txt
20-
commands =
21-
find . -type f -name "*.pyc" -delete
25+
OS_TEST_TIMEOUT=240
26+
deps =
27+
-r{toxinidir}/requirements-test.txt
28+
-r{toxinidir}/test-requirements.txt
2229

23-
[testenv:cover]
24-
# TODO(stephenfin): Remove the PYTHON hack below in favour of a [coverage]
25-
# section once we rely on coverage 4.3+
26-
#
27-
# https://bitbucket.org/ned/coveragepy/issues/519/
28-
envdir = {toxworkdir}/shared
29-
setenv =
30-
{[testenv]setenv}
31-
PYTHON=coverage run --source image-classification-tf-dicom --parallel-mode
30+
[testenv:qc.sty]
3231
commands =
33-
{[testenv]commands}
34-
coverage erase
35-
stestr run {posargs}
36-
coverage combine
37-
coverage html -d cover
38-
coverage xml -o cover/coverage.xml
39-
coverage report
40-
41-
[testenv:py27]
42-
# TODO(efried): Remove this once https://github.com/tox-dev/tox/issues/425 is fixed.
43-
basepython = python2.7
32+
- flake8 --statistics --tee --output-file={toxinidir}/flake8.log \
33+
--format=pylint image-classification-tf-dicom
34+
[testenv:qc.cov]
4435
commands =
45-
{[testenv]commands}
46-
stestr run {posargs}
36+
pytest --cov=image-classification-tf-dicom --cov-report=html:{toxinidir}/htmlcov --cov-report=term-missing tests
4737

48-
[testenv:py35]
49-
# TODO(efried): Remove this once https://github.com/tox-dev/tox/issues/425 is fixed.
50-
basepython = python3.5
38+
[testenv:qc.sec]
5139
commands =
52-
{[testenv]commands}
53-
stestr run {posargs}
54-
55-
[testenv:py36]
56-
# TODO(efried): Remove this once https://github.com/tox-dev/tox/issues/425 is fixed.
57-
basepython = python3.6
58-
commands =
59-
{[testenv:py35]commands}
60-
61-
[testenv:pep8]
62-
envdir = {toxworkdir}/shared
63-
commands =
64-
- flake8 --format=pylint --output-file=flake8.log
65-
66-
[testenv:bandit]
67-
envdir = {toxworkdir}/shared
68-
commands = bandit -r image-classification-tf-dicom -x tests -s B110,B410
69-
70-
[flake8]
71-
# H803 skipped on purpose per list discussion.
72-
# E123, E125 skipped as they are invalid PEP-8.
73-
74-
show-source = True
75-
ignore = E123,E125,H803,H405
76-
builtins = _
77-
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
78-
79-
[testenv:cobertura]
80-
commands = py.test --cov=image-classification-tf-dicom --cov-report=xml --cov-report=term-missing image-classification-tf-dicom/tests
81-
82-
[testenv:bandit-report]
83-
#basepython = python2.7
84-
commands =
85-
- mkdir /tmp/bandit
86-
- bandit -r image-classification-tf-dicom -x tests -s B110,B410 -f html -o /tmp/bandit/index.html
40+
mkdir -p {toxinidir}/bandit
41+
bandit -r image-classification-tf-dicom -x tests -s B101,B607,B602,B603,B404,B310 -f html -o {toxinidir}/bandit/index.html

0 commit comments

Comments
 (0)