: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
chore(ci): let tests-posthog own the ci report comment (#103123)
Raúl Negrón-Otero520f7bfab768
diff --git a/frontend/bin/ci-report/update-ci-report.mjs b/frontend/bin/ci-report/update-ci-report.mjsindex 83a245d3318b..0f33b2ca469d 100644--- a/frontend/bin/ci-report/update-ci-report.mjs+++ b/frontend/bin/ci-report/update-ci-report.mjs@@ -203,14 +203,18 @@ function sectionEquals(a, b) {return !!a && !!b && a.status === b.status && a.summary === b.summary && a.inner === b.inner}+// The logins behind the tokens that post the report: `github.token` on GitHub Actions and+// the tests-posthog app on Depot CI. Each writer must adopt a report the other started, or+// the PR gets a second report comment. A writer that moves to another token posts under a+// new login, which orphans every existing report comment until that login is listed here.+const REPORT_AUTHORS = new Set(['github-actions[bot]', 'tests-posthog[bot]'])+// Only the report comments this tooling wrote itself. The marker alone is not enough:// anyone can comment on a public-repo PR, and a human "Quote reply" of the report keeps// the marker inside `> ` prefixes — matching on substring would adopt, merge, or DELETE-// comments we do not own. The login is the identity behind the `github.token` the-// posting workflow steps pass — moving them to a custom app token changes the login and-// would orphan every existing report comment, so handle that transition here too.+// comments we do not own.export function isReportComment(comment) {- return comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(MARKER)+ return REPORT_AUTHORS.has(comment.user?.login) && comment.body?.startsWith(MARKER)}export async function deleteLegacyComments(prefixes, context = resolvePrContext('legacy comment cleanup')) {diff --git a/frontend/bin/ci-report/update-ci-report.test.ts b/frontend/bin/ci-report/update-ci-report.test.tsindex 206a71b80229..0830d19ef57d 100644--- a/frontend/bin/ci-report/update-ci-report.test.ts+++ b/frontend/bin/ci-report/update-ci-report.test.ts@@ -355,13 +355,20 @@ describe('ci-report section helper', () => {expect(get(sections, 'eager-graph').inner).toBe('EAGER')})- it('merges duplicate report comments into the oldest and deletes the rest', async () => {+ it('merges report comments from either CI identity into the oldest and deletes the rest', async () => {const github = fakeGitHub([- { body: renderComment(build([{ id: 'bundle-size', status: 'ok', summary: 'b', body: 'BUNDLE' }])) },- { body: renderComment(build([{ id: 'dist-size', status: 'info', summary: 'd', body: 'DIST' }])) },+ {+ body: renderComment(build([{ id: 'bundle-size', status: 'ok', summary: 'b', body: 'BUNDLE' }])),+ author: 'tests-posthog[bot]',+ },+ {+ body: renderComment(build([{ id: 'dist-size', status: 'info', summary: 'd', body: 'DIST' }])),+ author: 'github-actions[bot]',+ },])await postSection({ id: 'eager-graph', status: 'warn', summary: 'e', body: 'EAGER' }, opts)expect(github.comments).toHaveLength(1)+ expect(github.comments[0].author).toBe('tests-posthog[bot]')const sections = parseSections(github.comments[0].body)expect([...sections.keys()]).toEqual(['bundle-size', 'eager-graph', 'dist-size'])})