Add autoharness to run-kani script and use in CI #1676
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Kani | |
on: | |
workflow_dispatch: | |
merge_group: | |
pull_request: | |
branches: [ main ] | |
push: | |
paths: | |
- 'library/**' | |
- '.github/workflows/kani.yml' | |
- 'scripts/run-kani.sh' | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
check-kani-on-std: | |
name: Verify std library (partition ${{ matrix.partition }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
partition: [1, 2, 3, 4] | |
include: | |
- os: ubuntu-latest | |
base: ubuntu | |
- os: macos-latest | |
base: macos | |
fail-fast: false | |
env: | |
# Define the index of this particular worker [1-WORKER_TOTAL] | |
WORKER_INDEX: ${{ matrix.partition }} | |
# Total number of workers running this step | |
WORKER_TOTAL: 4 | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: head | |
submodules: true | |
# Step 2: Install jq | |
- name: Install jq | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get install -y jq | |
# Step 3: Run Kani on the std library (default configuration) | |
- name: Run Kani Verification | |
run: head/scripts/run-kani.sh --path ${{github.workspace}}/head | |
kani-autoharness: | |
name: Verify std library using autoharness | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
base: ubuntu | |
- os: macos-latest | |
base: macos | |
fail-fast: false | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
# Step 2: Run Kani autoharness on the std library for selected functions. | |
# Uses "--include-pattern" to make sure we do not try to run across all | |
# possible functions as that may take a lot longer than expected | |
- name: Run Kani Verification | |
run: | | |
scripts/run-kani.sh --run autoharness --kani-args \ | |
--include-pattern alloc::layout::Layout::from_size_align \ | |
--include-pattern ascii::ascii_char::AsciiChar::from_u8 \ | |
--include-pattern char::convert::from_u32_unchecked \ | |
--include-pattern "convert::num::<impl convert::From<num::nonzero::NonZero<" \ | |
--include-pattern "num::<impl i8>::unchecked_add" \ | |
--include-pattern "num::<impl i16>::unchecked_add" \ | |
--include-pattern "num::<impl i32>::unchecked_add" \ | |
--include-pattern "num::<impl i64>::unchecked_add" \ | |
--include-pattern "num::<impl i128>::unchecked_add" \ | |
--include-pattern "num::<impl isize>::unchecked_add" \ | |
--include-pattern "num::<impl u8>::unchecked_add" \ | |
--include-pattern "num::<impl u16>::unchecked_add" \ | |
--include-pattern "num::<impl u32>::unchecked_add" \ | |
--include-pattern "num::<impl u64>::unchecked_add" \ | |
--include-pattern "num::<impl u128>::unchecked_add" \ | |
--include-pattern "num::<impl usize>::unchecked_add" \ | |
--include-pattern "num::<impl i8>::unchecked_neg" \ | |
--include-pattern "num::<impl i16>::unchecked_neg" \ | |
--include-pattern "num::<impl i32>::unchecked_neg" \ | |
--include-pattern "num::<impl i64>::unchecked_neg" \ | |
--include-pattern "num::<impl i128>::unchecked_neg" \ | |
--include-pattern "num::<impl isize>::unchecked_neg" \ | |
--include-pattern "num::<impl i8>::unchecked_sh" \ | |
--include-pattern "num::<impl i16>::unchecked_sh" \ | |
--include-pattern "num::<impl i32>::unchecked_sh" \ | |
--include-pattern "num::<impl i64>::unchecked_sh" \ | |
--include-pattern "num::<impl i128>::unchecked_sh" \ | |
--include-pattern "num::<impl isize>::unchecked_sh" \ | |
--include-pattern "num::<impl u8>::unchecked_sh" \ | |
--include-pattern "num::<impl u16>::unchecked_sh" \ | |
--include-pattern "num::<impl u32>::unchecked_sh" \ | |
--include-pattern "num::<impl u64>::unchecked_sh" \ | |
--include-pattern "num::<impl u128>::unchecked_sh" \ | |
--include-pattern "num::<impl usize>::unchecked_sh" \ | |
--include-pattern "num::<impl i8>::unchecked_sub" \ | |
--include-pattern "num::<impl i16>::unchecked_sub" \ | |
--include-pattern "num::<impl i32>::unchecked_sub" \ | |
--include-pattern "num::<impl i64>::unchecked_sub" \ | |
--include-pattern "num::<impl i128>::unchecked_sub" \ | |
--include-pattern "num::<impl isize>::unchecked_sub" \ | |
--include-pattern "num::<impl u8>::unchecked_sub" \ | |
--include-pattern "num::<impl u16>::unchecked_sub" \ | |
--include-pattern "num::<impl u32>::unchecked_sub" \ | |
--include-pattern "num::<impl u64>::unchecked_sub" \ | |
--include-pattern "num::<impl u128>::unchecked_sub" \ | |
--include-pattern "num::<impl usize>::unchecked_sub" \ | |
--include-pattern "num::<impl i8>::wrapping_sh" \ | |
--include-pattern "num::<impl i16>::wrapping_sh" \ | |
--include-pattern "num::<impl i32>::wrapping_sh" \ | |
--include-pattern "num::<impl i64>::wrapping_sh" \ | |
--include-pattern "num::<impl i128>::wrapping_sh" \ | |
--include-pattern "num::<impl isize>::wrapping_sh" \ | |
--include-pattern "num::<impl u8>::wrapping_sh" \ | |
--include-pattern "num::<impl u16>::wrapping_sh" \ | |
--include-pattern "num::<impl u32>::wrapping_sh" \ | |
--include-pattern "num::<impl u64>::wrapping_sh" \ | |
--include-pattern "num::<impl u128>::wrapping_sh" \ | |
--include-pattern "num::<impl usize>::wrapping_sh" \ | |
--include-pattern "num::nonzero::NonZero::<i8>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<i16>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<i32>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<i64>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<i128>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<isize>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<u8>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<u16>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<u32>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<u64>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<u128>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<usize>::count_ones" \ | |
--include-pattern "num::nonzero::NonZero::<i8>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<i16>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<i32>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<i64>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<i128>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<isize>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<u8>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<u16>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<u32>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<u64>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<u128>::rotate_" \ | |
--include-pattern "num::nonzero::NonZero::<usize>::rotate_" \ | |
--include-pattern ptr::align_offset::mod_inv \ | |
--include-pattern ptr::alignment::Alignment::as_nonzero \ | |
--include-pattern ptr::alignment::Alignment::as_usize \ | |
--include-pattern ptr::alignment::Alignment::log2 \ | |
--include-pattern ptr::alignment::Alignment::mask \ | |
--include-pattern ptr::alignment::Alignment::new \ | |
--include-pattern ptr::alignment::Alignment::new_unchecked \ | |
--include-pattern time::Duration::from_micros \ | |
--include-pattern time::Duration::from_millis \ | |
--include-pattern time::Duration::from_nanos \ | |
--include-pattern time::Duration::from_secs \ | |
--exclude-pattern time::Duration::from_secs_f \ | |
--include-pattern unicode::unicode_data::conversions::to_ \ | |
--exclude-pattern ::precondition_check \ | |
--harness-timeout 5m \ | |
--default-unwind 1000 \ | |
--jobs=3 --output-format=terse | |
run-kani-list: | |
name: Kani List | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: head | |
submodules: true | |
# Step 2: Run list on the std library | |
- name: Run Kani List | |
run: | | |
head/scripts/run-kani.sh --run list --with-autoharness --path ${{github.workspace}}/head | |
# remove duplicate white space to reduce file size (GitHub permits at | |
# most one 1MB) | |
ls -l ${{github.workspace}}/head/kani-list.md | |
perl -p -i -e 's/ +/ /g' ${{github.workspace}}/head/kani-list.md | |
ls -l ${{github.workspace}}/head/kani-list.md | |
# Step 3: Add output to job summary | |
- name: Add Kani List output to job summary | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const kaniOutput = fs.readFileSync('${{github.workspace}}/head/kani-list.md', 'utf8'); | |
await core.summary | |
.addHeading('Kani List Output', 2) | |
.addRaw(kaniOutput, false) | |
.write(); |