Skip to content

feat: flaky test detection from cached history#26

Merged
maximn merged 5 commits into
mainfrom
feat/flaky-test-detection-from-history
Apr 3, 2026
Merged

feat: flaky test detection from cached history#26
maximn merged 5 commits into
mainfrom
feat/flaky-test-detection-from-history

Conversation

@maximn
Copy link
Copy Markdown
Contributor

@maximn maximn commented Apr 2, 2026

Summary

Detects tests that inconsistently pass and fail across recent CI runs, flagging them as potentially flaky. Adds a "Potentially Flaky Tests" section to the CI summary and a compact warning line to PR comments.

Changes

  • Add FlakyTestInfo and FlakyDetectionResult types to src/history/types.ts
  • Add flaky-threshold input to action.yml (default: 2 flips, in last 10 runs)
  • Export buildTestKey from comparison.ts for reuse
  • Implement detectFlakyTests() as a pure function in src/history/flaky-detection.ts
    • Counts pass↔fail flips per test across a sliding window of entries
    • Skips skipped statuses; treats errored as failing
    • Sorts by flaky rate descending, then flip count as tiebreaker
  • Add renderFlakySection() to CI summary — table with test, suite, rate, flips, emoji timeline
  • Add renderFlakyCompact() to PR comments — compact ⚠️ N flaky tests: name1, name2 line
  • Wire into index.ts: requires ≥5 history entries; errors caught with core.debug()
  • 35 new tests, 463 total, 0 regressions

Test plan

  • CI summary shows "Potentially Flaky Tests" table when ≥5 runs and flips exceed threshold
  • PR comment shows compact flaky warning after testsChanged line
  • Setting flaky-threshold: 5 raises the bar so fewer tests are flagged
  • Fewer than 5 history entries → flaky section is omitted, debug log emitted
  • Flaky detection error does not fail the action

maximn added 2 commits April 2, 2026 23:14
Detects tests that inconsistently pass/fail across recent runs.
Adds a 'Potentially Flaky Tests' section to CI summary and a compact
warning line to PR comments. Requires >= 5 history entries; threshold
configurable via flaky-threshold input (default: 2 flips).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

maximn added 3 commits April 3, 2026 20:38
Replace bare parseInt with a dedicated parser that warns on invalid
inputs (non-integer, negative) and falls back to the default of 2.
Test names containing backticks or newlines would produce malformed
markdown. toInlineCode normalises newlines and uses a fence of n+1
backticks to safely wrap any content.
@maximn maximn merged commit 39e4cdb into main Apr 3, 2026
6 checks passed
@maximn maximn deleted the feat/flaky-test-detection-from-history branch April 3, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant