diff --git a/.github/actions/rustup/action.yml b/.github/actions/rustup/action.yml index 61938acd149c..b2edc67fdb9f 100644 --- a/.github/actions/rustup/action.yml +++ b/.github/actions/rustup/action.yml @@ -21,6 +21,10 @@ inputs: default: false required: false type: boolean + miri: + default: false + required: false + type: boolean save-cache: default: false required: false @@ -56,6 +60,11 @@ runs: shell: bash run: rustup set profile minimal + - name: Add Miri + shell: bash + if: ${{ inputs.miri == 'true' }} + run: rustup component add miri + - name: Add Clippy shell: bash if: ${{ inputs.clippy == 'true' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48488dbbfa43..5cf9a240523f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -320,6 +320,35 @@ jobs: # reason for excluding https://github.com/napi-rs/napi-rs/issues/2200 run: cargo test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture + rust_test_miri: + name: Rust test miri + needs: [get-runner-labels, rust_changes] + if: ${{ needs.rust_changes.outputs.changed == 'true' }} + runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }} + steps: + - uses: actions/checkout@v4 + + - name: Pnpm Cache # Required by some tests + uses: ./.github/actions/pnpm-cache + + - name: Install Rust Toolchain + uses: ./.github/actions/rustup + with: + save-cache: ${{ github.ref_name == 'main' }} + shared-key: check + miri: true + + # Compile test without debug info for reducing the CI cache size + - name: Change profile.test + shell: bash + run: | + echo '[profile.test]' >> Cargo.toml + echo 'debug = false' >> Cargo.toml + + - name: Run test + # reason for excluding https://github.com/napi-rs/napi-rs/issues/2200 + run: cargo miri test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture + run_benchmark: name: Run benchmark runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index da1977327f5b..72db22658dbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2972,9 +2972,9 @@ checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" [[package]] name = "portable-atomic" -version = "1.3.3" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" diff --git a/crates/rspack_allocator/src/lib.rs b/crates/rspack_allocator/src/lib.rs index 272a4081a1bf..5d4205881355 100644 --- a/crates/rspack_allocator/src/lib.rs +++ b/crates/rspack_allocator/src/lib.rs @@ -1,4 +1,3 @@ -use mimalloc::MiMalloc; - #[global_allocator] -static GLOBAL: MiMalloc = MiMalloc; +#[cfg(not(miri))] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;