Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing CI #48

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1fe9f74
Decouple `kani` version from `kani-github-action` version
jaisnan Sep 6, 2023
13ad53c
Remove leftover `echo`
jaisnan Sep 6, 2023
bff8a97
Merge 'main'
jaisnan Sep 7, 2023
34a34e9
add test for `kani-version` parameter
jaisnan Sep 7, 2023
83d31b0
Swap run order to let latest version of kani run on subsequent CI jobs
jaisnan Sep 7, 2023
f025fdf
Add parameters to readme
jaisnan Sep 15, 2023
da35c83
Add tests to check for invalid versions
jaisnan Sep 15, 2023
a89f30c
Verify version number of Kani installed
jaisnan Sep 15, 2023
fbe9753
Fix readme
jaisnan Sep 15, 2023
561ecd2
Update readme
jaisnan Sep 15, 2023
60aafda
Update invalid version
jaisnan Sep 15, 2023
e68809b
Fix test string
jaisnan Sep 15, 2023
91bd80d
Update message
jaisnan Sep 15, 2023
94b8a46
Fix variable name
jaisnan Sep 15, 2023
a3d3f07
Fix error message parsing
jaisnan Sep 15, 2023
72396bb
Check against stderr
jaisnan Sep 15, 2023
60d2021
Use ids
jaisnan Sep 15, 2023
a58b4d4
try with stdout
jaisnan Sep 15, 2023
40e2e0a
debug steps
jaisnan Sep 15, 2023
efd219b
Store output in github env
jaisnan Sep 15, 2023
205f9d3
Add output
jaisnan Sep 15, 2023
f785b2b
Add debug info
jaisnan Sep 15, 2023
400ff98
Add echo for output
jaisnan Sep 15, 2023
a759f7f
remove whitespace
jaisnan Sep 15, 2023
2e7e278
Remove broken test
jaisnan Sep 15, 2023
7503eff
Test with debugging
jaisnan Sep 15, 2023
ed9b119
update output
jaisnan Sep 15, 2023
1e7a9b6
expand
jaisnan Sep 15, 2023
909c3ab
Update variable
jaisnan Sep 15, 2023
6069218
fix syntax
jaisnan Sep 15, 2023
f450511
checkout in the same step
jaisnan Sep 15, 2023
05be104
add error message
jaisnan Sep 15, 2023
5d13acd
Update action
jaisnan Sep 15, 2023
4e459cf
test without GITHUB_ACTION
jaisnan Sep 15, 2023
6b67c24
check error.log
jaisnan Sep 15, 2023
467b1ef
Fix formatting
jaisnan Sep 15, 2023
3c92bc9
test with set_error.outcome
jaisnan Sep 19, 2023
eeb2fc6
Fix test outcome
jaisnan Sep 19, 2023
4144544
Add continue_on_error
jaisnan Sep 19, 2023
8935f68
Add tests for other actions
jaisnan Sep 20, 2023
f678266
Check without whitespace
jaisnan Sep 20, 2023
dd5ef10
Check against exact pattern match
jaisnan Sep 20, 2023
df808c4
Fix awk
jaisnan Sep 20, 2023
3de9b2f
Remove inv-commas
jaisnan Sep 20, 2023
bbe8513
Better echo messages
jaisnan Sep 20, 2023
0faacc4
update using sed
jaisnan Sep 20, 2023
0f08fa0
test cargo search
jaisnan Sep 20, 2023
73755b9
test with regex
jaisnan Sep 20, 2023
f31b0d9
Add parsing for version
jaisnan Sep 20, 2023
032fe95
debug sed
jaisnan Sep 20, 2023
7fb51f3
Add grep check
jaisnan Sep 20, 2023
3fec533
add space
jaisnan Sep 20, 2023
5999136
remove grep
jaisnan Sep 20, 2023
0397c25
simple grep
jaisnan Sep 20, 2023
6c2619f
fix command
jaisnan Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,63 @@ jobs:
# you must check out the repository
- name: Checkout
uses: actions/checkout@v3
- name: Run Kani

- name: Run Kani with invalid version
id: set_error
uses: ./
with:
working-directory: tests/cargo-kani/simple-lib
kani-version: '0.1.10'
continue-on-error: true

- name: Check previous step outcome
id: get_error
run: |
# Check the outcome of "Run Kani with invalid version"
if [[ "${{ steps.set_error.outcome }}" == "failure" ]]; then
echo "Running Kani with invalid version "0.1.10" failed."
else
echo "::error::Running Kani with invalid version succeeded incorrectly or was skipped."
exit 1
fi

- name: Run Kani with older version
uses: ./ # Uses the action in the root directory
with:
working-directory: tests/cargo-kani/simple-lib
kani-version: '0.33.0'

- name: Test run Kani with older version
run: |
installed_version=$(kani --version | awk '{print $2}')
expected_version='0.33.0'

if [[ "$installed_version" == "$expected_version" ]]; then
echo "The installed version ($installed_version) matches the expected version ($expected_version)."
else
echo "::error::The installed version ($installed_version) does not match the expected version ($expected_version)."
exit 1
fi

- name: Run Kani with latest version
uses: ./ # Uses the action in the root directory
with:
working-directory: tests/cargo-kani/simple-lib

- name: Test run Kani with latest version
run: |
installed_version=$(kani --version | awk '{print $2}')
expected_version=$(cargo search kani-verifier | grep -m 1 "kani" | awk '{print $3}' | sed 's/"//g')

echo "version online is $(cargo search kani-verifier | grep -m 1 "kani" | awk '{print $3}' | sed 's/"//g')."

if [[ "$installed_version" == "$expected_version" ]]; then
echo "The installed version ($installed_version) matches the latest version ($expected_version)"
else
echo "::error::The installed version ($installed_version) does not match the latest version ($expected_version)."
exit 1
fi

- name: Test ProfProof within Kani Action
uses: ./
with:
Expand Down
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,65 @@

This repository provides a GitHub Action for running the [Kani Rust Verifier](https://github.com/model-checking/kani) in CI.

## GitHub Action Parameters

The following parameters can be used to configure and customize the behavior of this GitHub Action:

NOTE: All the fields provided are optional and have default behaviors when not specified.

`kani-version`

- **Description**: Specifies the Kani version number to use.
- **Default**: 'latest'
- **Usage**: You can provide a specific version of Kani to use. If omitted, the latest version will be installed and used.

`command`

- **Description**: Specifies the command to run Kani.
- **Default**: 'cargo-kani'
- **Usage**: You can set a custom command to run Kani. For example, this allows you to use a different binary or script for Kani, if needed.

`working-directory`

- **Description**: Specifies the directory in which Kani should be run.
- **Default**: '.'
- **Usage**: Kani will be executed within this directory.

`args`

- **Description**: Specifies additional arguments to pass to Kani.
- **Default**: ''
- **Usage**: You can provide any additional command-line arguments to Kani using this parameter. These arguments will be appended to the Kani command.

`enable-propproof`

- **Description**: Experimental feature that allows Kani to verify proptest harnesses using the PropProof feature.
- **Default**: false
- **Usage**: If set to `true`, Kani will enable the experimental PropProof feature for verifying proptest harnesses.

## Kani-version default behavior

Please note that since providing `kani-version` is optional, if the user doesn't provide the version, the action will install the latest version of `Kani` on `crates.io`.

## Example usage in a workflow YAML file:

Here is an example of a workflow YAML file for the Kani Github Action

```yaml
jobs:
kani:
runs-on: ubuntu-latest
steps:
- name: Run Kani
uses: model-checking/kani-github-action@v0.37
with:
kani-version: '0.35.0'
command: 'cargo-kani'
working-directory: './path/to/project'
args: '--tests'
enable-propproof: true
```

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
Expand All @@ -10,4 +69,3 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform

This code is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.

9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ branding:
color: 'orange'

inputs:
kani-version:
description: 'Kani Version number'
required: false
default: 'latest'
command:
description: 'Command to run.'
required: false
Expand All @@ -34,11 +38,8 @@ runs:
uses: dtolnay/rust-toolchain@stable

- name: Install Kani
run: ${{ github.action_path }}/src/install-kani.sh ${{ inputs.kani-version }}
shell: bash
run: |
export KANI_VERSION="0.36.0";
cargo install --version $KANI_VERSION --locked kani-verifier;
cargo-kani setup;

- name: Install PropProof
if: ${{ inputs.enable-propproof == 'true' }}
Expand Down
39 changes: 39 additions & 0 deletions src/install-kani.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT

# If version is latest, install directly from cargo
if [ "$1" == "latest" ]; then
cargo install --locked kani-verifier;
else
VERSION=$1
cargo install --version $VERSION --locked kani-verifier;
fi

# Check exit status for error handling
if [ $? -eq 0 ]; then
echo "Installed Kani $VERSION successfully"
else
echo "::error::Could not install Kani. Please check if the provided version is correct"
exit 1
fi

# Setup kani in ci
cargo-kani setup;

# Get the current installed version of kani and check it against the latest version
installed_version=$(kani --version | awk '{print $2}')

if [$? -eq 0]; then
if [ "$1" == "latest" ]; then
# Cargo search returns version number as string
requested_version=$(cargo search kani-verifier | grep -m 1 "^kani-verifier " | awk '{print $3}')
else
requested_version=$1
fi

if ["$installed_version" != "$requested_version"]; then
echo "::error::The version of Kani installed was different than the one requested"
exit 1
fi
fi
Loading