-
Notifications
You must be signed in to change notification settings - Fork 33
/
Jenkinsfile
328 lines (325 loc) · 14.5 KB
/
Jenkinsfile
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
pipeline {
agent { label 'docker' }
environment {
KIELE_VERSION = '0.1.0'
GITHUB_TOKEN = credentials('rv-jenkins-access-token')
SHORT_REV = """${sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()}"""
LONG_REV = """${sh(returnStdout: true, script: 'git rev-parse HEAD').trim()}"""
KIELE_RELEASE_TAG = "v${env.KIELE_VERSION}-${env.SHORT_REV}"
K_RELEASE = """${sh(returnStdout: true, script: 'cat deps/k_release').trim()}"""
K_VERSION = """${sh(returnStdout: true, script: 'cat deps/k_release | cut --characters=2-').trim()}"""
}
options { ansiColor('xterm') }
stages {
stage("Init title") {
when { changeRequest() }
steps { script { currentBuild.displayName = "PR ${env.CHANGE_ID}: ${env.CHANGE_TITLE}" } }
}
stage('Build and Test') {
agent {
dockerfile {
additionalBuildArgs '--build-arg K_COMMIT=${K_VERSION} --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
reuseNode true
}
}
stages {
stage('Build') { steps { sh 'make build -j4' } }
stage('Split Tests') { steps { sh 'make split-tests -j4' } }
stage('Assemble Iele Tests') { steps { sh 'make assemble-iele-test -j4' } }
stage('Test') {
options { timeout(time: 30, unit: 'MINUTES') }
parallel {
stage('EVM Tests') { steps { sh 'make test-vm -j4' } }
stage('IELE Tests') { steps { sh 'make test-iele -j4' } }
stage('IELE Tests (Haskell)') { steps { sh 'make test-iele-haskell -j4' } }
stage('IELE Tests (Coverage)') { steps { sh 'make test-iele-coverage -j4' } }
stage('Well Formed Check') { steps { sh 'make test-wellformed -j4' } }
stage('Ill Formed Check') { steps { sh 'make test-illformed -j4' } }
stage('Interactive') { steps { sh 'make test-interactive' } }
stage('Node') { steps { sh 'make test-node -j4 TEST_PORT=9001' } }
stage('Sourcemappings') { steps { sh 'make test-sourcemap' } }
stage('Report Generation') { steps { sh 'make test-generate-report' } }
}
}
}
}
stage('Package') {
stages {
stage('Checkout SCM') { steps { dir("kiele-${KIELE_VERSION}-src") { checkout scm } } }
stage('Binary Package') {
when {
branch 'master'
beforeAgent true
}
agent {
dockerfile {
additionalBuildArgs '--build-arg K_COMMIT=${K_VERSION} --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
reuseNode true
}
}
steps {
sh '''
make build -j8
make install DESTDIR=$(pwd)/kiele-${KIELE_VERSION}-bin
tar czvf kiele-${KIELE_VERSION}-bin.tar.gz kiele-${KIELE_VERSION}-bin
'''
stash name: 'bin-kiele', includes: "kiele-${env.KIELE_VERSION}-bin.tar.gz"
}
}
stage('Ubuntu Bionic') {
stages {
stage('Build Package') {
agent {
dockerfile {
dir "kiele-${env.KIELE_VERSION}-src/package/debian"
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg BASE_IMAGE=ubuntu:bionic'
reuseNode true
}
}
steps {
dir("kiele-${env.KIELE_VERSION}-bionic") {
checkout scm
sh './package/debian/build-package.sh ${K_RELEASE} bionic'
stash name: 'bionic-kframework', includes: "kframework-bionic.deb"
}
stash name: 'bionic-kiele', includes: "kiele_${env.KIELE_VERSION}_amd64_bionic.deb"
}
}
stage('Test Package') {
agent {
dockerfile {
filename "kiele-${env.KIELE_VERSION}-src/package/debian/Dockerfile.test"
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg BASE_IMAGE=ubuntu:bionic'
reuseNode true
}
}
options { timeout(time: 15, unit: 'MINUTES') }
steps {
dir("kiele-${env.KIELE_VERSION}-bionic-test") {
unstash 'bionic-kiele'
sh '''
sudo apt-get update && sudo apt-get upgrade --yes
sudo apt-get install --yes netcat
sudo apt-get install --yes ./kiele_${KIELE_VERSION}_amd64_bionic.deb
git clone 'https://github.com/runtimeverification/iele-semantics'
cd iele-semantics
git submodule update --init --recursive
git checkout ${LONG_REV}
./package/test-package.sh 9001
'''
}
}
}
}
}
stage('Ubuntu Focal') {
when {
branch 'master'
beforeAgent true
}
post { failure { slackSend color: '#cb2431' , channel: '#iele-internal' , message: "Packaging Phase Failed: ${env.BUILD_URL}" } }
stages {
stage('Build Package') {
agent {
dockerfile {
dir "kiele-${env.KIELE_VERSION}-src/package/debian"
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg BASE_IMAGE=ubuntu:focal'
reuseNode true
}
}
steps {
dir("kiele-${env.KIELE_VERSION}-bionic") {
checkout scm
sh './package/debian/build-package.sh ${K_RELEASE} focal'
stash name: 'focal-kframework', includes: "kframework-focal.deb"
}
stash name: 'focal-kiele', includes: "kiele_${env.KIELE_VERSION}_amd64_focal.deb"
}
}
stage('Test Package') {
agent {
dockerfile {
filename "kiele-${env.KIELE_VERSION}-src/package/debian/Dockerfile.test"
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg BASE_IMAGE=ubuntu:focal'
reuseNode true
}
}
options { timeout(time: 15, unit: 'MINUTES') }
steps {
dir("kiele-${env.KIELE_VERSION}-focal-test") {
unstash 'focal-kiele'
sh '''
sudo apt-get update && sudo apt-get upgrade --yes && sudo apt-get install --yes netcat
sudo apt-get install --yes ./kiele_${KIELE_VERSION}_amd64_focal.deb
git clone 'https://github.com/runtimeverification/iele-semantics'
cd iele-semantics
git submodule update --init --recursive
git checkout ${LONG_REV}
./package/test-package.sh 9001
'''
}
}
}
}
}
stage('DockerHub') {
when {
branch 'master'
beforeAgent true
}
post { failure { slackSend color: '#cb2431' , channel: '#iele-internal' , message: "Packaging Phase Failed: ${env.BUILD_URL}" } }
environment {
DOCKERHUB_TOKEN = credentials('rvdockerhub')
BIONIC_COMMIT_TAG = "ubuntu-bionic-${env.SHORT_REV}"
BIONIC_BRANCH_TAG = "ubuntu-bionic-${env.BRANCH_NAME}"
FOCAL_COMMIT_TAG = "ubuntu-focal-${env.SHORT_REV}"
FOCAL_BRANCH_TAG = "ubuntu-focal-${env.BRANCH_NAME}"
DOCKERHUB_REPO = "runtimeverificationinc/runtimeverification-iele-semantics"
}
stages {
stage('Build Image') {
agent { label 'docker' }
steps {
unstash 'bionic-kiele'
unstash 'focal-kiele'
sh '''
mv kiele_${KIELE_VERSION}_amd64_bionic.deb kiele_amd64_bionic.deb
mv kiele_${KIELE_VERSION}_amd64_focal.deb kiele_amd64_focal.deb
docker login --username "${DOCKERHUB_TOKEN_USR}" --password "${DOCKERHUB_TOKEN_PSW}"
docker image build . --file package/docker/Dockerfile --tag "${DOCKERHUB_REPO}:${BIONIC_COMMIT_TAG}" --build-arg K_COMMIT=${K_VERSION} --build-arg DISTRO='bionic'
docker image build . --file package/docker/Dockerfile --tag "${DOCKERHUB_REPO}:${FOCAL_COMMIT_TAG}" --build-arg K_COMMIT=${K_VERSION} --build-arg DISTRO='focal'
docker image push "${DOCKERHUB_REPO}:${BIONIC_COMMIT_TAG}"
docker image push "${DOCKERHUB_REPO}:${FOCAL_COMMIT_TAG}"
docker tag "${DOCKERHUB_REPO}:${BIONIC_COMMIT_TAG}" "${DOCKERHUB_REPO}:${BIONIC_BRANCH_TAG}"
docker tag "${DOCKERHUB_REPO}:${FOCAL_COMMIT_TAG}" "${DOCKERHUB_REPO}:${FOCAL_BRANCH_TAG}"
docker push "${DOCKERHUB_REPO}:${BIONIC_BRANCH_TAG}"
docker push "${DOCKERHUB_REPO}:${FOCAL_BRANCH_TAG}"
'''
}
}
stage('Test Bionic Image') {
agent {
docker {
image "${DOCKERHUB_REPO}:${BIONIC_COMMIT_TAG}"
args '-u 0'
reuseNode true
}
}
steps {
dir("kiele-${env.KIELE_VERSION}-docker-bionic-test") {
sh '''
apt-get update && apt-get upgrade --yes && apt-get install --yes netcat
cd ~
git clone 'https://github.com/runtimeverification/iele-semantics'
cd iele-semantics
git submodule update --init --recursive
git checkout ${LONG_REV}
./package/test-package.sh 9001
'''
}
}
}
stage('Test Focal Image') {
agent {
docker {
image "${DOCKERHUB_REPO}:${FOCAL_COMMIT_TAG}"
args '-u 0'
reuseNode true
}
}
steps {
dir("kiele-${env.KIELE_VERSION}-docker-focal-test") {
sh '''
apt-get update && apt-get upgrade --yes && apt-get install --yes netcat
cd ~
git clone 'https://github.com/runtimeverification/iele-semantics'
cd iele-semantics
git submodule update --init --recursive
git checkout ${LONG_REV}
./package/test-package.sh 9001
'''
}
}
}
}
}
}
}
stage('Deploy') {
when {
branch 'master'
beforeAgent true
}
agent {
dockerfile {
additionalBuildArgs '--build-arg K_COMMIT=${K_VERSION} --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
reuseNode true
}
}
post { failure { slackSend color: '#cb2431' , channel: '#iele-internal' , message: "Deploy Phase Failed: ${env.BUILD_URL}" } }
stages {
stage('GitHub Release') {
steps {
unstash 'bin-kiele'
unstash 'bionic-kiele'
unstash 'focal-kiele'
sshagent(['rv-jenkins-github']) {
sh '''
git clone 'ssh://github.com/runtimeverification/iele-semantics.git' kiele-release
cd kiele-release
git fetch --all
git tag -d "${KIELE_RELEASE_TAG}" "${SHORT_REV}" || true
git push -d origin "${KIELE_RELEASE_TAG}" || true
hub release delete "${KIELE_RELEASE_TAG}" || true
git tag "${KIELE_RELEASE_TAG}" "${LONG_REV}"
git push origin "${KIELE_RELEASE_TAG}"
make release.md KIELE_VERSION=${KIELE_RELEASE_TAG}
hub release create \
--attach "../kiele-${KIELE_VERSION}-bin.tar.gz#KIELE Linux Binary" \
--attach "../kiele_${KIELE_VERSION}_amd64_bionic.deb#Ubuntu Bionic (18.04) Package" \
--attach "../kiele_${KIELE_VERSION}_amd64_focal.deb#Ubuntu Focal (20.04) Package" \
--file "release.md" "${KIELE_RELEASE_TAG}"
'''
}
}
}
stage('Update Dependents') {
steps {
build job: 'DevOps/master', propagate: false, wait: false \
, parameters: [ booleanParam ( name: 'UPDATE_DEPS' , value: true ) \
, string ( name: 'UPDATE_DEPS_REPO' , value: 'runtimeverification/iele-semantics' ) \
, string ( name: 'UPDATE_DEPS_VERSION' , value: "${env.KIELE_RELEASE_TAG}" ) \
]
}
}
stage('GitHub Pages') {
steps {
dir('gh-pages') {
sshagent(['rv-jenkins-github']) {
sh '''
git clone 'ssh://github.com/runtimeverification/iele-semantics.git' --depth 1 --no-single-branch --branch master --branch gh-pages
cd iele-semantics
git checkout -B gh-pages origin/master
git submodule update --init --recursive -- ./web
cd web
npm install
npm run build
npm run build-sitemap
cd -
mv web/public_content ./
rm -rf $(find . -maxdepth 1 -not -name public_content -a -not -name .git -a -not -path . -a -not -path .. -a -not -name CNAME)
mv public_content/* ./
rm -rf public_content
git add ./
git commit -m 'gh-pages: Updated the website'
git merge --strategy ours origin/gh-pages --allow-unrelated-histories
git push origin gh-pages
'''
}
}
}
}
}
}
}
}