Add basic `miri` checks
We have a bit of `unsafe` code in the crates which should really be checked with `miri`. Thus this adds a basic CI check that automatically determines which crates need `miri` checking and checks them. It also makes sure to enable all target features so that SIMD code can be checked as well.
This commit is contained in:
parent
fb5971cc2b
commit
bd8ad1f5e2
|
@ -0,0 +1,33 @@
|
|||
--- # rust-bitcoin CI: If you edit this file please update README.md
|
||||
on: # yamllint disable-line rule:truthy
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'test-ci/**'
|
||||
pull_request:
|
||||
|
||||
name: Miri
|
||||
|
||||
jobs:
|
||||
Miri:
|
||||
name: Miri
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: "Checkout repo"
|
||||
uses: actions/checkout@v4
|
||||
- name: "Read nightly version"
|
||||
id: read_toolchain
|
||||
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
|
||||
- name: "Select toolchain"
|
||||
uses: dtolnay/rust-toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ steps.read_toolchain.outputs.nightly_version }}
|
||||
components: miri
|
||||
- name: "Setup miri"
|
||||
run: cargo miri setup
|
||||
- name: "Set dependencies"
|
||||
run: cp Cargo-recent.lock Cargo.lock
|
||||
- name: "Run test script"
|
||||
run: ./contrib/test-miri.sh
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euox pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
. contrib/test_vars.sh
|
||||
|
||||
target_features="$(rustc --print target-features | awk '{ if ($1 == "") { exit 0 } if (NR != 1 && $1 != "crt-static") { if (NR == 2) { printf "+%s", $1 } else { printf ",+%s", $1 } } }')"
|
||||
|
||||
for crate in $CRATES;
|
||||
do
|
||||
# The secp256k1 crate cannot be miri-checked because of FFI, so we have to exclude it
|
||||
if cargo tree --manifest-path "$crate/Cargo.toml" | grep -q secp256k1;
|
||||
then
|
||||
echo "$crate depends on secp256k1, skipping..." >&2
|
||||
continue
|
||||
fi
|
||||
# Running miri is expensive and not needed for crates that don't contain unsafe
|
||||
if RUSTFLAGS="-C target-feature=$target_features -F unsafe-code" cargo check -q --all-features --target x86_64-unknown-linux-gnu 2>/dev/null;
|
||||
then
|
||||
echo "No unsafe code in $crate, skipping..." >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
RUSTFLAGS="-C target-feature=$target_features" RUSTDOCFLAGS="-C target-feature=$target_features" MIRIFLAGS=-Zmiri-backtrace=full cargo miri test --manifest-path "$crate/Cargo.toml" --all-features --target x86_64-unknown-linux-gnu
|
||||
done
|
|
@ -1 +1 @@
|
|||
nightly-2024-09-04
|
||||
nightly-2024-09-07
|
||||
|
|
Loading…
Reference in New Issue