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 CI test for --use-local-toolchain #3074

Merged
merged 21 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e1b35d5
Add CI test for --use-local-toolchain
jaisnan Mar 13, 2024
5e216e6
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Mar 19, 2024
97ba4ce
Add --help, --version and standalone simple checks
jaisnan Mar 19, 2024
ba50497
Check the toolchains used in bundle and custom toolchain match, to av…
jaisnan Mar 20, 2024
cb1e555
Add test to use bundle's toolchain version.
jaisnan Mar 20, 2024
14c2c0b
Merge branch 'main' into add-ci-test-use-local-toolchain
jaisnan Mar 20, 2024
fadcf07
Fix yaml syntax
jaisnan Mar 20, 2024
5d1f9fd
Change to use kani-latest instead
jaisnan Mar 20, 2024
12698e1
Fix file path for rust rust-toolchain-version
jaisnan Mar 20, 2024
fb14238
add --use-local-bundle to complete setup
jaisnan Mar 20, 2024
79552e1
Add outputs from previous job
jaisnan Mar 20, 2024
e5c5489
Download bundle
jaisnan Mar 20, 2024
08cc1ac
Add test-local-toolchain to setup
jaisnan Mar 26, 2024
16196a8
Merge branch 'main' into add-ci-test-use-local-toolchain
jaisnan Mar 26, 2024
5d9322a
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Mar 26, 2024
e630a52
Fix custom toolchain dir
jaisnan Mar 26, 2024
109fc7f
Merge branch 'add-ci-test-use-local-toolchain' of https://github.com/…
jaisnan Mar 26, 2024
ca72c38
Add rustc version from bundle
jaisnan Mar 26, 2024
a9bf208
formatting
jaisnan Mar 26, 2024
efbe192
Test LocalBundle without re-installing
jaisnan Mar 26, 2024
eeb64c5
Try with tar and verifier
jaisnan Mar 26, 2024
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
78 changes: 78 additions & 0 deletions .github/workflows/check-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Job to check if the setup flow and associated flags are working as expected
#
# This will run everytime there's a change to main
name: Check Setup
on:
pull_request:
push:
branches:
- 'main'

jobs:
test-use-local-toolchain:
jaisnan marked this conversation as resolved.
Show resolved Hide resolved
name: TestLocalToolchain
strategy:
matrix:
os: [macos-13, ubuntu-20.04, ubuntu-22.04]
include:
- os: macos-13
rust_target: x86_64-apple-darwin
- os: ubuntu-20.04
rust_target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
rust_target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Kani
uses: actions/checkout@v4
with:
fetch-depth: '0'
submodules: 'true'

- name: Check download
run: |
ls -lh .

- name: Install from bundle
run: |
cargo install --locked --path .

- name: Extract nightly version date from rust-toolchain.toml
id: extract-date
run: |
DATE=$(grep 'channel' rust-toolchain.toml | cut -d '=' -f2 | tr -d ' "' | cut -d'-' -f2-)
echo "Nightly date: $DATE"
echo "DATE=$DATE" >> $GITHUB_ENV

- name: Remove installed Rust toolchain
run: rustup toolchain remove nightly-$DATE

- name: Create a custom toolchain directory
run: mkdir -p ${{ github.workspace }}/custom_toolchain

- name: Fetch the nightly tarball
run: |
echo "Downloading Rust toolchain from rust server."
curl --proto '=https' --tlsv1.2 -O https://static.rust-lang.org/dist/$DATE/rust-nightly-${{ matrix.rust_target }}.tar.gz
tar -xzf rust-nightly-${{ matrix.rust_target }}.tar.gz
./rust-nightly-${{ matrix.rust_target }}/install.sh --prefix=${{ github.workspace }}/custom_toolchain

- name: Ensure installation is correct
run: |
cargo kani setup --use-local-toolchain ${{ github.workspace }}/custom_toolchain/

- name: Ensure that the rustup toolchain is not present
run: ls -la ~/.rustup/toolchains/
jaisnan marked this conversation as resolved.
Show resolved Hide resolved

- name: Run tests
jaisnan marked this conversation as resolved.
Show resolved Hide resolved
run: |
ls ./tests/cargo-ui/
for dir in function multiple-harnesses verbose; do
>&2 echo "Running test $dir"
pushd ./tests/cargo-ui/$dir
jaisnan marked this conversation as resolved.
Show resolved Hide resolved
cargo kani
jaisnan marked this conversation as resolved.
Show resolved Hide resolved
popd
done
6 changes: 5 additions & 1 deletion src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,22 @@ pub(crate) fn get_rust_toolchain_version(kani_dir: &Path) -> Result<String> {
fn setup_rust_toolchain(kani_dir: &Path, use_local_toolchain: Option<OsString>) -> Result<String> {
// Currently this means we require the bundle to have been unpacked first!
let toolchain_version = get_rust_toolchain_version(kani_dir)?;
println!("[3/5] Installing rust toolchain version: {}", &toolchain_version);

// Symlink to a local toolchain if the user explicitly requests
if let Some(local_toolchain_path) = use_local_toolchain {
let toolchain_path = Path::new(&local_toolchain_path);
// TODO: match the version against which kani was built
// Issue: https://github.com/model-checking/kani/issues/3060
symlink_rust_toolchain(toolchain_path, kani_dir)?;
println!(
"[3/5] Installing rust toolchain from path provided: {}",
&toolchain_path.to_string_lossy()
);
return Ok(toolchain_version);
}

// This is the default behaviour when no explicit path to a toolchain is mentioned
println!("[3/5] Installing rust toolchain version: {}", &toolchain_version);
Command::new("rustup").args(["toolchain", "install", &toolchain_version]).run()?;
let toolchain = home::rustup_home()?.join("toolchains").join(&toolchain_version);
symlink_rust_toolchain(&toolchain, kani_dir)?;
Expand Down
Loading