Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): make weekly flaky report informational (#84088)

Raúl Negrón-Oterof07cd6bfa491
diff --git a/.github/scripts/weekly-flaky-report.mjs b/.github/scripts/weekly-flaky-report.mjs
index 8a577bd2531f..cb70ac5fe667 100644
--- a/.github/scripts/weekly-flaky-report.mjs
+++ b/.github/scripts/weekly-flaky-report.mjs
@@ -233,7 +233,7 @@ const TRUNK_QUARANTINED_QUERY = `
)`
// Uploads off, a missing table, or a query error all degrade to a report without Trunk state,
-// never to a failed run or an empty table.
+// never to a failed run.
async function fetchTrunkQuarantined(runner, runHogql = hogql, enabled = TRUNK_UPLOADS_ON) {
const none = () => null
if (!enabled) {
@@ -261,40 +261,39 @@ async function fetchTrunkQuarantined(runner, runHogql = hogql, enabled = TRUNK_U
.find(Boolean) || null
}
-// One question for both systems: is this failure already suppressed, so the queue should not ask
-// anyone to act on it? Returns null while the test still fails CI.
+// One question for both systems: is this failure suppressed, and since when? Suppressed tests
+// stay in the table with their suppression labeled, so masked failures remain visible.
//
-// Trunk with masking off is the one case that is marked but not suppressed: Trunk called the test
-// flaky, CI still goes red on it, so it stays in the queue carrying a label.
-function testStatusFor(trunkFor, masksCi = TRUNK_MASKS_CI) {
+// Trunk with masking off is marked but not suppressed: Trunk called the test flaky, CI still goes
+// red on it, so it reads 'flagged' rather than a quarantine date.
+function quarantineStatusFor(trunkFor, masksCi = TRUNK_MASKS_CI) {
return (item) => {
+ // A cluster's bare file selector can never match a per-test quarantine, so the members'
+ // statuses are counted at collapse time and the row reports how many are suppressed.
+ if (item.cluster_size) {
+ return item.quarantined_member_count ? `${item.quarantined_member_count}/${item.cluster_size}` : null
+ }
// Both counts are seven-day aggregates and the endpoint counts a quarantined run
// separately from a failed one, so a park that ended inside the window leaves the
// quarantined count set while CI fails on the test again. The unquarantined failures
- // decide: with any of them the test is still red and still work.
+ // decide: with any of them the test is red again and not suppressed.
const quarantineFile = item.classification === 'quarantined' || item.quarantined_failed_run_count > 0
if (quarantineFile && !item.failed_run_count) {
- return { parked: true }
+ return 'file'
}
const trunk = trunkFor(item)
if (!trunk) {
return null
}
- return { parked: masksCi }
+ if (!masksCi) {
+ return 'flagged'
+ }
+ return (trunk.quarantinedAt || '').slice(0, 10) || 'yes'
}
}
-// Parked tests leave the queue: a suppressed failure does not fail CI, so nobody has to act on it.
-//
-// Dropping them has to precede clustering. A cluster's selector is a bare file path, which can
-// never match a test id, so collapsing first buries parked tests in a row that then ranks as if
-// CI still failed on them.
-function buildQueue(candidates, statusFor) {
- return collapseClusters(candidates.filter((item) => !statusFor(item)?.parked))
-}
-
// 5+ co-failing tests in one file are one shared-fixture incident, not N flakes.
-function collapseClusters(items) {
+function collapseClusters(items, statusFor) {
const byFile = new Map()
for (const item of items) {
const file = item.selector.split('::')[0]
@@ -310,7 +309,13 @@ function collapseClusters(items) {
runner: group[0].runner,
selector: file,
cluster_size: group.length,
+ // 'flagged' members still fail CI, so only real suppressions count toward the fraction.
+ quarantined_member_count: group.filter((item) => {
+ const status = statusFor(item)
+ return status && status !== 'flagged'
+ }).length,
failed_run_count: group.reduce((sum, item) => sum + item.failed_run_count, 0),
+ // Members' PR sets can overlap, so the max is the provable floor rather than a sum.
failed_pr_count: Math.max(...group.map((item) => item.failed_pr_count)),
quarantined_failed_run_count: 0,
})
@@ -321,6 +326,15 @@ function collapseClusters(items) {
return collapsed
}
+// A cluster's PR count is the max over members whose PR sets can overlap, so it is a
+// floor on the distinct PRs hit; the trailing + keeps it from reading as exact.
+function prCountCell(item) {
+ if (item.failed_pr_count == null) {
+ return '-'
+ }
+ return item.cluster_size ? `${item.failed_pr_count}+` : String(item.failed_pr_count)
+}
+
// Rescued runs first (the strongest per-test signal), clusters and the rest by volume.
function rankReportCandidates(items, extrasFor) {
return items
@@ -342,8 +356,8 @@ async function buildRunnerReports(
) {
return Promise.all(
candidatePools.map(async ({ runner, candidates }) => {
- const statusFor = testStatusFor(await getTrunk(runner))
- const queue = buildQueue(candidates, statusFor)
+ const statusFor = quarantineStatusFor(await getTrunk(runner))
+ const queue = collapseClusters(candidates, statusFor)
const extrasFor = await getEnrichment(runner, queue)
return { runner, candidates: rankReportCandidates(queue, extrasFor), extrasFor, statusFor }
})
@@ -360,9 +374,6 @@ function tableRows(items, ownerFor, extrasFor, statusFor = () => null) {
const testCell = repoPath
? linkedCell([{ url: `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/blob/master/${repoPath}`, text: name }])
: cell(name)
- // Anything parked has already left the table, so the only status a row can carry is
- // Trunk having flagged a test that still fails CI.
- const flagged = statusFor(item) ? ' (Trunk flagged)' : ''
const logLinks = evidence.map(({ runId, jobId }, index) => ({
url: `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${runId}${jobId ? `/job/${jobId}` : ''}`,
text: String(index + 1),
@@ -370,7 +381,9 @@ function tableRows(items, ownerFor, extrasFor, statusFor = () => null) {
return [
testCell,
cell(RUNNER_LABELS[item.runner] || item.runner),
- cell(owner.replace(/^team-/, '') + flagged),
+ cell(owner.replace(/^team-/, '')),
+ cell(statusFor(item) || '-'),
+ cell(prCountCell(item)),
cell(runsRescued == null ? '-' : String(runsRescued)),
cell(String(item.failed_run_count)),
logLinks.length > 0 ? linkedCell(logLinks) : cell('-'),
@@ -394,24 +407,26 @@ function buildBlocks(now, rows) {
{ align: 'left' },
{ align: 'left' },
{ align: 'left' },
+ { align: 'left' },
+ { align: 'right' },
{ align: 'right' },
{ align: 'right' },
{ align: 'left' },
],
rows: [
- [cell('test'), cell('runner'), cell('owner'), cell('rescued'), cell('fails'), cell('logs')],
+ [
+ cell('test'),
+ cell('runner'),
+ cell('owner'),
+ cell('quarantined'),
+ cell('PRs'),
+ cell('rescued'),
+ cell('fails'),
+ cell('logs'),
+ ],
...rows,
],
},
- {
- type: 'context',
- elements: [
- {
- type: 'mrkdwn',
- text: 'Fix: `/fixing-flaky-tests` · Park 14 days: `hogli test:quarantine add <test id>`',
- },
- ],
- },
]
const editBlock = editWorkflowBlock()
if (editBlock) {
@@ -459,7 +474,6 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
export {
buildBlocks,
- buildQueue,
buildRunnerReports,
CLUSTER_MIN_TESTS,
enrich,
@@ -467,8 +481,8 @@ export {
fetchCandidatePools,
fetchTrunkQuarantined,
flakyTestsUrl,
+ quarantineStatusFor,
REPORT_RUNNERS,
selectReportCandidates,
tableRows,
- testStatusFor,
}
diff --git a/.github/scripts/weekly-flaky-report.test.mjs b/.github/scripts/weekly-flaky-report.test.mjs
index c896a37a2a31..9c14cf306967 100644
--- a/.github/scripts/weekly-flaky-report.test.mjs
+++ b/.github/scripts/weekly-flaky-report.test.mjs
@@ -3,7 +3,6 @@ import { describe, it } from 'node:test'
import {
buildBlocks,
- buildQueue,
buildRunnerReports,
CLUSTER_MIN_TESTS,
enrich,
@@ -11,10 +10,10 @@ import {
fetchCandidatePools,
fetchTrunkQuarantined,
flakyTestsUrl,
+ quarantineStatusFor,
REPORT_RUNNERS,
selectReportCandidates,
tableRows,
- testStatusFor,
} from './weekly-flaky-report.mjs'
import { repoPathResolver, trackedTestPaths } from './weekly-report-common.mjs'
@@ -41,6 +40,7 @@ describe('weekly flaky report', () => {
classification: 'confirmed_flake',
quarantined_failed_run_count: 0,
failed_run_count: 4,
+ failed_pr_count: 3,
},
],
() => ({ owner: 'team-devex', repoPath: 'posthog/test/test_example.py' }),
@@ -58,8 +58,12 @@ describe('weekly flaky report', () => {
assert.ok(table)
assert.deepEqual(
table.rows[0].map((tableCell) => tableCell.text),
- ['test', 'runner', 'owner', 'rescued', 'fails', 'logs']
+ ['test', 'runner', 'owner', 'quarantined', 'PRs', 'rescued', 'fails', 'logs']
)
+ // The edit-workflow context block may still render when Actions env vars are set;
+ // only the action footer has to be gone.
+ const contextText = JSON.stringify(blocks.filter((block) => block.type === 'context'))
+ assert.doesNotMatch(contextText, /fixing-flaky-tests|test:quarantine/)
for (const tableCell of table.rows.flat()) {
assert.ok(['raw_text', 'raw_number', 'rich_text'].includes(tableCell.type))
}
@@ -79,7 +83,9 @@ describe('weekly flaky report', () => {
],
})
assert.deepEqual(rows[0][1], { type: 'raw_text', text: 'pytest' })
- assert.deepEqual(rows[0][5], {
+ assert.deepEqual(rows[0][3], { type: 'raw_text', text: '-' })
+ assert.deepEqual(rows[0][4], { type: 'raw_text', text: '3' })
+ assert.deepEqual(rows[0][7], {
type: 'rich_text',
elements: [
{
@@ -245,8 +251,8 @@ describe('weekly flaky report', () => {
assert.equal(enrichmentRequested, false)
assert.deepEqual(row[1], { type: 'raw_text', text: 'Jest' })
- assert.deepEqual(row[3], { type: 'raw_text', text: '-' })
assert.deepEqual(row[5], { type: 'raw_text', text: '-' })
+ assert.deepEqual(row[7], { type: 'raw_text', text: '-' })
})
it('scopes enrichment to the current repository', async () => {
@@ -312,7 +318,7 @@ describe('weekly flaky report', () => {
assert.equal(trunkFor({ selector: 'backend/tests/test_migration.py::MigrationTest::test_other' }), null)
})
- it('drops both quarantine systems from the queue, but keeps a Trunk flag that still fails CI', () => {
+ it('labels how each quarantine system suppresses a test instead of dropping it', () => {
const quarantineFile = { runner: 'pytest', selector: 'file.py::test_file', classification: 'quarantined' }
// Quarantined earlier in the window, un-quarantined since, and failing on its own now.
const unparked = {
@@ -323,41 +329,67 @@ describe('weekly flaky report', () => {
failed_run_count: 4,
}
const trunked = { runner: 'pytest', selector: 'masked.py::test_masked', failed_run_count: 9 }
+ const undated = { runner: 'pytest', selector: 'undated.py::test_undated', failed_run_count: 2 }
const plain = { runner: 'pytest', selector: 'plain.py::test_plain', failed_run_count: 1 }
- const items = [quarantineFile, unparked, trunked, plain]
+ const items = [quarantineFile, unparked, trunked, undated, plain]
+ const trunkRows = new Map([
+ [trunked.selector, '2026-07-13T17:12:22.000Z'],
+ [undated.selector, null],
+ ])
const trunkFor = (item) =>
- item.selector === trunked.selector ? { quarantinedAt: '2026-07-13T17:12:22.000Z' } : null
- const selectors = (list) => list.map((item) => item.selector)
-
- const masked = buildQueue(items, testStatusFor(trunkFor, true))
- const unmasked = buildQueue(items, testStatusFor(trunkFor, false))
-
- assert.deepEqual(selectors(masked), [unparked.selector, plain.selector])
- // Masking off leaves Trunk's failure reddening CI, so only the quarantine file parks.
- assert.deepEqual(selectors(unmasked), [unparked.selector, trunked.selector, plain.selector])
- const [ownerCell] = tableRows(
- [trunked],
- () => ({ owner: 'team-devex', repoPath: null }),
- () => ({ runsRescued: null, evidence: [] }),
- testStatusFor(trunkFor, false)
- ).map((row) => row[2])
- assert.equal(ownerCell.text, 'devex (Trunk flagged)')
+ trunkRows.has(item.selector) ? { quarantinedAt: trunkRows.get(item.selector) } : null
+
+ const cells = (masksCi) =>
+ tableRows(
+ items,
+ () => ({ owner: 'team-devex', repoPath: null }),
+ () => ({ runsRescued: null, evidence: [] }),
+ quarantineStatusFor(trunkFor, masksCi)
+ ).map((row) => row[3].text)
+
+ assert.deepEqual(cells(true), ['file', '-', '2026-07-13', 'yes', '-'])
+ // Masking off leaves Trunk's failure reddening CI, so the date would overclaim.
+ assert.deepEqual(cells(false), ['file', '-', 'flagged', 'flagged', '-'])
})
- it('parks a quarantined test that would otherwise be buried in a collapsed cluster', () => {
- // A cluster's selector is a bare file path, so it can never match a test id.
- const items = Array.from({ length: CLUSTER_MIN_TESTS }, (_, index) => ({
+ it('keeps a Trunk-quarantined test in the report and counts suppressed cluster members', async () => {
+ const clustered = Array.from({ length: CLUSTER_MIN_TESTS }, (_, index) => ({
runner: 'pytest',
+ // Two members parked via the quarantine file: suppressed whichever way TRUNK_* masking
+ // resolves, so the count holds without pinning the env. A Trunk-marked member with
+ // masking off is only 'flagged' and must not count as suppressed.
+ classification: index < 2 ? 'quarantined' : 'confirmed_flake',
selector: `shared.py::test_${index}`,
- failed_run_count: 2,
+ failed_run_count: index < 2 ? 0 : 2,
+ quarantined_failed_run_count: index < 2 ? 3 : 0,
+ failed_pr_count: 1,
}))
-
- const queue = buildQueue(
- items,
- testStatusFor(() => ({ quarantinedAt: '2026-07-13T17:12:22.000Z' }), true)
+ const trunked = { runner: 'pytest', selector: 'masked.py::test_masked', failed_run_count: 9 }
+ const [{ candidates, statusFor }] = await buildRunnerReports(
+ [{ runner: 'pytest', candidates: [...clustered, trunked] }],
+ async () => () => ({ runsRescued: null, evidence: [] }),
+ async () => (item) =>
+ item.selector === trunked.selector ? { quarantinedAt: '2026-07-13T17:12:22.000Z' } : null
)
- assert.deepEqual(queue, [])
+ assert.deepEqual(
+ candidates.map((candidate) => [candidate.selector, candidate.failed_run_count]),
+ [
+ ['masked.py::test_masked', 9],
+ ['shared.py', 6],
+ ]
+ )
+ assert.equal(statusFor(candidates[1]), `2/${CLUSTER_MIN_TESTS}`)
+ // Truthy either way TRUNK_* masking resolves, so this holds without pinning the env.
+ assert.ok(statusFor(trunked))
+ const [clusterRow] = tableRows(
+ [candidates[1]],
+ () => ({ owner: 'team-devex', repoPath: null }),
+ () => ({ runsRescued: null, evidence: [] }),
+ statusFor
+ )
+ // The cluster PR count is a floor over overlapping member sets, never an exact count.
+ assert.deepEqual(clusterRow[4], { type: 'raw_text', text: '1+' })
})
it('matches a Jest selector reported from the package root against Trunk', async () => {
diff --git a/.github/workflows/weekly-flaky-report.yml b/.github/workflows/weekly-flaky-report.yml
index 9d5468a4c2cc..3f2d71880026 100644
--- a/.github/workflows/weekly-flaky-report.yml
+++ b/.github/workflows/weekly-flaky-report.yml
@@ -72,7 +72,7 @@ jobs:
# Optional: override the source-prefixed runs table name.
ENG_ANALYTICS_RUNS_TABLE: ${{ vars.ENG_ANALYTICS_RUNS_TABLE }}
# The same switches the CI uploaders read, so the report can only claim a test is
- # masked when Trunk is actually masking it. Unset means no Trunk section at all.
+ # masked when Trunk is actually masking it. Unset means no Trunk state at all.
TRUNK_UPLOAD_ENABLED: ${{ vars.TRUNK_UPLOAD_ENABLED }}
TRUNK_QUARANTINE_ENABLED: ${{ vars.TRUNK_QUARANTINE_ENABLED }}
# Optional: override the source-prefixed Trunk quarantine table name.
diff --git a/products/engineering_analytics/README.md b/products/engineering_analytics/README.md
index 19a66d9d0558..02ec46ec95f6 100644
--- a/products/engineering_analytics/README.md
+++ b/products/engineering_analytics/README.md
@@ -82,7 +82,7 @@ graph LR
- Job-level CI: per-job duration, queue time, runner tier, and dollar cost ride `workflow_jobs` (webhook stream plus bounded backfill).
- One write surface: test quarantine. The UI files a tracking issue plus a PR against the repo's checked-in `.test_quarantine.json` through the team's GitHub App. Everything else is read-only.
-- The test-health view is an active work queue, not a failure-rate leaderboard: the main pytest and Jest suites emit failures and same-job re-run recovery evidence. Jest writes a small marker beside JUnit when quarantine tolerates a failure, so masking it does not erase the signal. Evidence is counted per CI run, a test is called flaky only where one commit was seen both failing and passing it, and every other failure ranks as an honest suspected regression by blast radius. Callers can filter by `runner` before ranking and limiting when they need a runner-specific queue. The weekly Slack report requests each runner separately and shows up to 10 pytest tests followed by up to 10 Jest tests. Logs-based rescue counts and links remain pytest-only.
+- The test-health view is an active work queue, not a failure-rate leaderboard: the main pytest and Jest suites emit failures and same-job re-run recovery evidence. Jest writes a small marker beside JUnit when quarantine tolerates a failure, so masking it does not erase the signal. Evidence is counted per CI run, a test is called flaky only where one commit was seen both failing and passing it, and every other failure ranks as an honest suspected regression by blast radius. Callers can filter by `runner` before ranking and limiting when they need a runner-specific queue. The weekly Slack report requests each runner separately and shows up to 10 pytest tests followed by up to 10 Jest tests; it is informational, so suppressed tests stay listed with their quarantine state. Logs-based rescue counts and links remain pytest-only.
- Access control: per-user warehouse RBAC at the source resolver, `engineering_analytics:read` scopes on tools, feature-flag gated.
## The goal: CI Signals for PostHog Desktop