@@ -8,11 +8,11 @@ static final String[] WF_TESTS_PYTHON_ENVS = ['env_py36_pa5.yml', 'env_py38_pa7.
8
8
static final String DEFAULT_WF_TESTS_PYTHON_ENV = ' env_py39_kn47.yml'
9
9
10
10
@groovy.transform.Field
11
- static final String [] PYTEST_PYTHON_ENVS = [' env_py38_legacy' , ' env_py38' , ' env_py39' ]
11
+ static final List< String > PYTEST_PYTHON_ENVS = [' env_py38_legacy' , ' env_py38' , ' env_py39' ]
12
12
13
13
library " knime-pipeline@$BN "
14
14
15
- def baseBranch = (BN == KNIMEConstants . NEXT_RELEASE_BRANCH ? " master" : BN . replace(" releases/" , " " ))
15
+ def baseBranch = (BN == KNIMEConstants . NEXT_RELEASE_BRANCH ? ' master' : BN . replace(' releases/' , ' ' ))
16
16
17
17
/* * Return parameters to select python environment to run workflowtests with */
18
18
def getWFTestsPythonEnvParameters () {
@@ -54,14 +54,26 @@ try {
54
54
String envPath = " ${ env.WORKSPACE} /pytest-envs/${ pyEnv} "
55
55
String envYml = " ${ env.WORKSPACE} /pytest-envs/${ pyEnv} .yml"
56
56
57
- sh """
58
- micromamba create -p ${ envPath} -f ${ envYml}
59
- """
57
+ sh( label : ' create conda env ' , script : """
58
+ micromamba create -p ${ envPath} -f ${ envYml}
59
+ """ )
60
60
61
- sh """
62
- ${ envPath} /bin/pytest --junit-xml=pytest_results.xml || true
63
- """
64
- junit " pytest_results.xml"
61
+ sh(label : ' run pytest' , script : """
62
+ ${ envPath} /bin/coverage run -m pytest --junit-xml=pytest_results.xml || true
63
+
64
+ # create a separate coverage.xml file for each module
65
+ for d in org.knime.python3*/ ; do
66
+ ${ envPath} /bin/coverage xml -o "\$ {d}coverage-${ pyEnv} .xml" --include "*\$ d**/*.py" || true
67
+
68
+ # delete mention of module name in coverage.xml
69
+ if [ -f "\$ {d}coverage-${ pyEnv} .xml" ]; then
70
+ sed -i "s|\$ d||g" "\$ {d}coverage-${ pyEnv} .xml"
71
+ fi
72
+ done
73
+ """ )
74
+
75
+ junit ' pytest_results.xml'
76
+ stash(name : " ${ pyEnv} " , includes : " **/coverage-${ pyEnv} .xml" )
65
77
}
66
78
}
67
79
}
71
83
if (params[env]) {
72
84
// need to create a deep copy here, otherwise Jenkins will use
73
85
// the last selected option for everything
74
- def environmentFile = new String (env)
86
+ String environmentFile = new String (env)
75
87
parallelConfigs[" ${ environmentFile} " ] = {
76
88
runPython3MultiversionWorkflowTestConfig(environmentFile, baseBranch)
77
89
}
@@ -82,14 +94,17 @@ try {
82
94
83
95
stage(' Sonarqube analysis' ) {
84
96
env. lastStage = env. STAGE_NAME
85
- workflowTests. runSonar()
97
+ env. SONAR_ENV = " Sonarcloud"
98
+ configs = workflowTests. ALL_CONFIGURATIONS + PYTEST_PYTHON_ENVS
99
+ echo " running sonar on ${ configs} "
100
+ workflowTests. runSonar(configs)
86
101
}
87
102
} catch (ex) {
88
- currentBuild. result = ' FAILURE'
89
- throw ex
103
+ currentBuild. result = ' FAILURE'
104
+ throw ex
90
105
} finally {
91
- notifications. notifyBuild(currentBuild. result);
92
- }
106
+ notifications. notifyBuild(currentBuild. result)
107
+ }
93
108
94
109
def runPython3MultiversionWorkflowTestConfig (String environmentFile , String baseBranch ) {
95
110
withEnv([ " KNIME_WORKFLOWTEST_PYTHON_ENVIRONMENT=${ environmentFile} " ]) {
0 commit comments