Skip to content

Commit 6f05b7b

Browse files
authored
Merge pull request #421 from xieyuschen/iox2-60-support-miri-test-in-ci
[#60] Integrate Miri in CI with an allow list
2 parents fe1fc38 + b04b534 commit 6f05b7b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

.github/workflows/miri-check.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Miri
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main, release* ]
8+
9+
jobs:
10+
miri:
11+
name: "Miri"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Install Miri
16+
run: |
17+
rustup toolchain install nightly --component miri
18+
rustup override set nightly
19+
cargo miri setup
20+
- name: Get changed files
21+
id: changed-files
22+
uses: tj-actions/changed-files@v45
23+
- name: List all changed files
24+
env:
25+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
26+
run: ./internal/scripts/ci_run_miri.sh

.miri_allowlist

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# .miri_allowlist use hash character to lead a comment
2+
# each line will be treated as a valid relative path to enter and run 'cargo miri test',
3+
# if it contains some changed files(added, copied and modified, deletion is excluded) in the PR.
4+
#
5+
# note that each line should end up with a newline character,
6+
# otherwise the ci shell will skip the last line
7+
iceoryx2-bb/testing
8+
# this line is put here to ensure each file path contains a newline char, don't remove it

internal/scripts/ci_run_miri.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
#
3+
# See the NOTICE file(s) distributed with this work for additional
4+
# information regarding copyright ownership.
5+
#
6+
# This program and the accompanying materials are made available under the
7+
# terms of the Apache Software License 2.0 which is available at
8+
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9+
# which is available at https://opensource.org/licenses/MIT.
10+
#
11+
# SPDX-License-Identifier: Apache-2.0 OR MIT
12+
13+
filename=".miri_allowlist"
14+
while IFS= read -r line; do
15+
if [[ "$line" == \#* ]]; then
16+
continue
17+
fi
18+
19+
if echo "$ALL_CHANGED_FILES" | grep -q "$line"; then
20+
cd "$line" || { echo "Failed to change directory to $line"; exit 1; }
21+
echo "Run cargo miri test under: $(pwd)"
22+
cargo miri test
23+
if [ $? -ne 0 ]; then
24+
echo "Error: cargo miri test failed."
25+
exit 1
26+
fi
27+
cd -
28+
else
29+
echo "skip $line because the PR doesn't touch its files"
30+
fi
31+
done < "$filename"

0 commit comments

Comments
 (0)