From 0d34ba51918218d794abd22b7289091ec3880392 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 2 Oct 2024 08:55:23 +0200 Subject: [PATCH] ci: run tests with sanitizers on Linux and MacOS --- .github/workflows/check.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 490c7047c4..b9e1c237fa 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -45,7 +45,7 @@ jobs: - uses: ./.github/actions/rust with: version: ${{ matrix.rust-toolchain }} - components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools-preview' || '' }} + components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools-preview,' || '' }} ${{ matrix.rust-toolchain == 'nightly' && 'rust-src,' || '' }} tools: ${{ matrix.rust-toolchain == 'stable' && 'cargo-llvm-cov, ' || '' }} cargo-nextest token: ${{ secrets.GITHUB_TOKEN }} @@ -97,6 +97,24 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable' + - name: Run tests with sanitizers + if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.rust-toolchain == 'nightly' + env: + RUST_LOG: trace + run: | + if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then + TARGET="x86_64-unknown-linux-gnu" + SANITIZERS="address thread leak" + elif [ "${{ matrix.os }}" = "macos-latest" ]; then + TARGET="aarch64-apple-darwin" + # no leak sanitizer support yet + SANITIZERS="address thread" + fi + for sanitizer in $SANITIZERS; do + echo "Running tests with $sanitizer sanitizer..." + RUSTFLAGS="-Z sanitizer=$sanitizer" RUSTDOCFLAGS="-Z sanitizer=$sanitizer" cargo +nightly nextest run -Z build-std --target "$TARGET" + done + bench: needs: [check] uses: ./.github/workflows/bench.yml