-
Notifications
You must be signed in to change notification settings - Fork 17
433 lines (380 loc) · 17.5 KB
/
scala.yml
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2011-2020 ETH Zurich.
name: Build, Test, and Publish
on:
push: # run this workflow on every push
pull_request: # run this workflow on every pull_request
workflow_dispatch: # allow to manually trigger this workflow
inputs:
type:
description: 'Specifies whether a stable or nightly release should be triggered. Note that "stable" can only be used on branch "release".'
required: true
default: 'nightly'
options:
- stable
- nightly
tag_name:
description: 'Tag name for stable release. Ignored if a nightly release will be created.'
required: true
default: '-'
release_name:
description: 'Release title for stable release. Ignored if a nightly release will be created.'
required: true
default: '-'
schedule:
- cron: '0 7 * * *' # run every day at 07:00 UTC
# some remarks about the high-level structure of this CI script:
# - build
# `build` builds and tests ViperServer using sbt.
# - test
# `test` takes both ViperServer JARs that include tests and executes them on Ubuntu, macOS, and Windows.
# - create-nightly-release
# takes the fat and skinny JARs produced by configuration `latest` during `build` job and creates a nightly release with
# them. This job automatically runs every night.
# - create-stable-release
# takes the fat and skinny JARs produced by configuration `release` during `build` job and creates a draft release with
# them. This only works on branch `release`.
env:
Z3_VERSION: "4.8.7"
jobs:
build:
# build is the base job on which all other jobs depend
# we enforce here that the nightly build job only runs in the main repo:
if: (github.event_name == 'schedule' && github.repository == 'viperproject/viperserver') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
container: viperproject/viperserver:v4_z3_4.8.7
steps:
- name: Checkout ViperServer
uses: actions/checkout@v3
with:
path: viperserver
submodules: recursive
- name: Java Version
run: java --version
- name: Z3 Version
run: z3 -version
- name: Boogie Version
run: boogie /version
- name: Get Silver commits referenced by Silicon and Carbon
run: |
echo "SILICON_SILVER_REF=$(git -C viperserver/silicon/silver rev-parse HEAD)" >> $GITHUB_ENV
echo "CARBON_SILVER_REF=$(git -C viperserver/carbon/silver rev-parse HEAD)" >> $GITHUB_ENV
- name: Silicon and Carbon reference different Silver commits
if: env.SILICON_SILVER_REF != env.CARBON_SILVER_REF
run: |
echo "::error file=.github/workflows/scala.yml::Silicon and Carbon reference different Silver commits (${{ env.SILICON_SILVER_REF }} and ${{ env.CARBON_SILVER_REF }})"
# terminate this job:
exit 1
- name: Create version file
run: |
echo "ViperServer: commit $(git -C viperserver rev-parse HEAD)" >> versions.txt
echo "Silicon: commit $(git -C viperserver/silicon rev-parse HEAD)" >> versions.txt
echo "Carbon: commit $(git -C viperserver/carbon rev-parse HEAD)" >> versions.txt
echo "Silver: commit ${{ env.SILICON_SILVER_REF }}" >> versions.txt
# first line overwrites versions.txt in case it already exists, all other append to the file
- name: Upload version file
uses: actions/upload-artifact@v3
with:
name: versions.txt
path: versions.txt
- name: Set sbt cache variables
run: echo "SBT_OPTS=-Dsbt.global.base=sbt-cache/.sbtboot -Dsbt.boot.directory=sbt-cache/.boot -Dsbt.ivy.home=sbt-cache/.ivy" >> $GITHUB_ENV
# note that the cache path is relative to the directory in which sbt is invoked.
- name: Cache SBT
uses: actions/cache@v3
with:
path: |
viperserver/sbt-cache/.sbtboot
viperserver/sbt-cache/.boot
viperserver/sbt-cache/.ivy/cache
# <x>/project/target and <x>/target, where <x> is e.g. 'viperserver', are intentionally not
# included as several occurrences of NoSuchMethodError exceptions have been observed during CI runs. It seems
# like sbt is unable to correctly compute source files that require a recompilation. Therefore, we have
# disabled caching of compiled source files altogether
key: ${{ runner.os }}-sbt-no-precompiled-sources-${{ hashFiles('**/build.sbt') }}
- name: Test ViperServer
run: sbt test
working-directory: viperserver
- name: Upload log files
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: TestLogs
path: viperserver/logs
- name: Assemble ViperServer skinny JARs
run: sbt stage
working-directory: viperserver
- name: Zip skinny JARs
run: zip -r ../../../../viperserver-skinny-jars.zip ./*
working-directory: viperserver/target/universal/stage/lib
- name: Upload ViperServer skinny JARs
uses: actions/upload-artifact@v3
with:
name: viperserver-skinny-jars
path: viperserver/viperserver-skinny-jars.zip
- name: Assemble ViperServer fat JAR
run: sbt "set test in assembly := {}" clean assembly
working-directory: viperserver
- name: Upload ViperServer fat JAR
uses: actions/upload-artifact@v3
with:
name: viperserver-fat-jar
path: viperserver/target/scala-2.13/viperserver.jar
- name: Assemble ViperServer test fat JAR
run: sbt clean test:assembly
working-directory: viperserver
- name: Upload ViperServer test fat JAR
uses: actions/upload-artifact@v3
with:
name: viperserver-test-fat-jar
path: viperserver/target/scala-2.13/viperserver-test.jar
test:
name: test - ${{ matrix.os }}
needs: build
strategy:
# tests should not be stopped when they fail on one of the OSes:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
WIN_BOOGIE_URL: 'https://github.com/viperproject/boogie-builder/releases/latest/download/boogie-win.zip'
LINUX_BOOGIE_URL: 'https://github.com/viperproject/boogie-builder/releases/latest/download/boogie-linux.zip'
MAC_BOOGIE_URL: 'https://github.com/viperproject/boogie-builder/releases/latest/download/boogie-osx.zip'
steps:
# we need to checkout the repo to have access to the test files
- name: Checkout ViperServer
uses: actions/checkout@v3
with:
path: viperserver
# we need to checkout the silicon repo to have access to the logback configuration file
# as we do not use anything else except the logback config, we simply take the latest master branch (in all configurations)
- name: Checkout Silicon
uses: actions/checkout@v3
with:
repository: viperproject/silicon
path: silicon
- name: Download ViperServer test fat JAR
uses: actions/download-artifact@v3
with:
name: viperserver-test-fat-jar
path: viperserver
- name: Download Z3 (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
curl -L --silent --show-error --fail https://github.com/Z3Prover/z3/releases/download/z3-${{ env.Z3_VERSION }}/z3-${{ env.Z3_VERSION }}-x64-ubuntu-16.04.zip --output z3.zip
unzip z3.zip -d z3/
echo "$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-ubuntu-16.04/bin" >> $GITHUB_PATH
echo "Z3_EXE=$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-ubuntu-16.04/bin/z3" >> $GITHUB_ENV
shell: bash
- name: Download Z3 (macOS)
if: startsWith(matrix.os, 'macos')
run: |
curl -L --silent --show-error --fail https://github.com/Z3Prover/z3/releases/download/z3-${{ env.Z3_VERSION }}/z3-${{ env.Z3_VERSION }}-x64-osx-10.14.6.zip --output z3.zip
unzip z3.zip -d z3/
echo "$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-osx-10.14.6/bin" >> $GITHUB_PATH
echo "Z3_EXE=$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-osx-10.14.6/bin/z3" >> $GITHUB_ENV
shell: bash
- name: Download Z3 (Windows)
if: startsWith(matrix.os, 'windows')
run: |
curl -L --silent --show-error --fail https://github.com/Z3Prover/z3/releases/download/z3-${{ env.Z3_VERSION }}/z3-${{ env.Z3_VERSION }}-x64-win.zip --output z3.zip
unzip z3.zip -d z3/
echo "$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-win/bin" >> $GITHUB_PATH
echo "Z3_EXE=$GITHUB_WORKSPACE/z3/z3-${{ env.Z3_VERSION }}-x64-win/bin/z3.exe" >> $GITHUB_ENV
shell: bash
- name: Download Boogie (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
curl -L --silent --show-error --fail ${{ env.LINUX_BOOGIE_URL }} --output boogie-linux.zip
unzip boogie-linux.zip -d boogie-linux
echo "$GITHUB_WORKSPACE/boogie-linux/binaries-linux" >> $GITHUB_PATH
echo "BOOGIE_EXE=$GITHUB_WORKSPACE/boogie-linux/binaries-linux/Boogie" >> $GITHUB_ENV
shell: bash
- name: Download Boogie (macOS)
if: startsWith(matrix.os, 'macos')
run: |
curl -L --silent --show-error --fail ${{ env.MAC_BOOGIE_URL }} --output boogie-mac.zip
unzip boogie-mac.zip -d boogie-mac
echo "$GITHUB_WORKSPACE/boogie-mac/binaries-osx" >> $GITHUB_PATH
echo "BOOGIE_EXE=$GITHUB_WORKSPACE/boogie-mac/binaries-osx/Boogie" >> $GITHUB_ENV
shell: bash
- name: Download Boogie (Windows)
if: startsWith(matrix.os, 'windows')
run: |
curl -L --silent --show-error --fail ${{ env.WIN_BOOGIE_URL }} --output boogie-win.zip
unzip boogie-win.zip -d boogie-win
echo "$GITHUB_WORKSPACE/boogie-win/binaries-win" >> $GITHUB_PATH
echo "BOOGIE_EXE=$GITHUB_WORKSPACE/boogie-win/binaries-win/Boogie.exe" >> $GITHUB_ENV
shell: bash
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Java Version
run: java --version
- name: Z3 Version
run: z3 -version
- name: Boogie Version
run: Boogie /version
# unfortunately, the JAR seems to be broken and discovering test suites (e.g. using `-w viper.server`) fails.
# thus, the test suites have to be explicitly mentioned
- name: Test ViperServer
run: java -Xss128m -Dlogback.configurationFile=$GITHUB_WORKSPACE/silicon/src/main/resources/logback.xml -cp viperserver-test.jar org.scalatest.tools.Runner -R viperserver-test.jar -o -s viper.server.core.AstGenerationTests -s viper.server.core.CoreServerSpec -s viper.server.core.ViperServerHttpSpec
shell: bash
working-directory: viperserver
- name: Upload log files
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: TestLogs-${{ runner.os }}
path: viperserver/logs
create-nightly-release:
needs: test
# this job creates a new nightly pre-release, set viperserver.jar as artifacts, and deletes old releases
if: github.ref != 'refs/heads/release' && ((github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly') || github.event_name == 'schedule')
runs-on: ubuntu-latest
steps:
- name: Install prerequisites
run: sudo apt-get install curl
- name: Download ViperServer skinny JARs
uses: actions/download-artifact@v3
with:
name: viperserver-skinny-jars
path: deploy
- name: Download ViperServer fat JAR
uses: actions/download-artifact@v3
with:
name: viperserver-fat-jar
path: deploy
- name: Download version file
uses: actions/download-artifact@v3
with:
name: versions.txt
- name: Check whether commits have changed
# the following command queries all releases (as JSON) and passes it to `jq` that performs the following
# filtering:
# 1. only consider prereleases (instead of stable releases)
# 2. extract body
# 3. check if $VERSIONS is contained in the release's body. $VERSIONS stores the file content of versions.txt
# 4. return 'true" if at least one release satisfies the criterion
# MATCHING_RELEASE is 'true' if a matching release has been found and thus no new release should be created
run: |
MATCHING_RELEASE=$( \
curl --fail --silent \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
--url 'https://api.github.com/repos/viperproject/viperserver/releases' \
| \
jq --rawfile VERSIONS versions.txt \
'map(select(.prerelease == true) | .body | contains($VERSIONS)) | any')
echo "MATCHING_RELEASE=$MATCHING_RELEASE" >> $GITHUB_ENV
- name: Create release tag
if: env.MATCHING_RELEASE != 'true'
shell: bash
run: echo "TAG_NAME=$(date +v-%Y-%m-%d-%H%M)" >> $GITHUB_ENV
- name: Create nightly release
if: env.MATCHING_RELEASE != 'true'
id: create_release
uses: viperproject/create-nightly-release@v1
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: Nightly Release ${{ env.TAG_NAME }}
body_path: versions.txt
keep_num: 1 # keep the previous nightly release such that there are always two
keep_tags: true
- name: Upload ViperServer skinny jars
if: env.MATCHING_RELEASE != 'true'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/viperserver-skinny-jars.zip
asset_name: viperserver-skinny-jars.zip
asset_content_type: application/zip
- name: Upload ViperServer fat jar artifact
if: env.MATCHING_RELEASE != 'true'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/viperserver.jar
asset_name: viperserver.jar
asset_content_type: application/octet-stream
- name: Trigger Viper-IDE CI
if: env.MATCHING_RELEASE != 'true'
run: |
curl --fail --request POST \
--user 'viper-admin:${{ secrets.VIPER_ADMIN_TOKEN }}' \
--header 'Accept: application/vnd.github.v3+json' \
--url 'https://api.github.com/repos/viperproject/viper-ide/actions/workflows/test.yml/dispatches' \
--data "{ \
\"ref\":\"master\", \
\"inputs\":{ \
\"type\":\"nightly\", \
\"viperserver_tag_name\":\"${{ env.TAG_NAME }}\", \
\"boogie_tag_name\":\"latest\", \
\"z3_version\":\"${{ env.Z3_VERSION }}\", \
\"tag_name\":\"${{ env.TAG_NAME }}\", \
\"release_name\":\"Nightly Release ${{ env.TAG_NAME }}\" \
} \
}"
create-stable-release:
needs: test
# this job creates a stable draft-release and set viperserver.jar as artifacts
if: github.ref == 'refs/heads/release' && github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'stable'
runs-on: ubuntu-latest
steps:
- name: Download ViperServer skinny JARs
uses: actions/download-artifact@v3
with:
name: viperserver-skinny-jars
path: deploy
- name: Download ViperServer fat JAR
uses: actions/download-artifact@v3
with:
name: viperserver-fat-jar
path: deploy
- name: Download version file
uses: actions/download-artifact@v3
with:
name: versions.txt
- name: Create stable draft-release
id: create_release
uses: actions/create-release@v1
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag_name }}
release_name: ${{ github.event.inputs.release_name }}
body_path: versions.txt
draft: true
prerelease: false
- name: Upload ViperServer skinny jars
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/viperserver-skinny-jars.zip
asset_name: viperserver-skinny-jars.zip
asset_content_type: application/zip
- name: Upload ViperServer fat jar
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: deploy/viperserver.jar
asset_name: viperserver.jar
asset_content_type: application/octet-stream