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

Add script to automate build & running kani #78

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

jaisnan
Copy link

@jaisnan jaisnan commented Sep 6, 2024

  1. Adds a one-click command to pull, build and run kani
  2. Adds a toml file to store the commit info about the HEAD of kani/features/verify-std
  3. Checks for caching to prevent re-pulling, and building already compatible kani binary
  4. Modifies CI to re-use this script instead of the previous script
  5. Add --kani-args to pass arguments to kani command. -p sets the working directory.
  6. Adds a CI job to test the entrypoint workflow itself.
  7. Default output-format to terse

Extras

Cleans up some print statements in the run_update_with_checks script.

Call-out

  1. This does not allow command configuration, so it essentially all proofs in the library by default, which CAN get expensive. I can very easily add a harness filter to ensure that we can process only relevent harnesses.
  2. Need to change documentation to use this command instead of using kani directly as is currently suggested.
  3. Need to consider move to python, argument parsing with bash is a bad experience.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@jaisnan jaisnan requested a review from a team as a code owner September 6, 2024 19:11
@jaisnan jaisnan changed the title Add script to automate build Add script to automate build & running kani Sep 6, 2024
Copy link

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jai

run-kani.sh Outdated Show resolved Hide resolved
.github/workflows/check_entrypoint.yml Outdated Show resolved Hide resolved
kani-version.toml Outdated Show resolved Hide resolved
run-kani.sh Outdated Show resolved Hide resolved
run-kani.sh Outdated Show resolved Hide resolved
.github/workflows/kani.yml Outdated Show resolved Hide resolved
.github/workflows/kani.yml Outdated Show resolved Hide resolved
@@ -35,4 +35,11 @@ jobs:
submodules: true

- name: Run Kani Script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be named "Test Kani Script?"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this first step is in fact checking the standard library with Kani, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i shall separate the steps into test kani, following which I shall run kani on the standard library on the whole.

.github/workflows/kani.yml Outdated Show resolved Hide resolved
Comment on lines +43 to +44
- name: Run Kani Script without -p
working-directory: ${{github.workspace}}/head
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the testing of the script itself be done in a separate job?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd initially put it in a separate job, but merged it all into one based on this comment #78 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but given it's testing the script itself, shouldn't we have a workflow that doest just the script testing, and that workflow should only execute when any of the files relating to the script (the script itself plus toml files perhaps) change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, I wasn't saying they had to be merged in the same job. It just wasn't clear to me what each workflow was doing.

I would suggest that you test the script as a separate job of this workflow. But make it clear what each step is testing, so people are not confused. Maybe add some comments explaining what this is testing.

check_binary_exists() {
local build_dir="$1"
local expected_commit="$2"
local kani_path="$build_dir/scripts/kani"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using get_kani_path

main() {
local current_dir=$(pwd)
local build_dir="$WORK_DIR/kani_build"
local temp_dir_target=$(mktemp -d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this come with something like

cleanup()
{
  rm -rf "$temp_dir_target"
}

trap cleanup EXIT

?

"$kani_path" --version

echo "Running Kani verify-std command..."
cd $current_dir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary.



main() {
local current_dir=$(pwd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not not be needed.

cd $current_dir

# Run the command with the provided arguments (if any)
if [ -n "$command_args" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this branching is necessary, you can just use "$kani_path" verify-std -Z unstable-options ./library --target-dir "$temp_dir_target" -Z function-contracts -Z mem-predicates --output-format=terse $command_args either way as you are not using set -u.

Co-authored-by: Michael Tautschnig <mt@debian.org>
run: head/scripts/run-kani.sh --path ${{github.workspace}}/head

- name: Run Kani Script with --kani-args and -p
run: head/scripts/run-kani.sh -p ${{github.workspace}}/head --kani-args --harness ptr::verify::check_read_u128 --harness ptr::unique::verify::check_as_mut

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that you change the arguments to be something that doesn't depend on the harnesses configuration, or something very generic, like --harness ptr, which is less likely to be broken if we rename a harness.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are changing this file. Can you please rename line 19 (build) or give the workflow a nice name? 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants