diff --git a/.github/workflows/cargo-llvm-cov.yml b/.github/workflows/cargo-llvm-cov.yml index 207c324bc8cab..6ae80aff0a986 100644 --- a/.github/workflows/cargo-llvm-cov.yml +++ b/.github/workflows/cargo-llvm-cov.yml @@ -60,20 +60,14 @@ jobs: uses: codecov/codecov-action@v3 with: files: lcov.info - fail_ci_if_error: true - - # TODO: Will enable this once we get this work - # - # - name: Run code coverage for simtest - # run: | - # ./scripts/simtest/install.sh - # CODECOV=1 ./scripts/simtest/cargo-simtest simtest - - # - name: Upload report to Codecov for simtest - # uses: codecov/codecov-action@v3 - # with: - # files: lcov.info - # fail_ci_if_error: true + + - name: Run code coverage for simtest + run: ./scripts/simtest/codecov.sh + + - name: Upload report to Codecov for simtest + uses: codecov/codecov-action@v3 + with: + files: lcov-simtest.info notify: name: Notify diff --git a/scripts/simtest/cargo-simtest b/scripts/simtest/cargo-simtest index 3f7511963272d..f8f44c6c87b10 100755 --- a/scripts/simtest/cargo-simtest +++ b/scripts/simtest/cargo-simtest @@ -93,10 +93,6 @@ if [ "$1" = "build" ]; then CARGO_COMMAND=(build --profile simulator) fi -if [ -n "$CODECOV" ]; then - CARGO_COMMAND=(llvm-cov --ignore-run-fail --lcov --output-path lcov.info nextest --cargo-profile simulator) -fi - # Must supply a new temp dir - the test is deterministic and can't choose one randomly itself. export TMPDIR=$(mktemp -d) diff --git a/scripts/simtest/codecov.sh b/scripts/simtest/codecov.sh new file mode 100755 index 0000000000000..afdd148855633 --- /dev/null +++ b/scripts/simtest/codecov.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e +# Copyright (c) Mysten Labs, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# verify that git repo is clean +if [[ -n $(git status -s) ]]; then + echo "Working directory is not clean. Please commit all changes before running this script." + exit 1 +fi + +# apply git patch +git apply ./scripts/simtest/config-patch + +MSIM_WATCHDOG_TIMEOUT_MS=60000 MSIM_TEST_SEED=1 cargo llvm-cov --ignore-run-fail --lcov --output-path lcov-simtest.info nextest --cargo-profile simulator + +# remove the patch +git checkout .cargo/config Cargo.toml Cargo.lock diff --git a/scripts/simtest/config-patch b/scripts/simtest/config-patch new file mode 100644 index 0000000000000..4fc2cf4ec1b4f --- /dev/null +++ b/scripts/simtest/config-patch @@ -0,0 +1,36 @@ +diff --git a/.cargo/config b/.cargo/config +index 7369a2afce..5254870044 100644 +--- a/.cargo/config ++++ b/.cargo/config +@@ -20,11 +20,11 @@ move-clippy = [ + "-Aclippy::upper_case_acronyms", + "-Aclippy::type_complexity", + # Remove after https://github.com/rust-lang/rust-clippy/pull/11792 is released. + "-Aclippy::map_identity", + "-Aclippy::new_without_default", + "-Aclippy::box_default", + "-Aclippy::manual_slice_size_calculation", + ] + + [build] +-rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"] ++rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes", "--cfg", "msim"] +diff --git a/Cargo.toml b/Cargo.toml +index 3b1ca4591c..e4ff4d61d2 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -672,10 +672,14 @@ semver = "1.0.16" + spinners = "4.1.0" + include_dir = "0.7.3" + + + # Using the workspace-hack via this patch directive means that it only applies + # while building within this workspace. If another workspace imports a crate + # from here via a git dependency, it will not have the workspace-hack applied + # to it. + [patch.crates-io.workspace-hack] + path = "crates/workspace-hack" ++ ++[patch.crates-io] ++tokio = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "1a52783d6600ecc22e15253a982f77881bd47c77" } ++futures-timer = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "1a52783d6600ecc22e15253a982f77881bd47c77" }