-
Notifications
You must be signed in to change notification settings - Fork 92
442 lines (389 loc) · 15.1 KB
/
release.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
434
435
436
437
438
439
440
441
442
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# This workflow will build, and, optionally, release Kani bundles in this order.
#
# The release will create a draft release and upload the bundles to it, and it will only run when we push a new
# release tag (i.e.: tag named `kani-*`).
name: Release Bundle
on:
pull_request:
push:
branches:
- 'main'
tags:
- kani-*
env:
RUST_BACKTRACE: 1
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
build_bundle_macos:
name: BuildBundle-MacOs
runs-on: macos-13
permissions:
contents: write
outputs:
version: ${{ steps.bundle.outputs.version }}
bundle: ${{ steps.bundle.outputs.bundle }}
package: ${{ steps.bundle.outputs.package }}
crate_version: ${{ steps.bundle.outputs.crate_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Kani Dependencies
uses: ./.github/actions/setup
with:
os: macos-13
- name: Build bundle
id: bundle
uses: ./.github/actions/build-bundle
with:
os: macos-13
arch: x86_64-apple-darwin
build_bundle_macos_aarch64:
name: BuildBundle-MacOs-ARM
runs-on: macos-14
permissions:
contents: write
outputs:
version: ${{ steps.bundle.outputs.version }}
bundle: ${{ steps.bundle.outputs.bundle }}
package: ${{ steps.bundle.outputs.package }}
crate_version: ${{ steps.bundle.outputs.crate_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Kani Dependencies
uses: ./.github/actions/setup
with:
os: macos-14
- name: Build bundle
id: bundle
uses: ./.github/actions/build-bundle
with:
os: macos-14
arch: aarch64-apple-darwin
build_bundle_linux:
name: BuildBundle-Linux
runs-on: ubuntu-20.04
outputs:
# The bundle version (latest or the version to be released)
version: ${{ steps.bundle.outputs.version }}
bundle: ${{ steps.bundle.outputs.bundle }}
package: ${{ steps.bundle.outputs.package }}
crate_version: ${{ steps.bundle.outputs.crate_version }}
container:
# Build using ubuntu 18 due to compatibility issues with older OS.
image: ubuntu:18.04
volumes:
- /usr/local:/mnt/host-local
steps:
- name: Free up docker disk space
run: |
# inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
df -h
rm -r /mnt/host-local/lib/android /mnt/host-local/.ghcup
df -h
# This is required before checkout because the container does not
# have Git installed, so cannot run checkout action.
# The checkout action requires Git >=2.18 and python 3.7, so use the Git maintainers' PPA.
# and the "deadsnakes" PPA, as the default version of python on ubuntu 22.04 is Python 3.10
- name: Install system dependencies
run: |
apt-get update
apt-get install -y software-properties-common apt-utils
add-apt-repository ppa:git-core/ppa
add-apt-repository ppa:deadsnakes/ppa
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install -y \
build-essential bash-completion curl lsb-release sudo g++-9 gcc-9 flex \
bison make patch git python3.7 python3.7-dev python3.7-distutils
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 110 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9
ln -sf cpp-9 /usr/bin/cpp
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
curl -s https://bootstrap.pypa.io/pip/3.7/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
rm get-pip.py
- name: Checkout Kani
uses: actions/checkout@v3
- name: Setup Kani Dependencies
uses: ./.github/actions/setup
with:
os: ubuntu-18.04
- name: Build bundle
id: bundle
uses: ./.github/actions/build-bundle
with:
os: linux
arch: x86_64-unknown-linux-gnu
test-use-local-toolchain:
name: TestLocalToolchain
needs: [build_bundle_macos, build_bundle_linux]
strategy:
matrix:
os: [macos-13, ubuntu-20.04, ubuntu-22.04]
include:
- os: macos-13
rust_target: x86_64-apple-darwin
prev_job: ${{ needs.build_bundle_macos.outputs }}
- os: ubuntu-20.04
rust_target: x86_64-unknown-linux-gnu
prev_job: ${{ needs.build_bundle_linux.outputs }}
- os: ubuntu-22.04
rust_target: x86_64-unknown-linux-gnu
prev_job: ${{ needs.build_bundle_linux.outputs }}
runs-on: ${{ matrix.os }}
steps:
- name: Download bundle
uses: actions/download-artifact@v3
with:
name: ${{ matrix.prev_job.bundle }}
- name: Download kani-verifier crate
uses: actions/download-artifact@v3
with:
name: ${{ matrix.prev_job.package }}
- name: Check download
run: |
ls -lh .
- name: Get toolchain version used to setup kani
run: |
tar zxvf ${{ matrix.prev_job.bundle }}
DATE=$(cat ./kani-${{ matrix.prev_job.version }}/rust-toolchain-version | cut -d'-' -f2,3,4)
echo "Nightly date: $DATE"
echo "DATE=$DATE" >> $GITHUB_ENV
- name: Install Kani from path
run: |
tar zxvf ${{ matrix.prev_job.package }}
cargo install --locked --path kani-verifier-${{ matrix.prev_job.crate_version }}
- name: Create a custom toolchain directory
run: mkdir -p ${{ github.workspace }}/../custom_toolchain
- name: Fetch the nightly tarball
run: |
echo "Downloading Rust toolchain from rust server."
curl --proto '=https' --tlsv1.2 -O https://static.rust-lang.org/dist/$DATE/rust-nightly-${{ matrix.rust_target }}.tar.gz
tar -xzf rust-nightly-${{ matrix.rust_target }}.tar.gz
./rust-nightly-${{ matrix.rust_target }}/install.sh --prefix=${{ github.workspace }}/../custom_toolchain
- name: Ensure installation is correct
run: |
cargo kani setup --use-local-bundle ./${{ matrix.prev_job.bundle }} --use-local-toolchain ${{ github.workspace }}/../custom_toolchain/
- name: Ensure that the rustup toolchain is not present
run: |
if [ ! -e "~/.rustup/toolchains/" ]; then
echo "Default toolchain file does not exist. Proceeding with running tests."
else
echo "::error::Default toolchain exists despite not installing."
exit 1
fi
- name: Checkout tests
uses: actions/checkout@v4
- name: Move rust-toolchain file to outside kani
run: |
mkdir -p ${{ github.workspace }}/../post-setup-tests
cp -r tests/cargo-ui ${{ github.workspace }}/../post-setup-tests
cp -r tests/kani/Assert ${{ github.workspace }}/../post-setup-tests
ls ${{ github.workspace }}/../post-setup-tests
- name: Run cargo-kani tests after moving
run: |
for dir in supported-lib-types/rlib multiple-harnesses verbose; do
>&2 echo "Running test $dir"
pushd ${{ github.workspace }}/../post-setup-tests/cargo-ui/$dir
cargo kani
popd
done
- name: Check --help and --version
run: |
>&2 echo "Running cargo kani --help and --version"
pushd ${{ github.workspace }}/../post-setup-tests/Assert
cargo kani --help && cargo kani --version
popd
- name: Run standalone kani test
run: |
>&2 echo "Running test on file bool_ref"
pushd ${{ github.workspace }}/../post-setup-tests/Assert
kani bool_ref.rs
popd
test_bundle:
name: TestBundle
needs: [build_bundle_macos, build_bundle_linux]
strategy:
matrix:
os: [macos-13, ubuntu-20.04, ubuntu-22.04]
include:
# Stores the output of the previous job conditional to the OS
- prev_job: ${{ needs.build_bundle_linux.outputs }}
- os: macos-13
prev_job: ${{ needs.build_bundle_macos.outputs }}
runs-on: ${{ matrix.os }}
steps:
- name: Download bundle
uses: actions/download-artifact@v3
with:
name: ${{ matrix.prev_job.bundle }}
- name: Download kani-verifier crate
uses: actions/download-artifact@v3
with:
name: ${{ matrix.prev_job.package }}
- name: Check download
run: |
ls -lh .
- name: Install from bundle
run: |
tar zxvf ${{ matrix.prev_job.package }}
cargo install --locked --path kani-verifier-${{ matrix.prev_job.crate_version }}
cargo kani setup --use-local-bundle ./${{ matrix.prev_job.bundle }}
- name: Checkout tests
uses: actions/checkout@v4
- name: Run tests
# TODO: Customize compiletest to run custom kani. For now, just run a few cargo kani tests.
run: |
for dir in simple-lib simple-visualize build-rs-works simple-kissat; do
>&2 echo "Running test $dir"
pushd tests/cargo-kani/$dir
cargo kani
popd
done
# This job will run tests for platforms that don't have a respective GitHub worker.
# For now, we only test for Ubuntu-18.04 so we don't bother using matrix to configure the platform.
test_alt_platform:
name: TestAlternativePlatforms
needs: [build_bundle_linux]
runs-on: ubuntu-22.04
env:
PKG: ${{ needs.build_bundle_linux.outputs.package }}
BUNDLE: ${{ needs.build_bundle_linux.outputs.bundle }}
VERSION: ${{ needs.build_bundle_linux.outputs.crate_version }}
KANI_SRC: ./kani_src
steps:
- name: Checkout Kani
uses: actions/checkout@v4
with:
path: ${{ env.KANI_SRC }}
- name: Download bundle
uses: actions/download-artifact@v3
with:
name: ${{ env.BUNDLE }}
- name: Download kani-verifier crate
uses: actions/download-artifact@v3
with:
name: ${{ env.PKG }}
- name: Build container test
run: |
docker build -t kani-18-04 -f ${{ env.KANI_SRC }}/scripts/ci/Dockerfile.bundle-test-ubuntu-18-04 .
- name: Run installed tests
run: |
for dir in simple-lib simple-visualize build-rs-works simple-kissat; do
>&2 echo "Running test $dir"
docker run -v /var/run/docker.sock:/var/run/docker.sock \
-w /tmp/kani/tests/cargo-kani/$dir kani-18-04 cargo kani
done
# While the above test OS issues, now try testing with nightly as
# default:
docker run -v /var/run/docker.sock:/var/run/docker.sock \
-w /tmp/kani/tests/cargo-kani/simple-lib kani-18-04 \
bash -c "rustup default nightly && cargo kani"
kani_release:
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/kani-') }}
name: Release
runs-on: ubuntu-20.04
needs: [build_bundle_macos, build_bundle_macos_aarch64, build_bundle_linux, test_bundle, test_alt_platform]
permissions:
contents: write
outputs:
version: ${{ steps.versioning.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
run: |
# pkgid is something like file:///home/ubuntu/kani#kani-verifier:0.1.0
echo "CRATE_VERSION=$(cargo pkgid | cut -d@ -f2)" >> $GITHUB_ENV
# GITHUB_REF is something like refs/tags/kani-0.1.0
echo "TAG_VERSION=$(echo ${{ github.ref }} | cut -d "-" -f 2)" >> $GITHUB_ENV
- name: Check Version
id: versioning
run: |
# Validate git tag & Cargo.toml are in sync on version number
if [[ ${{ env.CRATE_VERSION }} != ${{ env.TAG_VERSION }} ]]; then
echo "Git tag ${{env.TAG_VERSION}} did not match crate version ${{env.CRATE_VERSION}}"
exit 1
fi
echo "version=${{ env.TAG_VERSION }}" >> $GITHUB_OUTPUT
- name: Download MacOS bundle
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_bundle_macos.outputs.bundle }}
- name: Download MacOS ARM bundle
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_bundle_macos_aarch64.outputs.bundle }}
- name: Download Linux bundle
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_bundle_linux.outputs.bundle }}
- name: Create release
id: create_release
uses: ncipollo/release-action@v1.14.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: kani-${{ env.TAG_VERSION }}
tag: kani-${{ env.TAG_VERSION }}
artifacts: "${{ needs.build_bundle_linux.outputs.bundle }},${{ needs.build_bundle_macos.outputs.bundle }},${{ needs.build_bundle_macos_aarch64.outputs.bundle }}"
body: |
Kani Rust verifier release bundle version ${{ env.TAG_VERSION }}.
draft: true
package_docker:
name: Package Docker
needs: kani_release
runs-on: ubuntu-20.04
permissions:
contents: write
packages: write
env:
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Kani Dependencies
uses: ./.github/actions/setup
with:
os: ubuntu-20.04
- name: 'Build release bundle'
run: |
cargo bundle
cargo package -p kani-verifier
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Set lower case owner name. Needed for docker push.'
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: scripts/ci/Dockerfile.bundle-release-20-04
push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/${{ env.OWNER_LC }}/kani-${{ env.os }}:${{ needs.kani_release.outputs.version }}
ghcr.io/${{ env.OWNER_LC }}/kani-${{ env.os }}:latest
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ needs.kani_release.outputs.version }}
org.opencontainers.image.licenses=Apache-2.0 OR MIT
# This check will not work until #1655 is completed.
# - name: Check action and image is updated.
# uses: ./.
# with:
# command: |
# [[ "$(cargo kani --version)" == 'cargo-kani ${{ needs.Release.outputs.version }}' ]]