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): warn instead of failing CI on eager graph budget breaches (#66990)

Paul D'Ambrac3d4461ca40d
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index e6f4ffde1864..bb91bf24045c 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -423,7 +423,7 @@ jobs:
# The eager graph check runs in --report-only mode inside build:with-report
# (compressed-size-action runs that for the PR AND base builds — a failing
# base build must not abort the action for every open PR). These steps post
- # the sticky PR comment and enforce the budgets from the PR build's report,
+ # the sticky PR comment and warn on budget breaches from the PR build's report,
# which carries the checkout sha in its filename because the base build
# overwrites the plain one. After compressed-size-action the tree is on the
# BASE branch, so guard for the scripts' absence (also covers branches
@@ -439,11 +439,11 @@ jobs:
echo "Skipping eager graph comment — script not present on this checkout"
fi
- - name: Enforce eager graph budgets
+ - name: Check eager graph budgets (warn only)
if: always() && github.event_name == 'pull_request'
run: |
if [ ! -f frontend/bin/check-eager-graph.mjs ]; then
- echo "Skipping eager graph enforcement — script not present on this checkout"
+ echo "Skipping eager graph check — script not present on this checkout"
exit 0
fi
REPORT="frontend/eager-graph-report-${GITHUB_SHA}.json"
@@ -451,7 +451,7 @@ jobs:
REPORT="frontend/eager-graph-report.json"
fi
if [ ! -f "$REPORT" ]; then
- echo "Skipping eager graph enforcement — no report found (branch may predate the check)"
+ echo "Skipping eager graph check — no report found (branch may predate the check)"
exit 0
fi
node frontend/bin/check-eager-graph.mjs --assert-report "$REPORT"
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index c95af20928d7..1308a1fd82da 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -11,11 +11,12 @@ const metaPath = path.join(frontendDir, 'posthog-app-esbuild-meta.json')
// --report-only: record results without failing the build. Used by build:with-report
// because compressed-size-action runs that script for BOTH the PR build and the base
// build — a base-branch budget breach must not abort the action for every open PR.
-// Enforcement happens in the dedicated workflow step via --assert-report.
+// Budget breaches are surfaced as warnings in the dedicated workflow step via --assert-report.
const reportOnly = process.argv.includes('--report-only')
-// --assert-report <path>: skip measuring; read a previously written report and exit
-// non-zero if it records violations.
+// --assert-report <path>: skip measuring; read a previously written report and surface any
+// recorded violations as warnings (GitHub Actions annotations) without failing CI — the
+// bundle-size Signals scout tracks regressions from the PR comment, so the check informs.
const assertReportIndex = process.argv.indexOf('--assert-report')
// The eager graph is everything reachable from a root through STATIC imports only —
@@ -53,45 +54,61 @@ function fail(message) {
process.exitCode = 1
}
+function warnViolation(message) {
+ console.warn(`\n⚠️ ${message}`)
+ const encoded = message.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A')
+ // console.info (not console.log, which oxlint strips) writes to stdout, where GitHub Actions parses workflow commands.
+ console.info(`::warning title=Eager graph budget::${encoded}`)
+}
+
function assertReport(reportFilePath) {
if (!fs.existsSync(reportFilePath)) {
- fail(`Report not found at ${reportFilePath} — did the build run the check?`)
- return
+ warnViolation(`Report not found at ${reportFilePath} — did the build run the check?`)
+ return 1
}
const reportToAssert = JSON.parse(fs.readFileSync(reportFilePath, 'utf-8'))
- for (const message of reportToAssert.errors ?? []) {
- fail(message)
+ let violations = 0
+ const topLevelErrors = reportToAssert.errors ?? []
+ for (const message of topLevelErrors) {
+ warnViolation(message)
+ violations++
}
for (const r of reportToAssert.roots) {
if (r.overBudget) {
- fail(
+ warnViolation(
`Eager graph for '${r.root}' is ${formatMiB(r.bytes)}, over the ${formatMiB(r.budgetBytes)} budget.\n` +
`Largest files in the closure:\n` +
r.largest.map(({ file, bytes }) => ` ${formatMiB(bytes).padStart(9)} ${file}`).join('\n') +
`\nMake the offending import lazy (React.lazy / dynamic import()), or raise the budget in ` +
`frontend/bin/check-eager-graph.mjs as a conscious decision in this PR.`
)
+ violations++
}
for (const hit of r.forbiddenHits) {
- fail(
+ warnViolation(
`'${hit.module}' is statically reachable from '${r.root}' — it must stay behind a dynamic import.\n` +
`Import chain:\n ${hit.chain.join('\n -> ')}`
)
+ violations++
}
- if (!process.exitCode) {
+ if (topLevelErrors.length === 0 && !r.overBudget && r.forbiddenHits.length === 0) {
console.info(`✅ ${r.label}: ${formatMiB(r.bytes)} within ${formatMiB(r.budgetBytes)}`)
}
}
+ return violations
}
if (assertReportIndex !== -1) {
- assertReport(process.argv[assertReportIndex + 1])
- if (process.exitCode) {
- console.error('\nEager graph check failed — see above.')
+ const violations = assertReport(process.argv[assertReportIndex + 1])
+ if (violations) {
+ console.warn(
+ `\n⚠️ Eager graph check — ${violations} issue(s) above. Not failing CI: the bundle-size ` +
+ `Signals scout tracks eager-graph regressions from the PR comment. Trim the eager closure when you can.`
+ )
} else {
console.info('\nAll eager graph budgets respected.')
}
- process.exit(process.exitCode ?? 0)
+ process.exit(0)
}
function formatMiB(bytes) {