-
Notifications
You must be signed in to change notification settings - Fork 150
352 lines (326 loc) · 12.6 KB
/
test-pr.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
name: 'Test PR'
on:
pull_request:
types: [opened, edited, reopened, synchronize]
branches:
- 'develop'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version-sync:
name: 'Version Sync'
runs-on: ubuntu-20.04
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
token: ${{ secrets.JENKINS_GITHUB_PAT }}
# fetch-depth 0 means deep clone the repo
fetch-depth: 0
- name: 'Update Version'
run: |
set -x
git config user.name devops
git config user.email [email protected]
./package/version.sh sub
if git add --update && git commit --message "Set Version: $(cat package/version)"; then
git push origin HEAD:${GITHUB_HEAD_REF}
fi
nix-maven:
name: 'Nix: Maven'
runs-on: ubuntu-20.04
needs: version-sync
steps:
- name: 'Check out code, set up Git'
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- run: |
git config user.name devops
git config user.email [email protected]
- name: 'Install Nix'
uses: cachix/install-nix-action@v22
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = http://cache.nixos.org https://hydra.iohk.io
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
- name: 'Install Cachix'
uses: cachix/cachix-action@v12
with:
name: k-framework
authToken: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
skipPush: true
- name: 'Update Maven dependencies, push changes'
run: |
set -x
git checkout ${GITHUB_HEAD_REF}
if ! git diff --exit-code origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} \
-- $(find . -name pom.xml); then
nix run .#update-maven
fi
if git add nix/ && git commit -m 'Update Nix lock files'; then
git push
fi
test-k:
name: 'K Tests'
runs-on: [self-hosted, linux, normal]
needs: version-sync
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Set up Docker'
uses: ./.github/actions/with-docker
with:
tag: k-ci-${{ github.sha }}
os: ubuntu
distro: jammy
llvm: 14
- name: 'Build and Test K'
run: docker exec -t k-ci-${GITHUB_SHA} /bin/bash -c 'mvn verify --batch-mode -U'
- name: 'Check out k-exercises'
uses: actions/checkout@v3
with:
repository: runtimeverification/k-exercises
token: ${{ secrets.JENKINS_GITHUB_PAT }}
submodules: recursive
path: k-exercises
- name: 'Tutorial Integration Tests'
run: |
docker exec -t k-ci-${GITHUB_SHA} /bin/bash -c 'k-distribution/target/release/k/bin/spawn-kserver kserver.log'
docker exec -t k-ci-${GITHUB_SHA} /bin/bash -c 'cd k-exercises/tutorial && make -j`nproc` --output-sync'
docker exec -t k-ci-${GITHUB_SHA} /bin/bash -c 'cd k-distribution/k-tutorial/1_basic && ./test_kompile.sh'
docker exec -t k-ci-${GITHUB_SHA} /bin/bash -c 'cd k-distribution/k-tutorial/2_intermediate && ./test_kompile.sh'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 k-ci-${GITHUB_SHA}
docker container rm --force k-ci-${GITHUB_SHA} || true
test-package-ubuntu-jammy:
name: 'K Ubuntu Jammy Package'
runs-on: [self-hosted, linux, normal]
needs: version-sync
steps:
- uses: actions/checkout@v3
- name: 'Build and Test'
uses: ./.github/actions/test-package
with:
os: ubuntu
distro: jammy
llvm: 14
build-package: package/debian/build-package jammy
test-package: package/debian/test-package
- name: On Failure, Upload the kore-exec.tar.gz file to the Summary Page
if: failure()
uses: actions/upload-artifact@v2
with:
name: kore-exec.tar.gz
path: |
**/kore-exec.tar.gz
- name: 'On Success, Upload the package built to the Summary Page'
if: success()
uses: actions/upload-artifact@v3
with:
name: kframework.deb
path: kframework.deb
if-no-files-found: error
retention-days: 1
set-release-id:
name: 'Set Release ID'
runs-on: ubuntu-20.04
steps:
- name: 'Get release_id'
run: echo "release_id=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)" >> ${GITHUB_OUTPUT}
id: release
outputs:
release_id: ${{ steps.release.outputs.release_id }}
source-tarball:
name: 'Create source tarball'
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
submodules: recursive
- name: 'Create source tarball'
env:
GITHUB_TOKEN: ${{ secrets.JENKINS_GITHUB_PAT }}
run: |
set -x
version=$(cat package/version)
tarball=kframework-${version}-src.tar.gz
find . -name .git | xargs rm -r
CURDIR=$(pwd)
cd ..
tar czvf ${tarball} $(basename ${CURDIR})
mv ${tarball} ${CURDIR}/
cd ${CURDIR}
gh release upload --repo runtimeverification/k --clobber v${version} ${tarball}
macos-build:
name: 'Build MacOS Package'
runs-on: macos-13
timeout-minutes: 120
needs: [set-release-id, source-tarball]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
submodules: recursive
path: kframework
- name: Check out matching homebrew repo branch
uses: actions/checkout@v3
id: checkout
with:
repository: kframework/homebrew-k
path: homebrew-k
ref: staging
continue-on-error: true
- name: Check out homebrew repo master branch
uses: actions/checkout@v3
if: ${{ steps.checkout.outcome == 'failure' }}
with:
repository: kframework/homebrew-k
path: homebrew-k
- name: Cache maven
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-
restore-keys: |
${{ runner.os }}-maven-
- name: Build brew bottle
id: build
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
MAVEN_OPTS: >-
-Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false
-Dmaven.wagon.httpconnectionManager.ttlSeconds=30
run: |
PACKAGE=kframework
VERSION=$(cat kframework/package/version)
ROOT_URL='https://github.com/runtimeverification/k/releases/download'
wget "$ROOT_URL/v${VERSION}/kframework-${VERSION}-src.tar.gz"
cd homebrew-k
../kframework/package/macos/brew-update-to-local ${PACKAGE} ${VERSION}
git commit Formula/$PACKAGE.rb -m "Update ${PACKAGE} to ${VERSION}: part 1"
../kframework/package/macos/brew-build-and-update-to-local-bottle ${PACKAGE} ${VERSION} ${ROOT_URL}
git reset HEAD^
LOCAL_BOTTLE_NAME=$(basename $(find . -name "kframework-${VERSION}.ventura.bottle*.tar.gz"))
BOTTLE_NAME=$(echo ${LOCAL_BOTTLE_NAME#./} | sed 's!kframework--!kframework-!')
../kframework/package/macos/brew-update-to-final ${PACKAGE} ${VERSION} ${ROOT_URL}
echo "path=${LOCAL_BOTTLE_NAME}" >> ${GITHUB_OUTPUT}
echo "path_remote=${BOTTLE_NAME}" >> ${GITHUB_OUTPUT}
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
- name: Upload bottle
uses: actions/upload-artifact@v2
with:
name: homebrew
path: homebrew-k
- name: Delete Release
if: failure()
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo
await github.rest.repos.deleteRelease({ owner, repo, release_id: ${{ needs.set-release-id.outputs.release_id }} })
outputs:
bottle_path: ${{ steps.build.outputs.path }}
bottle_path_remote: ${{ steps.build.outputs.path_remote }}
version: ${{ steps.build.outputs.version }}
performance-tests:
name: 'Performace Tests'
runs-on: [self-hosted, linux, performance]
needs: test-package-ubuntu-jammy
steps:
- uses: actions/checkout@v3
- name: 'Download K package from the Summary Page'
uses: actions/download-artifact@v3
with:
name: kframework.deb
- name: 'Set up Docker Test Image'
env:
BASE_OS: ubuntu
BASE_DISTRO: jammy
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_PROJECT: k-framework
BENCHER_ADAPTER: json
run: |
set -euxo pipefail
workspace=$(pwd)
docker run --name k-profiling-tests-${GITHUB_SHA} \
--rm -it --detach \
-e BENCHER_API_TOKEN=$BENCHER_API_TOKEN \
-e BENCHER_PROJECT=$BENCHER_PROJECT \
-e BENCHER_ADAPTER=$BENCHER_ADAPTER \
-e GITHUB_HEAD_REF=$GITHUB_HEAD_REF \
-e GITHUB_BASE_REF=$GITHUB_BASE_REF \
-e GITHUB_TOKEN=$GITHUB_TOKEN \
-e GITHUB_ACTIONS=true \
-e GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e GITHUB_REF=$GITHUB_REF \
--workdir /opt/workspace \
-v "${workspace}:/opt/workspace" \
${BASE_OS}:${BASE_DISTRO}
- name: 'Install K from Package'
run: |
set -euxo pipefail
docker exec -t k-profiling-tests-${GITHUB_SHA} /bin/bash -c './k-distribution/tests/profiling/setup_profiling.sh'
- name: 'Profiling Performance Tests'
run: |
set -euxo pipefail
docker exec -t k-profiling-tests-${GITHUB_SHA} /bin/bash -c 'cd k-distribution/tests/profiling && make'
- name: 'Tear down Docker'
if: always()
run: |
docker stop --time=0 k-profiling-tests-${GITHUB_SHA}
docker container rm --force k-profiling-tests-${GITHUB_SHA} || true
compile-nix-flake:
name: 'Nix flake'
strategy:
fail-fast: false
matrix:
include:
- runner: [self-hosted, linux, normal]
- runner: macos-13
os: macos-13
- runner: MacM1
os: self-macos-12
runs-on: ${{ matrix.runner }}
needs: [nix-maven]
steps:
- name: 'Check out code'
uses: actions/checkout@v3
- name: 'Upgrade bash'
if: ${{ contains(matrix.os, 'macos') }}
run: brew install bash
- name: 'Install Nix'
if: ${{ !startsWith(matrix.os, 'self') }}
uses: cachix/install-nix-action@v22
with:
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = http://cache.nixos.org https://hydra.iohk.io
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
- name: 'Install Cachix'
if: ${{ !startsWith(matrix.os, 'self') }}
uses: cachix/cachix-action@v12
with:
name: k-framework
authToken: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
- name: 'Build K Framework'
run: GC_DONT_GC=1 nix build --print-build-logs .
# These tests take a really long time to run on other platforms, so we
# skip them unless we're on the M1 runner.
- name: 'Test K'
if: ${{ matrix.os == 'self-macos-12' }}
run: GC_DONT_GC=1 nix build --print-build-logs .#test