Files
insights/frontend/bin/ci-report/delete-legacy-comments.mjs
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

51 lines
2.1 KiB
JavaScript

#!/usr/bin/env node
import { gh, listPrComments, resolvePrContext } from './update-ci-report.mjs'
// The CI checks used to each post their own PR comment. They now share one
// ci-report comment, so delete any leftover standalone comments once, on the first
// consolidated run, to stop a PR from showing both. Transitional — safe to remove
// after all open PRs have re-run. Matching is bot-author + body prefix, so the
// unmarked comments are identified by the fixed text they always started with.
const LEGACY_MARKERS = [
'<!-- insights-eager-graph-check -->',
'<!-- insights-bundle-size-check -->',
'<!-- mcp-ui-apps-size-report -->',
'<!-- playwright-report-comment -->',
'<!-- ch-migration-sql -->',
'## 🧠 AI eval results',
'It looks like the code of ',
'### 📄 Generated Docs Update Required',
'### 📦 Surveys SDK Version Check Reminder',
'<!-- hobby-smoke-test -->',
'<!-- hobby-ci-comment -->',
'[docs-preview]:',
'## Migration SQL Changes',
'## 🔍 Migration Risk Analysis',
]
const context = resolvePrContext('cleanup')
if (!context) {
process.exit(0)
}
const { token, repo, prNumber } = context
try {
// Same ownership rule as isReportComment in update-ci-report.mjs: every legacy
// check posted its marker as the first line under the workflow token's identity,
// and matching on substring alone would let a human comment that quotes or pastes
// a marker be deleted by CI.
const stale = (await listPrComments(context)).filter(
(c) => c.user?.login === 'github-actions[bot]' && LEGACY_MARKERS.some((marker) => c.body?.startsWith(marker))
)
for (const comment of stale) {
await gh(token, `/repos/${repo}/issues/comments/${comment.id}`, { method: 'DELETE' })
console.info(`Deleted legacy CI comment ${comment.id} on PR #${prNumber}.`)
}
if (!stale.length) {
console.info('No legacy CI comments to delete.')
}
} catch (err) {
// Fork PRs run with a read-only token — cleanup is best-effort, never worth a red job.
console.warn(`Could not clean up legacy CI comments (read-only token on fork PRs?): ${err.message}`)
}