Skip to content

Commit 81ec454

Browse files
Unify Kani bundle CI jobs (rust-lang#2841)
We have two different ways today of building release bundles, one in `kani.yml` and another one in `release.yml`, and only the `kani.yml` actually run tests. This is error prone, since the release workflow only runs during a release without validation tests, and the build can diverge from what's being tested in CI. Instead, we will always run the same workflow, except for the steps that create the release. Resolves rust-lang#2703 Co-authored-by: Zyad Hassan <[email protected]>
1 parent ecd8957 commit 81ec454

File tree

5 files changed

+302
-213
lines changed

5 files changed

+302
-213
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
name: Build bundle
4+
description: "Build the Kani bundle for the current architecture and OS. The inputs must match the worker architecture."
5+
inputs:
6+
arch:
7+
description: "Current architecture tuple"
8+
os:
9+
description: "Current operating system"
10+
outputs:
11+
version:
12+
description: "The bundle version (latest or =crate_version)"
13+
value: ${{ steps.set_output.outputs.version }}
14+
crate_version:
15+
description: "The current crate version"
16+
value: ${{ steps.set_output.outputs.crate_version }}
17+
bundle:
18+
description: "The bundle file name"
19+
value: ${{ steps.set_output.outputs.bundle }}
20+
package:
21+
description: "The package file name"
22+
value: ${{ steps.set_output.outputs.package }}
23+
runs:
24+
using: composite
25+
steps:
26+
- name: Export crate version
27+
shell: bash
28+
run: |
29+
echo "CRATE_VERSION=$(cargo pkgid | cut -d@ -f2)" >> $GITHUB_ENV
30+
31+
- name: Export tag version
32+
shell: bash
33+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/kani-') }}
34+
run: |
35+
# GITHUB_REF is refs/tags/kani-0.1.0
36+
echo "VERSION=$(echo ${{ github.ref }} | cut -d "-" -f 2)" >> $GITHUB_ENV
37+
38+
- name: Check Version
39+
shell: bash
40+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/kani-') }}
41+
run: |
42+
# Validate git tag & Cargo.toml are in sync on version number
43+
if [[ ${{ env.CRATE_VERSION }} != ${{ env.VERSION }} ]]; then
44+
echo "Git tag ${{env.VERSION}} did not match crate version ${{env.CRATE_VERSION}}"
45+
exit 1
46+
fi
47+
48+
- name: Export latest version
49+
shell: bash
50+
if: ${{ !startsWith(github.ref, 'refs/tags/kani-') }}
51+
run: |
52+
echo "VERSION=latest" >> $GITHUB_ENV
53+
54+
- name: Build bundle
55+
shell: bash
56+
run: |
57+
cargo bundle -- ${{ env.VERSION }}
58+
echo "BUNDLE=kani-${{ env.VERSION }}-${{ inputs.arch }}.tar.gz" >> $GITHUB_ENV
59+
60+
- name: Build package
61+
shell: bash
62+
run: |
63+
cargo package -p kani-verifier
64+
mv target/package/kani-verifier-${{ env.CRATE_VERSION }}.crate ${{ inputs.os }}-kani-verifier.crate
65+
echo "PKG=${{ inputs.os }}-kani-verifier.crate" >> $GITHUB_ENV
66+
67+
- name: Upload bundle
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: ${{ env.BUNDLE }}
71+
path: ${{ env.BUNDLE }}
72+
if-no-files-found: error
73+
# Aggressively short retention: we don't really need these
74+
retention-days: 3
75+
76+
- name: Upload kani-verifier pkg
77+
uses: actions/upload-artifact@v3
78+
with:
79+
name: ${{ env.PKG }}
80+
path: ${{ env.PKG }}
81+
if-no-files-found: error
82+
# Aggressively short retention: we don't really need these
83+
retention-days: 3
84+
85+
- name: Export output
86+
shell: bash
87+
id: set_output
88+
run: |
89+
echo "version=${{ env.VERSION }}" >> ${GITHUB_OUTPUT}
90+
echo "crate_version=${{ env.CRATE_VERSION }}" >> ${GITHUB_OUTPUT}
91+
echo "bundle=${{ env.BUNDLE }}" >> ${GITHUB_OUTPUT}
92+
echo "package=${{ env.PKG }}" >> ${GITHUB_OUTPUT}

.github/actions/setup/action.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright Kani Contributors
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33
name: Setup Kani Dependencies
4+
description: "Setup the machine to run Kani. Install rustup, dependencies and sync submodules."
45
inputs:
56
os:
67
description: In which Operating System is this running
@@ -21,12 +22,15 @@ runs:
2122
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/local/.ghcup
2223
df -h
2324
24-
- name: Install dependencies
25-
run: cd ${{ inputs.kani_dir }} && ./scripts/setup/${{ inputs.os }}/install_deps.sh
25+
- name: Install Rust toolchain
26+
run: |
27+
cd ${{ inputs.kani_dir }}
28+
./scripts/setup/install_rustup.sh
29+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
2630
shell: bash
2731

28-
- name: Install Rust toolchain
29-
run: cd ${{ inputs.kani_dir }} && ./scripts/setup/install_rustup.sh
32+
- name: Install dependencies
33+
run: cd ${{ inputs.kani_dir }} && ./scripts/setup/${{ inputs.os }}/install_deps.sh
3034
shell: bash
3135

3236
- name: Update submodules

.github/workflows/kani.yml

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -144,123 +144,3 @@ jobs:
144144
branch: gh-pages
145145
folder: docs/book/
146146
single-commit: true
147-
148-
releasebundle-macos:
149-
runs-on: ${{ matrix.os }}
150-
strategy:
151-
matrix:
152-
os: [macos-12]
153-
include:
154-
- os: macos-12
155-
artifact: kani-latest-x86_64-apple-darwin.tar.gz
156-
steps:
157-
- name: Checkout Kani
158-
uses: actions/checkout@v3
159-
160-
- name: Setup Kani Dependencies
161-
uses: ./.github/actions/setup
162-
with:
163-
os: ${{ matrix.os }}
164-
165-
- name: Build release bundle
166-
run: |
167-
cargo bundle -- latest
168-
cargo package -p kani-verifier
169-
170-
# We can't run macos in a container, so we can only test locally.
171-
# Hopefully any dependency issues won't be unique to macos.
172-
- name: Local install test
173-
if: ${{ matrix.os == 'macos-12' }}
174-
run: |
175-
cargo install --path ./target/package/kani-verifier-*[^e]
176-
cargo-kani setup --use-local-bundle ./${{ matrix.artifact }}
177-
(cd tests/cargo-kani/simple-lib && cargo kani)
178-
(cd tests/cargo-kani/simple-visualize && cargo kani)
179-
(cd tests/cargo-kani/build-rs-works && cargo kani)
180-
181-
- name: Upload artifact
182-
uses: actions/upload-artifact@v3
183-
with:
184-
name: ${{ matrix.artifact }}
185-
path: ${{ matrix.artifact }}
186-
if-no-files-found: error
187-
# Aggressively short retention: we don't really need these
188-
retention-days: 3
189-
190-
releasebundle-ubuntu:
191-
runs-on: ubuntu-20.04
192-
container:
193-
image: ubuntu:18.04
194-
volumes:
195-
- /usr/local:/mnt/host-local
196-
steps:
197-
- name: Remove unnecessary software to free up disk space
198-
run: |
199-
# inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
200-
df -h
201-
rm -r /mnt/host-local/lib/android /mnt/host-local/.ghcup
202-
df -h
203-
# This is required before checkout because the container does not
204-
# have Git installed, so cannot run checkout action. The checkout
205-
# action requires Git >=2.18, so use the Git maintainers' PPA.
206-
- name: Install system dependencies
207-
run: |
208-
apt-get update
209-
apt-get install -y software-properties-common apt-utils
210-
add-apt-repository ppa:git-core/ppa
211-
apt-get update
212-
apt-get install -y \
213-
build-essential bash-completion curl lsb-release sudo g++ gcc flex \
214-
bison make patch git
215-
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL \
216-
https://get.docker.com -o /tmp/install-docker.sh
217-
bash /tmp/install-docker.sh
218-
219-
- name: Checkout Kani
220-
uses: actions/checkout@v3
221-
222-
- name: Setup Kani Dependencies
223-
uses: ./.github/actions/setup
224-
with:
225-
os: ubuntu-18.04
226-
227-
- name: Build release bundle
228-
run: |
229-
PATH=/github/home/.cargo/bin:$PATH cargo bundle -- latest
230-
PATH=/github/home/.cargo/bin:$PATH cargo package -p kani-verifier
231-
232-
# -v flag: Use docker socket from host as we're running docker-in-docker
233-
- name: Build container test
234-
run: |
235-
for tag in 20-04 20-04-alt 18-04; do
236-
>&2 echo "Building test container for ${tag}"
237-
docker build -t kani-$tag -f scripts/ci/Dockerfile.bundle-test-ubuntu-$tag .
238-
done
239-
240-
- name: Run installed tests
241-
run: |
242-
for tag in kani-20-04 kani-20-04-alt kani-18-04; do
243-
for dir in simple-lib simple-visualize build-rs-works simple-kissat; do
244-
>&2 echo "Tag $tag: running test $dir"
245-
docker run -v /var/run/docker.sock:/var/run/docker.sock \
246-
-w /tmp/kani/tests/cargo-kani/$dir $tag cargo kani
247-
done
248-
docker run -v /var/run/docker.sock:/var/run/docker.sock \
249-
$tag cargo-kani setup \
250-
--use-local-bundle ./kani-latest-x86_64-unknown-linux-gnu.tar.gz
251-
done
252-
253-
# While the above test OS issues, now try testing with nightly as
254-
# default:
255-
docker run -v /var/run/docker.sock:/var/run/docker.sock \
256-
-w /tmp/kani/tests/cargo-kani/simple-lib kani-20-04 \
257-
bash -c "rustup default nightly && cargo kani"
258-
259-
- name: Upload artifact
260-
uses: actions/upload-artifact@v3
261-
with:
262-
name: kani-latest-x86_64-unknown-linux-gnu.tar.gz
263-
path: kani-latest-x86_64-unknown-linux-gnu.tar.gz
264-
if-no-files-found: error
265-
# Aggressively short retention: we don't really need these
266-
retention-days: 3

0 commit comments

Comments
 (0)