Skip to content

Conversation

@max-trunk
Copy link
Contributor

@max-trunk max-trunk commented Dec 19, 2025

TRUNK-17215

Caches the result of /getQuarantineConfig locally on disk with a TTL of 5 min, duration configurable via the TRUNK_QUARANTINED_TESTS_DISK_CACHE_TTL_SECS env var. This caching is only configured for MutTestReport, currently only utilized by the rspec plugin. This should help mitigate the number of network requests needed for customers who:

  • use rspec
  • have lots of flaky tests
  • have auto-quarantining enabled
  • invoke rspec several times throughout the same CI job run

Tested with a locally-built gem with these changes, observed correct cache hits & misses. Example cached results file:

$ ls -lah $TMPDIR/trunk-flaky-tests
total 8
drwxr-xr-x@   3 max  staff    96B Dec 22 09:43 .
drwx------@ 620 max  staff    19K Dec 22 09:43 ..
-rw-r--r--@   1 max  staff   183B Dec 22 09:42 quarantined_tests_bccbed3a-e594-5275-a9b3-1c3b040d33c5.json

$ cat $TMPDIR/trunk-flaky-tests/quarantined_tests_bccbed3a-e594-5275-a9b3-1c3b040d33c5.json
{"quarantined_tests":{"a4b59df6-259b-50cb-9833-89c75d7ed594":true,"e6ea1e71-92f7-5bbf-8c57-fdd265cc2dfb":true,"62666a86-c344-5933-a7f7-f37d2eefefef":true},"cached_at_secs":1766414558}

@trunk-io
Copy link

trunk-io bot commented Dec 19, 2025

😎 Merged successfully - details.

@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 83.95062% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.86%. Comparing base (1cbbb03) to head (c90d42a).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
test_report/src/report.rs 83.95% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   73.58%   73.86%   +0.28%     
==========================================
  Files          72       72              
  Lines       16460    16539      +79     
==========================================
+ Hits        12112    12217     +105     
+ Misses       4348     4322      -26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trunk-staging-io
Copy link

trunk-staging-io bot commented Dec 19, 2025

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@trunk-staging-io
Copy link

Static BadgeStatic BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
publish_test_report An assertion failed because the expected value was 4, but the actual value was 3. Logs ↗︎

View Full Report ↗︎Docs

@max-trunk max-trunk marked this pull request as ready for review December 22, 2025 15:52
Comment on lines 337 to 351
let cache_data = match fs::read_to_string(&cache_path) {
Ok(data) => data,
Err(err) => {
tracing::warn!("Failed to read quarantined tests cache file: {:?}", err);
return None;
}
};

let cache_entry: QuarantinedTestsDiskCacheEntry = match serde_json::from_str(&cache_data) {
Ok(entry) => entry,
Err(err) => {
tracing::warn!("Failed to parse quarantined tests cache file: {:?}", err);
return None;
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think this can be simplified by having it streamed directly from the reader

serde_json::from_reader(reader)

Comment on lines 418 to 432
// first check in-memory cache
if self.0.borrow().quarantined_tests.as_ref().is_some() {
// already fetched
return;
}

// then check disk cache
if let Some(quarantined_tests) =
self.load_quarantined_tests_from_disk_cache(&org_url_slug, &repo_url)
{
// update in-memory cache
self.0.borrow_mut().quarantined_tests = Some(quarantined_tests);
return;
}

// cache miss - make API call
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The comments feel self-explanatory and unnecessary.

@trunk-io
Copy link

trunk-io bot commented Dec 22, 2025

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@trunk-io trunk-io bot merged commit d9d4942 into main Dec 22, 2025
16 checks passed
cached_at_secs: now,
};

// create cache directory if it doesn't exist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is also unnecessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants