: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ci): require proof in the flaky report (#96143)
Paul D'Ambra0e1e71c0dc6c
diff --git a/.github/scripts/weekly-flaky-report.mjs b/.github/scripts/weekly-flaky-report.mjsindex 0007d36650c3..26973470073b 100644--- a/.github/scripts/weekly-flaky-report.mjs+++ b/.github/scripts/weekly-flaky-report.mjs@@ -70,10 +70,13 @@ function endpointUrl(action, params = {}) {return url}+// The endpoint sorts master failures first, so PR-only rows fill the tail of the page. The+// PR-only filter runs after the fetch, so request the endpoint maximum to leave headroom for+// confirmed flakes with no master failure that rank below those rows.function flakyTestsUrl(runner) {return endpointUrl('flaky_tests', {date_from: '-7d',- limit: 100,+ limit: 200,repo: GITHUB_REPOSITORY,runner,})@@ -115,13 +118,17 @@ function selectReportCandidates(items, runner, toRepoPaths) {.join(', ')}`)}- return onMaster.slice(0, CANDIDATE_POOL)+ return onMaster}async function fetchCandidatePools(runners, toRepoPaths, fetchTests = fetchFlakyTests) {return Promise.all(runners.map(async (runner) => {const result = await fetchTests(runner)+ if (result.truncated) {+ // Rows past the page never reach the PR-only filter, so a full page is worth a trace.+ console.info(`${runner}: endpoint page is full at ${result.limit} rows; more tests qualified`)+ }return { runner, candidates: selectReportCandidates(result.items || [], runner, toRepoPaths) }}))@@ -235,9 +242,8 @@ 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.async function fetchTrunkQuarantined(runner, runHogql = hogql, enabled = TRUNK_UPLOADS_ON) {- const none = () => nullif (!enabled) {- return none+ return null}let rows = []try {@@ -247,7 +253,7 @@ async function fetchTrunkQuarantined(runner, runHogql = hogql, enabled = TRUNK_Urows = result.results || []} catch (err) {console.warn(`Trunk quarantine lookup failed — reporting without Trunk state: ${err.message}`)- return none+ return null}const byVariant = new Map()for (const [nodeid, quarantinedAt] of rows) {@@ -281,7 +287,7 @@ function quarantineStatusFor(trunkFor, masksCi = TRUNK_MASKS_CI) {if (quarantineFile && !item.failed_run_count) {return 'file'}- const trunk = trunkFor(item)+ const trunk = trunkFor?.(item)if (!trunk) {return null}@@ -356,8 +362,12 @@ async function buildRunnerReports() {return Promise.all(candidatePools.map(async ({ runner, candidates }) => {- const statusFor = quarantineStatusFor(await getTrunk(runner))- const queue = collapseClusters(candidates, statusFor)+ const trunkFor = await getTrunk(runner)+ const statusFor = quarantineStatusFor(trunkFor)+ const candidatesWithTrunkStatus = trunkFor+ ? candidates.filter((item) => item.classification !== 'suspected_regression' || trunkFor(item))+ : candidates+ const queue = collapseClusters(candidatesWithTrunkStatus.slice(0, CANDIDATE_POOL), statusFor)const extrasFor = await getEnrichment(runner, queue)return { runner, candidates: rankReportCandidates(queue, extrasFor), extrasFor, statusFor }})diff --git a/.github/scripts/weekly-flaky-report.test.mjs b/.github/scripts/weekly-flaky-report.test.mjsindex 607b31ce8f9b..02fcec41d49a 100644--- a/.github/scripts/weekly-flaky-report.test.mjs+++ b/.github/scripts/weekly-flaky-report.test.mjs@@ -30,7 +30,7 @@ describe('weekly flaky report', () => {assert.equal(pytestUrl.searchParams.get('runner'), 'pytest')assert.equal(jestUrl.searchParams.get('runner'), 'jest')assert.equal(jestUrl.searchParams.get('repo'), 'PostHog/posthog')- assert.equal(jestUrl.searchParams.get('limit'), '100')+ assert.equal(jestUrl.searchParams.get('limit'), '200')})it('builds a Slack table with supported cells and structured links', () => {@@ -110,27 +110,48 @@ describe('weekly flaky report', () => {})})- it('selects proved flakes for the requested runner', () => {+ it('selects on-master candidates for the requested runner', () => {const common = {failed_run_count: 4,failed_pr_count: 1,master_failed_run_count: 3,+ same_commit_recovery_run_count: 0,quarantined_failed_run_count: 0,}const items = [- { ...common, runner: 'pytest', selector: 'test_proved.py::test_proved', classification: 'confirmed_flake' },+ {+ ...common,+ runner: 'pytest',+ selector: 'test_proved.py::test_proved',+ classification: 'confirmed_flake',+ same_commit_recovery_run_count: 1,+ },{...common,runner: 'pytest',selector: 'test_burst.py::test_burst',classification: 'suspected_regression',},- { ...common, runner: 'jest', selector: 'test_report.ts', classification: 'confirmed_flake' },+ {+ ...common,+ runner: 'pytest',+ selector: 'test_pr_only.py::test_pr_only',+ classification: 'suspected_regression',+ failed_pr_count: 4,+ master_failed_run_count: 0,+ },+ {+ ...common,+ runner: 'jest',+ selector: 'test_report.ts',+ classification: 'confirmed_flake',+ same_commit_recovery_run_count: 1,+ },]assert.deepEqual(selectReportCandidates(items, 'pytest', onMasterResolver).map((candidate) => candidate.selector),- ['test_proved.py::test_proved']+ ['test_proved.py::test_proved', 'test_pr_only.py::test_pr_only'])assert.deepEqual(selectReportCandidates(items, 'jest', onMasterResolver).map((candidate) => candidate.selector),@@ -144,11 +165,16 @@ describe('weekly flaky report', () => {failed_run_count: 6,failed_pr_count: 3,master_failed_run_count: 0,+ same_commit_recovery_run_count: 0,quarantined_failed_run_count: 0,}const items = [{ ...common, runner: 'jest', selector: 'frontend/src/shared.test.tsx::shared flakes' },- { ...common, runner: 'jest', selector: 'products/new/frontend/Unmerged.test.tsx::Unmerged explains itself' },+ {+ ...common,+ runner: 'jest',+ selector: 'products/new/frontend/Unmerged.test.tsx::Unmerged explains itself',+ },]const toRepoPaths = (path) => (path === 'frontend/src/shared.test.tsx' ? [path] : [])@@ -180,6 +206,59 @@ describe('weekly flaky report', () => {)})+ it('filters unproved regressions after an available Trunk lookup', async () => {+ const common = {+ runner: 'pytest',+ classification: 'suspected_regression',+ failed_run_count: 6,+ failed_pr_count: 4,+ master_failed_run_count: 0,+ same_commit_recovery_run_count: 0,+ quarantined_failed_run_count: 0,+ }+ const plainRegressions = Array.from({ length: 40 }, (_, index) => ({+ ...common,+ selector: `${index < CLUSTER_MIN_TESTS ? 'shared.py' : `plain_${index}.py`}::test_${index}`,+ }))+ const trunked = { ...common, selector: 'trunked.py::test_trunked' }+ const confirmed = {+ ...common,+ selector: 'confirmed.py::test_confirmed',+ classification: 'confirmed_flake',+ same_commit_recovery_run_count: 1,+ }+ const fileQuarantined = {+ ...common,+ selector: 'quarantined.py::test_quarantined',+ classification: 'quarantined',+ failed_run_count: 0,+ failed_pr_count: 0,+ quarantined_failed_run_count: 2,+ }+ const master = { ...common, selector: 'master.py::test_master', master_failed_run_count: 1 }+ const getEnrichment = async () => () => ({ runsRescued: 0, evidence: [] })+ const candidatePools = await fetchCandidatePools(['pytest'], onMasterResolver, async () => ({+ items: [...plainRegressions, trunked, confirmed, fileQuarantined, master],+ }))+ const [{ candidates }] = await buildRunnerReports(+ candidatePools,+ getEnrichment,+ async () => (item) => (item === trunked ? { quarantinedAt: '2026-07-13T17:12:22.000Z' } : null)+ )++ assert.deepEqual(+ candidates.map((candidate) => candidate.selector),+ [trunked.selector, confirmed.selector, fileQuarantined.selector]+ )++ const [{ candidates: candidatesWithoutTrunk }] = await buildRunnerReports(+ [{ runner: 'pytest', candidates: [plainRegressions[0]] }],+ getEnrichment,+ async () => null+ )+ assert.deepEqual(candidatesWithoutTrunk, [plainRegressions[0]])+ })+it('ranks and limits each runner independently', async () => {const candidatePools = ['pytest', 'jest'].map((runner) => ({runner,@@ -274,28 +353,30 @@ describe('weekly flaky report', () => {])})- it('reports without Trunk state when uploads are off, the table is missing, or it is empty', async () => {- const item = { selector: 'posthog/test/test_example.py::test_report' }+ it('distinguishes unavailable Trunk data from an empty result', async () => {const cases = [{label: 'uploads off',enabled: false,+ available: false,runHogql: () => assert.fail('must not query Trunk while uploads are disabled'),},{label: 'table missing',enabled: true,+ available: false,runHogql: async () => {throw new Error('Unknown table trunkio.quarantinedtests')},},- { label: 'no rows', enabled: true, runHogql: async () => ({ results: [] }) },+ { label: 'no rows', enabled: true, available: true, runHogql: async () => ({ results: [] }) },]- for (const { label, enabled, runHogql } of cases) {+ for (const { label, enabled, available, runHogql } of cases) {const trunkFor = await fetchTrunkQuarantined('pytest', runHogql, enabled)- assert.equal(trunkFor(item), null, label)+ assert.equal(typeof trunkFor === 'function', available, label)+ assert.equal(trunkFor?.({ selector: 'posthog/test/test_example.py::test_report' }) ?? null, null, label)}})@@ -364,9 +445,20 @@ describe('weekly flaky report', () => {selector: `shared.py::test_${index}`,failed_run_count: index < 2 ? 0 : 2,quarantined_failed_run_count: index < 2 ? 3 : 0,+ same_commit_recovery_run_count: index < 2 ? 0 : 1,+ master_failed_run_count: 0,failed_pr_count: 1,}))- const trunked = { runner: 'pytest', selector: 'masked.py::test_masked', failed_run_count: 9 }+ const trunked = {+ runner: 'pytest',+ selector: 'masked.py::test_masked',+ classification: 'suspected_regression',+ failed_run_count: 9,+ failed_pr_count: 4,+ master_failed_run_count: 0,+ same_commit_recovery_run_count: 0,+ quarantined_failed_run_count: 0,+ }const [{ candidates, statusFor }] = await buildRunnerReports([{ runner: 'pytest', candidates: [...clustered, trunked] }],async () => () => ({ runsRescued: null, evidence: [] }),@@ -441,5 +533,4 @@ describe('weekly flaky report', () => {'2026-07-11T16:45:09.000Z')})-})