Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#421 from xieyuschen/iox2-60-suppor…
Browse files Browse the repository at this point in the history
…t-miri-test-in-ci

[eclipse-iceoryx#60] Integrate Miri in CI with an allow list
  • Loading branch information
orecham authored Oct 3, 2024
2 parents fe1fc38 + b04b534 commit 6f05b7b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/miri-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Miri

on:
push:
branches: [ main ]
pull_request:
branches: [ main, release* ]

jobs:
miri:
name: "Miri"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Miri
run: |
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: ./internal/scripts/ci_run_miri.sh
8 changes: 8 additions & 0 deletions .miri_allowlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .miri_allowlist use hash character to lead a comment
# each line will be treated as a valid relative path to enter and run 'cargo miri test',
# if it contains some changed files(added, copied and modified, deletion is excluded) in the PR.
#
# note that each line should end up with a newline character,
# otherwise the ci shell will skip the last line
iceoryx2-bb/testing
# this line is put here to ensure each file path contains a newline char, don't remove it
31 changes: 31 additions & 0 deletions internal/scripts/ci_run_miri.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache Software License 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
# which is available at https://opensource.org/licenses/MIT.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

filename=".miri_allowlist"
while IFS= read -r line; do
if [[ "$line" == \#* ]]; then
continue
fi

if echo "$ALL_CHANGED_FILES" | grep -q "$line"; then
cd "$line" || { echo "Failed to change directory to $line"; exit 1; }
echo "Run cargo miri test under: $(pwd)"
cargo miri test
if [ $? -ne 0 ]; then
echo "Error: cargo miri test failed."
exit 1
fi
cd -
else
echo "skip $line because the PR doesn't touch its files"
fi
done < "$filename"

0 comments on commit 6f05b7b

Please sign in to comment.