Skip to content

Commit

Permalink
no nightly, fixes, cleanup, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Nov 28, 2024
1 parent 9246ccc commit 8fd0834
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 37 deletions.
60 changes: 35 additions & 25 deletions .github/workflows/cargo_llvm_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,65 +46,75 @@ jobs:

- name: Install llvm-tools
run: |
TOOLCHAIN=nightly-x86_64-unknown-linux-gnu
TOOLCHAIN=$(rustup show active-toolchain | cut -d ' ' -f 1)
rustup component add llvm-tools --toolchain "$TOOLCHAIN"
LLVM_PROFDATA=$HOME/.rustup/toolchains/$TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata
echo "LLVM_PROFDATA=$LLVM_PROFDATA" >> $GITHUB_ENV
LLVM_PROFDATA="$HOME/.rustup/toolchains/$TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata"
if [ -x "$LLVM_PROFDATA" ]; then
$LLVM_PROFDATA --version
echo "LLVM_PROFDATA=$LLVM_PROFDATA" >> $GITHUB_ENV
else
echo "Error: llvm-profdata not found at $LLVM_PROFDATA or not executable."
echo "Error: llvm-profdata not found at $LLVM_PROFDATA, or is not executable."
exit 1
fi
- name: Run code coverage (nextest)
run: |
cargo +nightly llvm-cov clean --profraw-only
set +e
IOTA_SKIP_SIMTESTS=1 cargo +nightly llvm-cov \
--ignore-run-fail \
--no-report \
nextest -vv
echo "Scanning for corrupted .profraw files. This might take a while."
find target/llvm-cov-target -name '*.profraw' | while read file; do
if ! "$LLVM_PROFDATA" show "$file" > /dev/null 2>&1; then
echo "Removing corrupted file: $file"
rm "$file"
fi
done
IOTA_SKIP_SIMTESTS=1 cargo llvm-cov --ignore-run-fail --no-report nextest -vv
find target/llvm-cov-target -name '*.profraw' -print0 | xargs -0 $LLVM_PROFDATA merge \
--failure-mode=warn \
--sparse \
--output target/nextest.profdata
set -e
if [ $? -ne 0]; then
echo "Error detected despite `--ignore-run-fail`. Trying to salvage the situation:"
echo "Scanning for corrupted .profraw files. This might take a while."
find target/llvm-cov-target -name '*.profraw' | while read file; do
if ! "$LLVM_PROFDATA" show "$file" > /dev/null 2>&1; then
echo "$file: corruped -> removing"
rm "$file"
else
echo "$file: good"
fi
done
find target/llvm-cov-target -name '*.profraw' -print0 | xargs -0 $LLVM_PROFDATA merge \
--failure-mode=warn \
--sparse \
--output target/nextest.profdata
fi
[ -f "target/nextest.profdata" ] || exit 1
[ -s "target/nextest.profdata" ] || exit 1
- name: Run code coverage (simtest)
run: |
cargo +nightly llvm-cov clean --profraw-only
git clean -fd
set +e
./scripts/simtest/simtest-cov.sh
[ -f "target/simtest.profdata" ] || exit 1
set -e
if [ ! -s "target/simtest.profdata" ]; then
echo "🚨 Warning 🚨: Collecting simtest coverage failed."
exit 0
fi
- name: Create report (lcov.info)
run: |
cd target
if [ -f "simtest.profdata" ]; then
if [ -s "simtest.profdata" ]; then
$LLVM_PROFDATA merge --failure-mode=warn --sparse nextest.profdata simtest.profdata --output merged.profdata
else
mv nextest.profdata merged.profdata
fi
[ -f "merged.profdata" ] || exit 1
[ -s "merged.profdata" ] || exit 1
LLVM_PROFILE_FILE="merged.profdata" cargo +nightly llvm-cov report \
LLVM_PROFILE_FILE="merged.profdata" cargo llvm-cov report \
--lcov \
--output-path lcov.info \
--ignore-filename-regex 'external-crates/.*'
Expand Down
32 changes: 20 additions & 12 deletions scripts/simtest/simtest-cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,34 @@ git apply ./scripts/simtest/config-patch
root_dir=$(git rev-parse --show-toplevel)
export SIMTEST_STATIC_INIT_MOVE=$root_dir"/examples/move/basics"

TOOLCHAIN=nightly-x86_64-unknown-linux-gnu
TOOLCHAIN=$(rustup show active-toolchain | cut -d ' ' -f 1)
LLVM_PROFDATA="$HOME/.rustup/toolchains/$TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata"

MSIM_WATCHDOG_TIMEOUT_MS=60000 MSIM_TEST_SEED=1 cargo llvm-cov \
--ignore-run-fail \
--no-report \
MSIM_WATCHDOG_TIMEOUT_MS=60000 MSIM_TEST_SEED=1 cargo llvm-cov --ignore-run-fail --no-report \
nextest -vv --cargo-profile simulator

echo "Scanning for corrupted .profraw files. This might take a while."
find target/llvm-cov-target -name '*.profraw' | while read file; do
if ! "$LLVM_PROFDATA" show "$file" > /dev/null 2>&1; then
echo "Removing corrupted file: $file"
rm "$file"
fi
done

find target/llvm-cov-target -name '*.profraw' -print0 | xargs -0 $LLVM_PROFDATA merge \
--failure-mode=warn \
--sparse \
--output target/simtest.profdata

if [ $? -ne 0]; then
echo "Error detected despite `--ignore-run-fail`. Trying to salvage the situation:"
echo "Scanning for corrupted .profraw files. This might take a while."
find target/llvm-cov-target -name '*.profraw' | while read file; do
if ! "$LLVM_PROFDATA" show "$file" > /dev/null 2>&1; then
echo "$file: corruped -> removing"
rm "$file"
else
echo "$file: good"
fi
done

find target/llvm-cov-target -name '*.profraw' -print0 | xargs -0 $LLVM_PROFDATA merge \
--failure-mode=warn \
--sparse \
--output target/simtest.profdata
fi

# remove the patch
git checkout .cargo/config Cargo.toml Cargo.lock

0 comments on commit 8fd0834

Please sign in to comment.