Skip to content

Commit

Permalink
Adds miri to CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
akern40 committed Oct 24, 2024
1 parent 0a3cad3 commit 26abede
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ jobs:
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }}

miri:
runs-on: ubuntu-latest
name: miri
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toochain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
- name: Install openblas
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/miri-tests.sh

cross_test:
#if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions ndarray-rand/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn oversampling_without_replacement_should_panic()
}

quickcheck! {
#[cfg_attr(miri, ignore)] // Takes an insufferably long time
fn oversampling_with_replacement_is_fine(m: u8, n: u8) -> TestResult {
let (m, n) = (m as usize, n as usize);
let a = Array::random((m, n), Uniform::new(0., 2.));
Expand Down Expand Up @@ -84,6 +85,7 @@ quickcheck! {
}
}

#[cfg_attr(miri, ignore)]
#[cfg(feature = "quickcheck")]
quickcheck! {
fn sampling_behaves_as_expected(m: u8, n: u8, strategy: SamplingStrategy) -> TestResult {
Expand Down
21 changes: 21 additions & 0 deletions scripts/miri-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -x
set -e

# We rely on layout-dependent casts, which should be covered with #[repr(transparent)]
# This should catch if we missed that
RUSTFLAGS="-Zrandomize-layout"

# General tests
cargo miri test -v --no-default-features
cargo miri test -v -p ndarray -p ndarray-rand --lib --tests

# BLAS tests
cargo miri test -p ndarray --lib -v --features blas
cargo miri test -p blas-mock-tests -v
cargo miri test -p blas-tests -v --features blas-tests/openblas-system
cargo miri test -p numeric-tests -v --features numeric-tests/test_blas

# Examples
cargo miri test --examples

0 comments on commit 26abede

Please sign in to comment.