Files
insights/frontend/bin/post-bundle-size-comment.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

61 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
import { formatBytes, formatDelta, totalComparison } from './ci-report/format.mjs'
import { resolvePrAndBaseReport } from './ci-report/report-files.mjs'
import { postSection } from './ci-report/update-ci-report.mjs'
// A file whose size moves by less than this is treated as unchanged, matching the
// compressed-size-action `minimum-change-threshold: 1000` this replaces.
const MINIMUM_CHANGE_BYTES = 1000
const resolved = resolvePrAndBaseReport('bundle-size-report', 'bundle size')
if (!resolved) {
process.exit(0)
}
const { report, baseReport } = resolved
const baseBytes = Object.fromEntries((baseReport?.files ?? []).map((f) => [f.file, f.bytes]))
// Only diff per file when there is a baseline. Without one every file looks "new", which
// would flood the section with the whole manifest and make every delta a bogus increase.
const prFiles = new Map(report.files.map((f) => [f.file, f.bytes]))
const changed = []
if (baseReport) {
for (const identity of new Set([...prFiles.keys(), ...Object.keys(baseBytes)])) {
const prBytes = prFiles.get(identity)
const base = baseBytes[identity]
const delta = (prBytes ?? 0) - (base ?? 0)
if (Math.abs(delta) >= MINIMUM_CHANGE_BYTES) {
changed.push({ identity, prBytes, base, delta })
}
}
}
changed.sort((a, b) => Math.abs(b.delta) - Math.abs(a.delta))
const total = totalComparison(report.total, baseReport?.total ?? null)
const lines = [
'Uncompressed size of every built `.js` bundle, compared against the base branch.',
'',
total.totalLine,
'',
]
if (baseReport && changed.length) {
lines.push('| File | Size | Δ vs base |', '| --- | --- | --- |')
for (const { identity, prBytes, base } of changed) {
const size = prBytes === undefined ? '_removed_' : formatBytes(prBytes)
lines.push(`| \`${identity}\` | ${size} | ${formatDelta(prBytes ?? 0, base)} |`)
}
lines.push('')
} else if (baseReport) {
lines.push(`No file changed by more than ${formatBytes(MINIMUM_CHANGE_BYTES)}.`, '')
}
lines.push(
'<sub>Posted automatically by [build-bundle-size-report](https://github.com/Insights/insights/blob/master/frontend/bin/build-bundle-size-report.mjs) · uncompressed bytes from dist-report</sub>'
)
await postSection({
id: 'bundle-size',
status: total.status,
summary: total.summary,
body: lines.join('\n'),
})