forked from tlaplus/tlaplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.jenkins.groovy
234 lines (198 loc) · 13.1 KB
/
.jenkins.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//def labels = ['windows', 'master', 'macos'] // labels for Jenkins node types we will build on
def labels = ['master', 'macos']
def branch = "master"
def builders = [:]
for (x in labels) {
def label = x // Need to bind the label variable before the closure - can't do 'for (label in labels)'
// Create a map to pass in to the 'parallel' step so we can fire all the builds at once
builders[label] = {
node(label) {
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git branch: branch, url: 'https://github.com/tlaplus/tlaplus.git'
}
stage('Tools') {
withAnt(installation: 'apache ant', jdk: 'Java11') {
if (isUnix()) {
sh "ant -f tlatools/org.lamport.tlatools/customBuild.xml info compile compile-test dist test-dist"
} else {
bat "ant -f tlatools\\org.lamport.tlatools\\customBuild.xml info compile compile-test dist test-dist"
}
}
}
stage ('RecordTestAndCoverageTools') {
junit 'tlatools/org.lamport.tlatools/target/surefire-reports/onJar/*.xml'
// collect jacoco results for TLC
jacoco classPattern: 'tlatools/org.lamport.tlatools/class', exclusionPattern: '**/*Test*.class', execPattern: 'tlatools/org.lamport.tlatools/target/code-coverage.exec', sourcePattern: 'tlatools/org.lamport.tlatools/src'
}
stage('Toolbox') {
// Run the maven build
if (label == 'master') {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: '3.5.4',
jdk: 'Java11',
mavenLocalRepo: '.repository',
options: [jacocoPublisher(disabled: true)]) {
// Run the maven build
sh "mvn -Pcodesigning -U clean verify -Dmaven.test.failure.ignore=true -Dtest.skip=true"
} // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs reports...
}
// the macosx zip on the master node to have it signed with the Apple certificate on macosx. However, only master
// has the lamport certificate to sign the individual toolbox bundles.
stash includes: 'toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip', name: 'toolbox'
} else {
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: '3.5.4',
jdk: 'Java11',
mavenLocalRepo: '.repository',
options: [jacocoPublisher(disabled: true)]) {
// Run the maven build
if (isUnix()) {
sh "mvn -U clean verify -Dmaven.test.failure.ignore=true -Dtest.skip=true"
} else {
bat "mvn -U clean verify -Dmaven.test.failure.ignore=true -Dtest.skip=true"
}
} // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs reports...
}
}
stage ('RecordTestToolbox') {
junit '**/target/surefire-reports/*.xml'
}
}
}
}
parallel builders
// Rest runs on master node alone
node ('master') {
stage ('ReportSonarQube') {
withSonarQubeEnv {
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: '3.5.4',
jdk: 'Java11') {
sh "mvn $SONAR_MAVEN_GOAL -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.branch=master"
}
}
}
stage('p2Tests') {
wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
sh '''
rm -rf TLAToolbox-?.?.?-linux.gtk.x86_64.zip
rm -rf p2test/
## copy currently released Toolbox and extract it (We want to make sure that we can update from it to this build)
wget http://dl.tlapl.us/tlatoolbox/products/TLAToolbox-1.6.0-linux.gtk.x86_64.zip
unzip -qq TLAToolbox*.zip -d p2test/
cd p2test/toolbox/
## Update current Toolbox release to this version
./toolbox -nosplash -application org.eclipse.equinox.p2.director \
-repository file://${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/repository \
-uninstallIU org.lamport.tla.toolbox.product.product \
-installIU org.lamport.tla.toolbox.product.product \
-profileProperties org.eclipse.update.install.features=true
## Use Toolbox's p2 director to install the test feature into the previuos toolbox release to verify the update above worked and didn't trash anything.
./toolbox -nosplash -application org.eclipse.equinox.p2.director \
-repository file://${WORKSPACE}/toolbox/org.lamport.tla.toolbox.p2repository/target/repository/ \
-installIU org.lamport.tla.toolbox.feature.uitest.feature.group
## Run the SWTBot smoke tests to check product zips
./toolbox -nosplash -application org.eclipse.swtbot.eclipse.junit.headless.swtbottestapplication \
-testApplication org.lamport.tla.toolbox.application \
-product org.lamport.tla.toolbox.product.standalone.product \
-nouithread \
-testPluginName org.lamport.tla.toolbox.tool.tlc.ui.uitest \
formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter \
formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,org.lamport.tla.toolbox.tool.tlc.ui.uitest.SmokeTests.xml \
-className org.lamport.tla.toolbox.SmokeTests \
-data workspace$(date +%s) \
-clean
cp *.xml ${WORKSPACE}/
'''
}
}
stage ('RecordTestP2UpdateManager') {
// Collect junit output for p2 smoke tests
junit 'p2test/toolbox/org.lamport.tla.toolbox.tool.tlc.ui.uitest.SmokeTests.xml'
}
stage('CreateRPMFile') {
sh '''
cd toolbox/org.lamport.tla.toolbox.product.product/target/
fakeroot alien --to-rpm --scripts TLAToolbox-?.?.?-linux.gtk.amd64.deb
cp TLA*.rpm products/
'''
}
stage('CreateAPTRepo') {
sh '''
chmod -x toolbox/org.lamport.tla.toolbox.product.product/createAptRepo.sh
cp toolbox/org.lamport.tla.toolbox.product.product/target/*.deb toolbox/org.lamport.tla.toolbox.product.product/target/repository/
cd toolbox/org.lamport.tla.toolbox.product.product/target/repository/
bash -x ../../createAptRepo.sh .
'''
}
stage('RenderChangelog') { // Render the github flavord markdown to html
sh 'grip --context=tlaplus/tlaplus --export ${WORKSPACE}/general/docs/changelogs/ch1_7_1.md ${WORKSPACE}/general/docs/changelogs/changelog.html'
}
}
node ('macos') {
stage('SignToolbox') {
sh 'rm -rf *'
unstash 'toolbox'
sh 'ls -lah'
sh 'unzip toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip'
sh 'codesign -f -s "Developer ID Application: M K (3PCM4M3RWK)" -v "TLA+ Toolbox.app" --deep'
sh 'ditto -ck --sequesterRsrc --keepParent "TLA+ Toolbox.app" TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip'
sh 'mv TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip toolbox/org.lamport.tla.toolbox.product.product/target/products/'
stash includes: 'toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip', name: 'signed'
}
}
node ('master') {
stage('Archive') {
unstash 'signed'
fingerprint '**/org.lamport.tla.toolbox.product.product/target/repository/, **/org.lamport.tla.toolbox.product.product/target/products/*.zip, **/org.lamport.tla.toolbox.product.product/target/products/*.deb, **/tlatools/org.lamport.tlatools/dist/, **/org.lamport.tla.toolbox.doc/html/'
archiveArtifacts '**/general/docs/changelogs/changelog.html, **/org.lamport.tla.toolbox.product.product/target/org.lamport.tla.toolbox.product.product-1.4.0-SNAPSHOT.zip, **/org.lamport.tla.toolbox.p2repository/target/repository/, **/org.lamport.tla.toolbox.product.product/target/repository/, **/org.lamport.tla.toolbox.product.product/target/products/*.zip, **/org.lamport.tla.toolbox.product.product/target/products/*.deb, **/org.lamport.tla.toolbox.product.product/target/products/*.rpm, **/org.lamport.tla.toolbox.product.product/target/products/32bit_x86/*, **/tlatools/org.lamport.tlatools/dist/, **/org.lamport.tla.toolbox.doc/html/'
}
}
node ('master') {
stage ('DraftGithubRelease') {
if (env.JOB_NAME == 'Release-HEAD-master-Toolbox') {
sh '''
#!/bin/bash
cd ${WORKSPACE}/general/docs/changelogs
## Append sha1 sum to changelog (last line of changelog has the table header).
echo "$(sha1sum ${WORKSPACE}/tlatools/org.lamport.tlatools/dist/tla2tools.jar | cut -f 1 -d " ")|tla2tools.jar" >> ch1_7_1.md
echo "$(sha1sum ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-win32.win32.x86_64.zip | cut -f 1 -d " ")|TLAToolbox-1.7.1-win32.win32.x86_64.zip" >> ch1_7_1.md
echo "$(sha1sum ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip | cut -f 1 -d " ")|TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip" >> ch1_7_1.md
echo "$(sha1sum ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-linux.gtk.x86_64.zip | cut -f 1 -d " ")|TLAToolbox-1.7.1-linux.gtk.x86_64.zip" >> ch1_7_1.md
## Two above as one-liner without intermediate file.
$(jq -n --argjson changelog "$(cat ch1_7_1.md | jq --raw-input --slurp .)" -f gh-1_7_1.jq > gh-1_7_1.json)
## Get id of existing draft release with given name.
DRAFT_RELEASE=$(curl -sS -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/tlaplus/tlaplus/releases --header "Content-Type: application/json" | jq '.[]| select(.draft==true and .name=="The Brontinus release") | .id')
echo $DRAFT_RELEASE
## Update draft release with latest changelog in case it changed.
## https://developer.github.com/v3/repos/releases/#edit-a-release
curl -sS -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE -d @gh-1_7_1.json -X PATCH --header "Content-Type: application/json"
## Remove old assets otherwise upload below will error.
ASSETS=$(curl -sS -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets --header "Content-Type: application/json" | jq '.[]| .id')
for id in $(echo "$ASSETS"); do
## DELETE /repos/:owner/:repo/releases/assets/:asset_id
curl -sS -X DELETE -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/tlaplus/tlaplus/releases/assets/$id
done
## p2 repository
#curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=repository.zip --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.p2repository/target/repository/repository.zip
## tla2tools.jar
curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=tla2tools.jar --upload-file ${WORKSPACE}/tlatools/org.lamport.tlatools/dist/tla2tools.jar
## macOS
curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-macosx.cocoa.x86_64.zip
## win32
curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=TLAToolbox-1.7.1-win32.win32.x86_64.zip --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-win32.win32.x86_64.zip
## Linux
curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=TLAToolbox-1.7.1-linux.gtk.x86_64.zip --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLAToolbox-1.7.1-linux.gtk.x86_64.zip
## deb
#curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=TLAToolbox-1.7.1-linux.gtk.amd64.deb --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/repository/TLAToolbox-1.7.1-linux.gtk.amd64.deb
## RPM
#curl -s -X POST -H "Content-Type: application/zip" -H "Authorization: token ${GITHUB_TOKEN}" https://uploads.github.com/repos/tlaplus/tlaplus/releases/$DRAFT_RELEASE/assets?name=TLAToolbox-1.7.1-linux.gtk.amd64.rpm --upload-file ${WORKSPACE}/toolbox/org.lamport.tla.toolbox.product.product/target/products/TLA\\+Toolbox-1.7.1~*.x86_64.rpm
'''
}
}
}