Skip to content

Commit 3852094

Browse files
authored
Merge pull request #25 from LebedevRI/miri
CI: add Miri
2 parents 2966aa4 + 45f241b commit 3852094

File tree

8 files changed

+217
-80
lines changed

8 files changed

+217
-80
lines changed

.github/workflows/CI-linux.yml

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ on:
4343
env:
4444
DEBIAN_FRONTEND: noninteractive
4545
RUSTFLAGS: "-Dwarnings"
46+
WITH_MIRI: ${{ inputs.rust-toolchain-name == 'nightly' && inputs.flavor == 'dev' && inputs.builder-target != 'riscv64' }}
4647
SRC_DIR: ${{ github.workspace }}/rawspeed.rs
4748
CODECOV_TOKEN_EXISTS: ${{ secrets.CODECOV_TOKEN != '' }}
4849
CODE_COVERAGE_SUPPORTED: ${{ inputs.flavor != 'RustFmt' && inputs.flavor != 'doc' && (inputs.target-os != 'windows' || inputs.rust-toolchain-abi == 'msvc') }}
@@ -61,6 +62,8 @@ jobs:
6162
timeout-minutes: 1
6263
run: |
6364
set -xe
65+
WITH_CODE_COVERAGE=${{ env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true') }}
66+
echo "WITH_CODE_COVERAGE=$(echo ${WITH_CODE_COVERAGE})" >> $GITHUB_ENV
6467
if [ "${{ inputs.builder-target }}" = "x86_64" ] \
6568
|| [ "${{ inputs.builder-target }}" = "aarch64" ] \
6669
|| [ "${{ inputs.builder-target }}" = "i686" ] \
@@ -271,32 +274,53 @@ jobs:
271274
eatmydata apt install ${{ env.PACKAGES }}
272275
eatmydata apt clean
273276
rm -rf /var/lib/apt/lists/*
274-
- name: Install Rust toolchain and targets
275-
timeout-minutes: 1
277+
- name: Install Rust toolchain and targets and crates
278+
timeout-minutes: 4
276279
run: |
277280
set -xe
281+
RUST_COMPONENTS=""
282+
RUST_CRATES=""
278283
eatmydata curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
279284
. "$HOME/.cargo/env"
280285
eatmydata rustup toolchain install ${{ inputs.rust-toolchain-name }} --allow-downgrade --profile minimal
281286
eatmydata rustup default ${{ inputs.rust-toolchain-name }}
282287
eatmydata rustup target add ${{ env.RUST_TARGET }}
283288
if [ "${{ inputs.flavor }}" = "RustFmt" ]; then
284-
eatmydata rustup component add rustfmt
289+
RUST_COMPONENTS="${RUST_COMPONENTS} \
290+
rustfmt \
291+
"
285292
elif [ "${{ inputs.flavor }}" = "doc" ]; then
286293
/bin/true
287294
elif [ "${{ inputs.flavor }}" = "dev" ] || [ "${{ inputs.flavor }}" = "release" ]; then
288-
eatmydata rustup component add clippy
295+
RUST_COMPONENTS="${RUST_COMPONENTS} \
296+
clippy \
297+
"
289298
else
290299
exit 1
291300
fi
292-
- name: Install necessary Rust packages for code coverage
293-
if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true')
294-
timeout-minutes: 2
295-
run: |
296-
set -xe
297-
. "$HOME/.cargo/env"
298-
eatmydata rustup component add llvm-tools-preview
299-
eatmydata cargo install cargo-llvm-cov
301+
if [ "${{ env.WITH_CODE_COVERAGE }}" = "true" ]; then
302+
RUST_COMPONENTS="${RUST_COMPONENTS} \
303+
llvm-tools-preview \
304+
"
305+
RUST_CRATES="${RUST_CRATES} \
306+
cargo-llvm-cov \
307+
"
308+
fi
309+
if [ "${{ env.WITH_MIRI }}" = "true" ]; then
310+
RUST_COMPONENTS="${RUST_COMPONENTS} \
311+
rust-src \
312+
miri \
313+
"
314+
RUST_CRATES="${RUST_CRATES} \
315+
cargo-nextest \
316+
"
317+
fi
318+
if [ "${RUST_COMPONENTS}" != "" ]; then
319+
eatmydata rustup component add ${RUST_COMPONENTS}
320+
fi
321+
if [ "${RUST_CRATES}" != "" ]; then
322+
eatmydata cargo install ${RUST_CRATES}
323+
fi
300324
- name: Fetch/Checkout msvc-wine git repo
301325
timeout-minutes: 1
302326
if: inputs.target-os == 'windows' && inputs.rust-toolchain-abi == 'msvc'
@@ -400,7 +424,7 @@ jobs:
400424
cargo test --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }}
401425
- name: Run tests to collect code coverage
402426
timeout-minutes: 2
403-
if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true')
427+
if: env.WITH_CODE_COVERAGE == 'true'
404428
env:
405429
RUSTFLAGS: "-C instrument-coverage"
406430
run: |
@@ -411,15 +435,15 @@ jobs:
411435
cargo llvm-cov --no-report --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }}
412436
- name: Aggregate code coverage
413437
timeout-minutes: 1
414-
if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true')
438+
if: env.WITH_CODE_COVERAGE == 'true'
415439
run: |
416440
set -xe
417441
. "$HOME/.cargo/env"
418442
cd "$SRC_DIR"
419443
cargo llvm-cov report --codecov --output-path $SRC_DIR/codecov.json --target ${{ env.RUST_TARGET }} --profile ${{ inputs.flavor }}
420444
- name: Upload coverage reports to Codecov
421445
timeout-minutes: 1
422-
if: env.CODE_COVERAGE_SUPPORTED == 'true' && (inputs.builder-host == inputs.builder-target || (env.ENDIANNESS == 'big' && inputs.builder-target != 's390x')) && (github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true')
446+
if: env.WITH_CODE_COVERAGE == 'true'
423447
uses: codecov/codecov-action@v5
424448
env:
425449
OS: ${{ inputs.os }}
@@ -435,6 +459,14 @@ jobs:
435459
files: ${{ env.SRC_DIR }}/codecov.json
436460
root_dir: ${{ env.SRC_DIR }}
437461
fail_ci_if_error: true
462+
- name: Run tests under Miri
463+
timeout-minutes: 10
464+
if: env.WITH_MIRI == 'true'
465+
run: |
466+
set -xe
467+
. "$HOME/.cargo/env"
468+
cd "$SRC_DIR"
469+
cargo miri nextest run --target ${{ env.RUST_TARGET }}
438470
- name: Build docs
439471
timeout-minutes: 1
440472
if: inputs.flavor == 'doc'

.github/workflows/CI-macOS.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ jobs:
3838
name: ${{ inputs.runs-on }}, XCode ${{ inputs.xcode-version }}, Rust ${{ inputs.rust-toolchain-name }}, profile ${{ inputs.flavor }}
3939
runs-on: ${{ inputs.runs-on }}
4040
steps:
41+
- name: Configure necessary env variables
42+
timeout-minutes: 1
43+
run: |
44+
set -xe
45+
WITH_CODE_COVERAGE=${{ github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true' }}
46+
echo "WITH_CODE_COVERAGE=$(echo ${WITH_CODE_COVERAGE})" >> $GITHUB_ENV
4147
- name: Fetch/Checkout RawSpeed.RS git repo
4248
timeout-minutes: 1
4349
uses: actions/checkout@v4
@@ -54,21 +60,29 @@ jobs:
5460
brew autoremove --quiet
5561
brew cleanup --quiet --prune=all
5662
- name: Install Rust
57-
timeout-minutes: 1
63+
timeout-minutes: 4
5864
run: |
5965
set -xe
6066
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
6167
rustup toolchain install ${{ inputs.rust-toolchain-name }} --allow-downgrade --profile minimal
6268
rustup default ${{ inputs.rust-toolchain-name }}
63-
rustup component add clippy
64-
- name: Install necessary packages for code coverage
65-
if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true'
66-
timeout-minutes: 3
67-
run: |
68-
set -xe
69-
. "$HOME/.cargo/env"
70-
rustup component add llvm-tools-preview
71-
cargo install cargo-llvm-cov
69+
RUST_COMPONENTS="${RUST_COMPONENTS} \
70+
clippy \
71+
"
72+
if [ "${{ env.WITH_CODE_COVERAGE }}" = "true" ]; then
73+
RUST_COMPONENTS="${RUST_COMPONENTS} \
74+
llvm-tools-preview \
75+
"
76+
RUST_CRATES="${RUST_CRATES} \
77+
cargo-llvm-cov \
78+
"
79+
fi
80+
if [ "${RUST_COMPONENTS}" != "" ]; then
81+
rustup component add ${RUST_COMPONENTS}
82+
fi
83+
if [ "${RUST_CRATES}" != "" ]; then
84+
cargo install ${RUST_CRATES}
85+
fi
7286
- name: Run cargo check
7387
timeout-minutes: 1
7488
run: |
@@ -99,7 +113,7 @@ jobs:
99113
cargo test --profile ${{ inputs.flavor }}
100114
- name: Run tests to collect code coverage
101115
timeout-minutes: 1
102-
if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true'
116+
if: env.WITH_CODE_COVERAGE == 'true'
103117
env:
104118
RUSTFLAGS: "-C instrument-coverage"
105119
run: |
@@ -110,15 +124,15 @@ jobs:
110124
cargo llvm-cov --no-report --profile ${{ inputs.flavor }}
111125
- name: Aggregate code coverage
112126
timeout-minutes: 1
113-
if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true'
127+
if: env.WITH_CODE_COVERAGE == 'true'
114128
run: |
115129
set -xe
116130
. "$HOME/.cargo/env"
117131
cd "$SRC_DIR"
118132
cargo llvm-cov report --codecov --output-path $SRC_DIR/codecov.json --profile ${{ inputs.flavor }}
119133
- name: Upload coverage reports to Codecov
120134
timeout-minutes: 1
121-
if: github.event_name == 'pull_request' || env.CODECOV_TOKEN_EXISTS == 'true'
135+
if: env.WITH_CODE_COVERAGE == 'true'
122136
uses: codecov/codecov-action@v5
123137
env:
124138
OS: ${{ inputs.os }}

0 commit comments

Comments
 (0)