forked from mbeddr/mbeddr.core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.groovy
160 lines (133 loc) · 4.64 KB
/
default.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
def defaultRun() {
timestamps {
node ('linux') {
def gradleOpts ='--no-daemon --info'
def customEnv = setupEnvironment()
withEnv(customEnv) {
stage 'Checkout'
//checkout scm
gitCheckout()
stage 'Generate Build Scripts'
sh "./gradlew ${gradleOpts} -b build.gradle build_allScripts"
stage 'Build mbeddr'
sh "./gradlew ${gradleOpts} -b build.gradle build_mbeddr"
stage 'Build Tutorial'
sh "./gradlew ${gradleOpts} -b build.gradle build_tutorial"
stage name: 'Run Tests', concurrency: 2
stash includes: 'MPS/**/*', name: 'mps'
stash includes: 'build/**/*.xml,code/plugins/**/*.xml,code/languages/com.mbeddr.build/solutions/com.mbeddr.rcp/source_gen/com/mbeddr/rcp/config/*,scripts/**/*.xml', name: 'build_scripts'
stash includes: 'artifacts/**/*', name: 'build_mbeddr'
parallel (
//"windows": { runTests('windows')},
"linux": { runTests('linux')}
)
stage 'Publish Artifacts'
step([$class: 'ArtifactArchiver', artifacts: 'artifacts/', fingerprint: true])
step([$class: 'ArtifactArchiver', artifacts: 'code/languages/com.mbeddr.build/solutions/com.mbeddr.rcp/source_gen/com/mbeddr/rcp/config/', fingerprint: true])
stage 'Package'
sh "./gradlew ${gradleOpts} -b build.gradle publish_mbeddrPlatform publish_mbeddrTutorial publish_all_in_one publish_mbeddrRCP"
stage 'Cleanup'
deleteDir()
}
}
}
}
def runTests(nodeLabel) {
parallel (
"tests ${nodeLabel} 1" : {
node (nodeLabel) {
runTest("test_mbeddr_core", false)
runTest("test_mbeddr_platform", false)
runTest("test_mbeddr_performance", false)
}
},
"tests ${nodeLabel} 2" : {
node (nodeLabel) {
runTest("test_mbeddr_analysis", true)
}
},
"tests ${nodeLabel} 3" : {
node (nodeLabel) {
runTest("test_mbeddr_tutorial", false)
runTest("test_mbeddr_debugger", false)
runTest("test_mbeddr_ext", false)
runTest("test_mbeddr_cc", false)
}
}
)
}
def getWorkspacePath() {
def ws_path = pwd() + "/"
if(!isUnix()) {
sh 'set'
ws_path = "C:\\ws\\"
}
echo "WS-Path: ${ws_path}"
return ws_path
}
def runTest(gradleTask, boolean withCbmc) {
def gradleOpts ='--no-daemon --info --continue --stacktrace'
def curDir = pwd()
// The tests need an own environment since they can run on different nodes/OS with diffenrent tool paths
def customEnv = setupEnvironment()
customEnv += ["PATH+CBMC_PATH=${curDir}/cbmc"]
withEnv(customEnv) {
//checkout scm
gitCheckout()
unstash 'mps'
unstash 'build_scripts'
unstash 'build_mbeddr'
if(withCbmc) {
initCbmc()
}
try {
if(isUnix()) {
sh "./gradlew ${gradleOpts} -b build.gradle ${gradleTask}"
} else {
bat ".\\gradlew.bat ${gradleOpts} -b build.gradle ${gradleTask}"
}
step([$class: 'JUnitResultArchiver', testResults: 'scripts/**/TEST-*.xml'])
} catch(err) {
echo "### There were test failures:\n${err}"
}
}
}
def initCbmc() {
def curDir = pwd()
echo "CurrDir: $curDir"
step ([$class: 'CopyArtifact', projectName: 'Build_CBMC']);
if(isUnix()) {
sh "rm -rf ${curDir}/cbmc && mkdir -p ${curDir}/cbmc && cd cbmc/ && tar xvzf ${curDir}/cbmc-linux.tar.gz"
} else {
bat "del /S /F /Q ${curDir}\\cbmc && mkdir ${curDir}\\cbmc && cd cbmc && unzip ${curDir}\\cbmc-win.zip"
}
}
def setupEnvironment() {
def javaHome = tool(name: 'JDK 8')
def antHome = tool(name: 'Ant 1.9')
def customEnv = ["PATH+JDK=${javaHome}/bin", "PATH+ANT_HOME=${antHome}/bin", "JAVA_HOME=${javaHome}"]
return customEnv
}
@NonCPS
def gitCheckout() {
// Use a local reference git repo to speed up the checkout from GitHub
def reference = env.BSHARE
if(isUnix()) {
reference += "/gitcaches/reference/mbeddr.core/"
} else {
reference = "${BASE}\\workspace\\mbeddr_Reference_Repo\\mbeddr.core\\"
//reference += "\\gitcaches\\reference\\mbeddr.core\\"
}
echo "Reference-Path: ${reference}"
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions + [
[$class: 'CloneOption', noTags: false, reference: reference, shallow: false],
[$class: 'CleanBeforeCheckout']],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
])
}