Skip to content

Commit 7dc61e9

Browse files
authored
test: add miri testing (#8426)
* test: add miri testing * test: enable * fix: fix
1 parent 7c9e9f8 commit 7dc61e9

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.github/actions/rustup/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ inputs:
2121
default: false
2222
required: false
2323
type: boolean
24+
miri:
25+
default: false
26+
required: false
27+
type: boolean
2428
save-cache:
2529
default: false
2630
required: false
@@ -56,6 +60,11 @@ runs:
5660
shell: bash
5761
run: rustup set profile minimal
5862

63+
- name: Add Miri
64+
shell: bash
65+
if: ${{ inputs.miri == 'true' }}
66+
run: rustup component add miri
67+
5968
- name: Add Clippy
6069
shell: bash
6170
if: ${{ inputs.clippy == 'true' }}

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,35 @@ jobs:
320320
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
321321
run: cargo test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture
322322

323+
rust_test_miri:
324+
name: Rust test miri
325+
needs: [get-runner-labels, rust_changes]
326+
if: ${{ needs.rust_changes.outputs.changed == 'true' }}
327+
runs-on: ${{ fromJSON(needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS) }}
328+
steps:
329+
- uses: actions/checkout@v4
330+
331+
- name: Pnpm Cache # Required by some tests
332+
uses: ./.github/actions/pnpm-cache
333+
334+
- name: Install Rust Toolchain
335+
uses: ./.github/actions/rustup
336+
with:
337+
save-cache: ${{ github.ref_name == 'main' }}
338+
shared-key: check
339+
miri: true
340+
341+
# Compile test without debug info for reducing the CI cache size
342+
- name: Change profile.test
343+
shell: bash
344+
run: |
345+
echo '[profile.test]' >> Cargo.toml
346+
echo 'debug = false' >> Cargo.toml
347+
348+
- name: Run test
349+
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
350+
run: cargo miri test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture
351+
323352
run_benchmark:
324353
name: Run benchmark
325354
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rspack_allocator/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use mimalloc::MiMalloc;
2-
31
#[global_allocator]
4-
static GLOBAL: MiMalloc = MiMalloc;
2+
#[cfg(not(miri))]
3+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

0 commit comments

Comments
 (0)