Skip to content

Commit 70bd021

Browse files
authored
Add two new CI workflows to check Kani against verify-rust-std (rust-lang#3386)
This PR adds the following workflows: 1. `verify-std-check`: This workflow will run either in a PR or via workflow call. It pulls the `main` branch of `verify-rust-std` repository, and see if it can verify the repo with the new Kani version from HEAD. - If verification succeeds, the workflow will succeed. - If the verification fails and this is a PR, the workflow will compare the verification result against the base of the PR. The workflow will succeed if the results match*. 2. `verify-std-update`: This workflow will run the `verify-std-check` workflow. If it succeeds, it will update the `verify-rust-std` branch from HEAD. This workflow will fail if `features/verify-rust-std` branch diverges, and a merge is required. The motivation for this PR is to help us identify any changes to Kani that may break the Rust verification repository, and to keep the `verify-rust-std` up to date as much as possible. * The fallback logic is needed since toolchain upgrades can potentially break the std verification. This will happen in cases where the new toolchain version is incompatible with the library version from the `verify-rust-std`. Those cases should not interfere with Kani development, and they should be fixed when we update the `verify-rust-std` repo.
1 parent b18698f commit 70bd021

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
#
4+
# This workflow will try to build and run the `verify-rust-std` repository.
5+
#
6+
# This check should be optional, but it has been added to help provide
7+
# visibility to when a PR may break the `verify-rust-std` repository.
8+
#
9+
# We expect toolchain updates to potentially break this workflow in cases where
10+
# the version tracked in the `verify-rust-std` is not compatible with newer
11+
# versions of the Rust toolchain.
12+
#
13+
# Changes unrelated to the toolchain should match the current status of main.
14+
15+
name: Check Std Verification
16+
on:
17+
pull_request:
18+
workflow_call:
19+
20+
env:
21+
RUST_BACKTRACE: 1
22+
23+
jobs:
24+
verify-std:
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
# Kani does not support windows.
29+
os: [ ubuntu-22.04, macos-14 ]
30+
steps:
31+
- name: Checkout Library
32+
uses: actions/checkout@v4
33+
with:
34+
repository: model-checking/verify-rust-std
35+
path: verify-rust-std
36+
submodules: true
37+
38+
- name: Checkout `Kani`
39+
uses: actions/checkout@v4
40+
with:
41+
path: kani
42+
43+
- name: Setup Kani Dependencies
44+
uses: ./kani/.github/actions/setup
45+
with:
46+
os: ${{ matrix.os }}
47+
kani_dir: kani
48+
49+
- name: Build Kani
50+
working-directory: kani
51+
run: |
52+
cargo build-dev
53+
echo "$(pwd)/scripts" >> $GITHUB_PATH
54+
55+
- name: Run verification with HEAD
56+
id: check-head
57+
working-directory: verify-rust-std
58+
continue-on-error: true
59+
run: |
60+
kani verify-std -Z unstable-options ./library --target-dir ${{ runner.temp }} -Z function-contracts \
61+
-Z mem-predicates -Z ptr-to-ref-cast-checks
62+
63+
# If the head failed, check if it's a new failure.
64+
- name: Checkout base
65+
working-directory: kani
66+
if: steps.check-head.outcome != 'success' && github.event_name == 'pull_request'
67+
run: |
68+
BASE_REF=${{ github.event.pull_request.base.sha }}
69+
git checkout ${BASE_REF}
70+
cargo build-dev
71+
72+
- name: Run verification with BASE
73+
id: check-base
74+
if: steps.check-head.outcome != 'success' && github.event_name == 'pull_request'
75+
working-directory: verify-rust-std
76+
continue-on-error: true
77+
run: |
78+
kani verify-std -Z unstable-options ./library --target-dir ${{ runner.temp }} -Z function-contracts \
79+
-Z mem-predicates -Z ptr-to-ref-cast-checks
80+
81+
- name: Compare PR results
82+
if: steps.check-head.outcome != 'success' && steps.check-head.output != github.check-base.output
83+
run: |
84+
echo "New failure introduced by this change"
85+
exit 1
86+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
#
4+
# This workflow will try to update the verify std branch.
5+
6+
name: Update "features/verify-rust-std"
7+
on:
8+
schedule:
9+
- cron: "30 3 * * *" # Run this every day at 03:30 UTC
10+
workflow_dispatch: # Allow manual dispatching.
11+
12+
env:
13+
RUST_BACKTRACE: 1
14+
15+
jobs:
16+
# First ensure the HEAD is compatible with the `verify-rust-std` repository.
17+
verify-std:
18+
name: Verify Std
19+
permissions: { }
20+
uses: ./.github/workflows/verify-std-check.yml
21+
22+
# Push changes to the features branch.
23+
update-branch:
24+
needs: verify-std
25+
permissions:
26+
contents: write
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout Kani
30+
uses: actions/checkout@v4
31+
32+
- name: Update feature branch
33+
run: |
34+
git push origin HEAD:features/verify-rust-std
35+

0 commit comments

Comments
 (0)