Repository: duesee/imap-codec (language: rust)

Issue:
Review CI cache (due to potentially flaky coverage)



Discussion / hints:
For some context:
On #504, coverage failed with a somewhat strange behavior. While a locally generated report looked fine, the report on Coveralls looked rather strange.

Snippet from local report:
![local report](https://github.com/duesee/imap-codec/assets/33267536/30d1cdd5-4232-4099-ad00-ccff8ede53fd)
Snippet from Coveralls report:
![coveralls report snippet](https://github.com/duesee/imap-codec/assets/33267536/dd4345ef-2931-4c4e-b652-c2502b753011)

I have now run a debug test build archiving the generated coverage report from the runner to be downloaded for inspection.

As is seems, the issue is not related to Coveralls but happens when generating the report on the runner:
![snippet from runner report](https://github.com/duesee/imap-codec/assets/33267536/4a4b1a11-b353-4326-a784-b414471acf8e)

... and yes, when disabling the GitHub build cache, the issue is resolved. So disabling the cache (at least for the coverage job) seems to be one way to go.

I will continue to investigate this a bit further, maybe there is a better way to fix this ...


Fix patch:
diff --git a/justfile b/justfile
index dca1b845..f096477e 100644
--- a/justfile
+++ b/justfile
@@ -139,9 +139,9 @@ bench_against_main:
 
 # Measure test coverage
 coverage: install_rust_llvm_tools_preview install_cargo_grcov
-    mkdir -p target/coverage
-    # Remove old profiling information and coverage reports
-    rm -rf target/coverage/*
+    # Old build artifacts seem to be able to mess up coverage data (see #508),
+    # removing everything in `target` seems to be the easiest fix for this.
+    rm -rf target/*
     # Run instrumented tests to generate coverage information
     RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="$PWD/target/coverage/coverage-%m-%p.profraw" cargo test -p imap-codec -p imap-types --all-features
     # Generate coverage reports


Test patch: