Skip to content

Commit 69d357b

Browse files
Fix Kani version parsing in install script (#58)
Co-authored-by: Felipe Monteiro <felisous@amazon.com>
1 parent 2534b7a commit 69d357b

7 files changed

Lines changed: 46 additions & 91 deletions

File tree

‎.github/workflows/test-action.yml‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ jobs:
4040

4141
- name: Test "Run Kani with older version"
4242
run: |
43-
installed_version=$(kani --version | awk '{print $2}')
43+
# Kani 0.67.0 and earlier print `kani <version>`; 0.68.0 and later
44+
# print `Kani Rust Verifier <version> (<invocation>)` plus a CBMC line.
45+
installed_version=$(
46+
kani --version |
47+
sed -nE 's/^(Kani Rust Verifier|kani) ([^[:space:]]+).*/\2/p' |
48+
head -1
49+
)
4450
expected_version='0.33.0'
4551
4652
if [[ "$installed_version" == "$expected_version" ]]; then
@@ -57,19 +63,18 @@ jobs:
5763

5864
- name: Test "Run Kani with latest version"
5965
run: |
60-
installed_version=$(kani --version | awk '{print $2}')
61-
expected_version=$(cargo search kani-verifier | grep -m 1 "kani" | awk '{print $3}' | sed 's/"//g')
66+
installed_version=$(
67+
kani --version |
68+
sed -nE 's/^(Kani Rust Verifier|kani) ([^[:space:]]+).*/\2/p' |
69+
head -1
70+
)
71+
# CARGO_TERM_COLOR=always leaks in from the Rust toolchain action, and
72+
# its escape codes would defeat the anchor below.
73+
expected_version=$(CARGO_TERM_COLOR=never cargo search kani-verifier | grep -m 1 "^kani-verifier " | awk '{print $3}' | sed 's/"//g')
6274
6375
if [[ "$installed_version" == "$expected_version" ]]; then
6476
echo "The installed version ($installed_version) matches the latest version ($expected_version)"
6577
else
6678
echo "::error::The installed version ($installed_version) does not match the latest version ($expected_version)."
6779
exit 1
6880
fi
69-
70-
- name: Test ProfProof within Kani Action
71-
uses: ./
72-
with:
73-
working-directory: tests/cargo-kani/proptest-lib
74-
args: --tests
75-
enable-propproof: true

‎README.md‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ If omitted, the latest version of `Kani` hosted on [`Kani's crates.io page`](htt
3333
- **Default**: `''`
3434
- **Usage**: These arguments or subcommands will be appended to the Kani command.
3535

36-
`enable-propproof`
37-
38-
- **Description**: Experimental feature that allows Kani to verify [proptest harnesses](https://proptest-rs.github.io/proptest/proptest/index.html) using the PropProof feature.
39-
- **Default**: `false`
40-
- **Usage**: If set to `true`, Kani will enable the experimental PropProof feature for verifying proptest harnesses.
41-
4236
## Example usage in a workflow YAML file:
4337

4438
Here are a few examples of workflow YAML files for the Kani Github Action:
@@ -75,7 +69,7 @@ jobs:
7569

7670
#### Example 3: Run Kani with args
7771

78-
Use latest version of Kani, to run `cargo-kani --tests` on a project with `propproof` harnesses.
72+
Use latest version of Kani, to run `cargo-kani --tests` on a project.
7973

8074
```yaml
8175
jobs:
@@ -86,7 +80,6 @@ jobs:
8680
uses: model-checking/kani-github-action@v1
8781
with:
8882
args: '--tests'
89-
enable-propproof: true
9083
```
9184

9285
## Security

‎action.yml‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ inputs:
2626
description: 'Arguments to pass to kani.'
2727
required: false
2828
default: ''
29-
enable-propproof:
30-
description: 'Experimental: Allow Kani to verify proptest harnesses using the PropProof feature'
31-
required: false
32-
default: false
3329

3430
runs:
3531
using: "composite"
@@ -41,21 +37,6 @@ runs:
4137
run: ${{ github.action_path }}/src/install-kani.sh ${{ inputs.kani-version }}
4238
shell: bash
4339

44-
- name: Install PropProof
45-
if: ${{ inputs.enable-propproof == 'true' }}
46-
uses: actions/checkout@v3
47-
with:
48-
repository: model-checking/kani
49-
ref: features/proptest
50-
path: propproof
51-
submodules: true
52-
53-
- name: Add PropProof to config
54-
if: ${{ inputs.enable-propproof == 'true' }}
55-
shell: bash
56-
run: |
57-
echo "paths = [\"$GITHUB_WORKSPACE/propproof\"]" > $HOME/.cargo/config.toml
58-
5940
- name: Run Kani
6041
shell: bash
6142
run: |

‎src/install-kani.sh‎

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fi
1212

1313
# Check exit status for error handling
1414
if [ $? -eq 0 ]; then
15-
echo "Installed Kani $VERSION successfully"
15+
echo "Installed Kani $1 successfully"
1616
else
1717
echo "::error::Could not install Kani. Please check if the provided version is correct"
1818
exit 1
@@ -21,19 +21,37 @@ fi
2121
# Setup kani in ci
2222
cargo-kani setup;
2323

24-
# Get the current installed version of kani and check it against the latest version
25-
installed_version=$(kani --version | awk '{print $2}')
24+
# Get the current installed version of kani and check it against the latest version.
25+
# Two output formats have to be supported, since this action can install any
26+
# published version:
27+
# - Kani 0.68.0 and later print `Kani Rust Verifier <version> (<invocation>)`,
28+
# followed by a `CBMC <version>` line.
29+
# - Kani 0.67.0 and earlier used clap's default flag, printing `kani <version>`.
30+
installed_version=$(
31+
kani --version |
32+
sed -nE 's/^(Kani Rust Verifier|kani) ([^[:space:]]+).*/\2/p' |
33+
head -1
34+
)
2635

27-
if [ $? -eq 0 ]; then
28-
if [ "$1" == "latest" ]; then
29-
# Cargo search returns version number as string
30-
requested_version=$(cargo search kani-verifier | grep -m 1 "kani-verifier" | awk '{print $3}' | tr -d '"')
31-
else
32-
requested_version=$1
33-
fi
36+
if [ -z "$installed_version" ]; then
37+
echo "::error::Could not determine installed Kani version from \`kani --version\`"
38+
exit 1
39+
fi
3440

35-
if [ "$installed_version" != "$requested_version" ]; then
36-
echo "::error::The version of Kani installed was different than the one requested"
41+
if [ "$1" == "latest" ]; then
42+
# Cargo search returns version number as string. Force color off: the Rust
43+
# toolchain action exports CARGO_TERM_COLOR=always, and the escape codes it
44+
# adds would otherwise defeat the anchor below.
45+
requested_version=$(CARGO_TERM_COLOR=never cargo search kani-verifier | grep -m 1 "^kani-verifier " | awk '{print $3}' | tr -d '"')
46+
if [ -z "$requested_version" ]; then
47+
echo "::error::Could not determine the latest Kani version from \`cargo search\`"
3748
exit 1
3849
fi
50+
else
51+
requested_version=$1
52+
fi
53+
54+
if [ "$installed_version" != "$requested_version" ]; then
55+
echo "::error::The version of Kani installed ($installed_version) was different than the one requested ($requested_version)"
56+
exit 1
3957
fi

‎tests/cargo-kani/proptest-lib/.gitignore‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎tests/cargo-kani/proptest-lib/Cargo.toml‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎tests/cargo-kani/proptest-lib/src/lib.rs‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)