Repository navigation
ci(frontend): track bundle size over time with benchmark-action - #42511
Conversation
|
The flagged issue is correct. In Here is the corrected implementation for the const results = [];
TRACKED_ENTRYPOINTS.forEach(name => {
const entrypoint = entrypoints[name];
if (!entrypoint) {
console.error(`Required entrypoint "${name}" missing from stats.json`);
process.exit(1);
}
results.push({
name: `${name} entrypoint (JS)`,
unit: 'bytes',
value: entrypointSizeByExt(entrypoint, '.js'),
});
results.push({
name: `${name} entrypoint (CSS)`,
unit: 'bytes',
value: entrypointSizeByExt(entrypoint, '.css'),
});
});Would you like me to check the other comments on this PR and implement fixes for them as well? superset-frontend/scripts/bundle-size-summary.js |
There was a problem hiding this comment.
Code Review Agent Run #75a90b
Actionable Suggestions - 1
-
superset-frontend/scripts/bundle-size-summary.js - 1
- Missing unit tests for new tool · Line 1-78
Review Details
-
Files reviewed - 2 · Commit Range:
987c5ad..987c5ad- superset-frontend/scripts/bundle-size-summary.js
- superset-frontend/webpack.config.js
-
Files skipped - 1
- .github/workflows/superset-frontend.yml - Reason: Filter setting
-
Tools
- Eslint (Linter) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #42511 +/- ##
==========================================
+ Coverage 57.30% 66.72% +9.41%
==========================================
Files 2872 2864 -8
Lines 163447 162924 -523
Branches 37727 37616 -111
==========================================
+ Hits 93664 108709 +15045
+ Misses 68894 52167 -16727
- Partials 889 2048 +1159
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review Agent Run #ea069aActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Actually there's a Codecov option to help tracking the bundle size. I'm not sure if there's any accompanying cost but if not then I think we can utilize such a readily available option. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Pushed two follow-up commits addressing review feedback: 1. Nightly baseline instead of every push to master. Persisting a new baseline on every push (many times a day) would burn a full production build each time for no benefit a once-daily refresh doesn't already cover. Moved baseline persistence to a new 2. Nightly bundle-analyzer report + visibility badges. The Netlify publish step is gated on |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds continuous frontend bundle-size tracking in CI by generating slim webpack stats, summarizing key entrypoints, and comparing PR builds against a nightly baseline with automated PR alerts.
Changes:
- Add env-gated webpack stats override to emit only assets/entrypoints for bundle-size measurement.
- Introduce a bundle-size summary script + Jest coverage to reduce stats into benchmark-action’s expected format.
- Add PR-time bundle-size comparison job and a nightly workflow to refresh the baseline and (optionally) publish bundle analyzer output.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| superset-frontend/webpack.config.js | Adds BUNDLE_SIZE_STATS-gated config.stats override to include asset/entrypoint sizes in --json output. |
| superset-frontend/scripts/bundle-size-summary.js | New reducer script that converts webpack stats into benchmark-action “customSmallerIsBetter” metrics. |
| superset-frontend/spec/scripts/bundle-size-summary.test.js | New Jest tests validating reducer behavior and error handling. |
| .github/workflows/superset-frontend.yml | Adds PR-only bundle-size job to build prod bundle, summarize sizes, and compare to cached nightly baseline with PR comments on regressions. |
| .github/workflows/frontend-bundle-size-nightly.yml | New nightly workflow to refresh baseline data in cache and optionally publish bundle analyzer report to Netlify. |
| README.md | Adds Storybook and Bundle Analyzer badges/links. |
|
| Language | Invalidated translations |
|---|---|
fr |
493 |
How to fix
1. Install dependencies (if not already set up):
pip install -r superset/translations/requirements.txt
sudo apt-get install gettext # or: brew install gettext2. Re-extract strings and sync .po files:
./scripts/translations/babel_update.shThis rewrites superset/translations/messages.pot from the current source files and merges the changes into every .po file. Strings whose msgid changed will be marked #, fuzzy.
3. Resolve the fuzzy entries in the affected language files (fr):
grep -n '#, fuzzy' superset/translations/<lang>/LC_MESSAGES/messages.poFor each fuzzy entry, either rewrite the msgstr to match the new string and remove the #, fuzzy line, or clear the msgstr to "" if you cannot provide a translation.
4. Commit your changes to the .po files.
Code Review Agent Run #b2a645Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
ccaf919 to
c592230
Compare
Code Review Agent Run #ffd956Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
hainenber
left a comment
There was a problem hiding this comment.
Codecov has JS bundle analysis feature. Should we utilize that?
Superset's frontend bundle size is a recurring complaint, but until now
there's been no ongoing visibility into it -- only periodic manual cleanup
efforts. This adds a `bundle-size` job to superset-frontend.yml that builds
the real production bundle (npm run build), reduces its per-entrypoint
sizes to a few headline numbers, and tracks them over time via
benchmark-action/github-action-benchmark, posting a PR comment when a
change regresses past 110% of the last recorded baseline.
Reuses the already-built CI Docker image (same image sharded-jest-tests /
lint-frontend / etc. already download), so the only new cost is the
production webpack build itself -- and that's cheap after the first run:
webpack's persistent filesystem cache (already configured in
webpack.config.js) makes warm rebuilds ~20s locally vs several minutes
cold, confirmed by hand against this repo's real build.
webpack.config.js gains a BUNDLE_SIZE_STATS env-gated stats override
(mirrors the existing BUNDLE_ANALYZER pattern). The default `stats:
'minimal'` omits per-asset sizes entirely; `--stats=normal` includes them
but also serializes the full ~15k-module dependency graph, producing a
560+MB stats.json for this app -- large enough to exceed Node's max
string length on a plain fs.readFileSync. The env-gated override requests
just `{ assets: true, entrypoints: true }`, verified end-to-end against a
minimal synthetic webpack project (same webpack/webpack-cli versions) and
against real stats pulled from this repo's actual production build.
History storage deliberately avoids the gh-pages branch (benchmark-action's
usual default) since that branch is the live Helm chart index published by
superset-helm-release.yml, not free real estate. Instead uses
external-data-json-path with actions/cache: restored on every run (PR or
push) so PRs get a same-baseline comparison and regression comment, but
only saved back to the cache on push to master, so an unmerged PR's numbers
never become the shared baseline. No gh-pages branch is touched in any
code path, and no PAT/GitHub App is needed -- comment-on-alert only needs
the default per-job GITHUB_TOKEN.
…ints Addresses review feedback: validate every tracked entrypoint is present in stats.json (fail instead of silently skipping) and add unit tests for the summary script. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…push Persisting a new baseline on every push to master (which happens many times a day) burns a full production build each time for no benefit a once-a-day refresh doesn't already cover -- a day-old baseline is fine for catching relative regressions on PRs. Moves baseline persistence to a new frontend-bundle-size-nightly.yml (schedule + workflow_dispatch), and restricts superset-frontend.yml's bundle-size job to pull_request only: compare-and-alert against the last nightly baseline, never persist. Also caches webpack's persistent filesystem build cache (superset-frontend/.temp_cache) across CI runs via actions/cache, keyed on the same files webpack's own `buildDependencies` invalidates on. Without this, every PR run would pay the full cold-build cost (several minutes) instead of the ~20s warm-build cost the cache is supposed to buy -- GH-hosted runners are fresh VMs with nothing carried over between jobs, so the cache has to be restored explicitly or it does nothing.
…nalyzer badges Two related visibility gaps, fixed together since both ride on the same nightly build: 1. superset-storybook.netlify.app has been live and populated with real, current component stories the whole time (Netlify's own git integration auto-builds and deploys it, no CI workflow involved) -- but there was no link to it anywhere in the repo. Added a README badge. 2. BUNDLE_ANALYZER=true npm run build has always produced a browsable treemap of what's actually in the bundle, but only ever locally, on request. Now rides along in the same nightly build that already refreshes the bundle-size baseline (BUNDLE_ANALYZER and BUNDLE_SIZE_STATS are independent env-gated additions to webpack.config.js, so one production build produces both), publishing the treemap (report.html) to Netlify -- the same host already trusted for Storybook and docs previews, reusing the existing NETLIFY_AUTH_TOKEN secret. Deliberately does not publish the sibling statistics.html sunburst chart: webpack.config.js documents it as routinely exceeding 100MB for this app (it's .gitignore'd for exactly that reason), too large for a static site page. The Netlify publish step is gated on NETLIFY_BUNDLE_ANALYZER_SITE_ID and no-ops until that secret exists -- safe to merge now. Turning it on just needs a new (free) Netlify site named superset-bundle-analyzer and its site ID added as that secret; nothing else in the workflow depends on it. The README badge points at that same URL in anticipation.
Correct the missing-entrypoints error message to point at the actual BUNDLE_SIZE_STATS env var (not --stats=normal, which this repo deliberately avoids), restore process.argv after each test to avoid leaking state, and drop the unused contents: write permission from the bundle-size job. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Hoist NETLIFY_BUNDLE_ANALYZER_SITE_ID into job-level env so the Netlify-publish step's `if:` can gate on it -- secrets aren't available in step-level `if:` conditionals, so the previous check always evaluated false and the job would fail before it, per GH Actions' documented if-conditional context availability. - Gate comment-on-alert on same-repo PRs in the bundle-size job. On a fork PR GITHUB_TOKEN is forced read-only, so once the alert threshold is crossed the action's pulls.createReview call 403s and that error isn't caught by fail-on-alert, which only governs the deliberate alert-threshold failure -- it propagates and fails the job outright. Fork PRs still get the comparison via summary-always. Co-Authored-By: Claude Opus 4.8 <[email protected]>
2db8f64 to
114f904
Compare
Code Review Agent Run #1418a6Actionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
The bundle-size job downloads the docker image built from pull_request.head.sha but its own checkout used the default synthetic merge ref, so the summary script could run against a different revision than the one the image was built from once the base branch moved. Co-Authored-By: Claude Opus 4.8 <[email protected]>
sha174n
left a comment
There was a problem hiding this comment.
Reviewed — CI/build configuration only, no product runtime or data-access surface. No security concerns. LGTM.
SUMMARY
Superset's frontend bundle size is a recurring complaint (per an internal audit of CI speedup opportunities), but there's been no ongoing visibility into it -- only periodic manual cleanup. This turns it into a ratchet: track it continuously, comment on PRs that regress it.
Adds a
bundle-sizejob tosuperset-frontend.ymlalongside the existinglint-frontend/validate-frontend/etc. jobs. It:npm run build) inside itscripts/bundle-size-summary.js)Cost: the only new work is the production webpack build itself, and it's cheap after the first run. webpack's persistent filesystem cache (already configured in
webpack.config.js) makes warm rebuilds ~20s locally vs. several minutes cold -- confirmed by hand against this repo's actual build, both cold (after touchingwebpack.config.js, which invalidates the cache) and warm. The job is gated the same way as its siblings (needs.frontend-build.outputs.should-run == 'true'), so it's skipped entirely on non-frontend PRs.Why
webpack.config.jsneeded a change: the defaultstats: 'minimal'omits per-asset sizes entirely from--jsonoutput. The alternative,--stats=normal, includes them but also serializes the full ~15k-module dependency graph -- a 560+MBstats.jsonfor this app, large enough that a plainfs.readFileSyncthrowsERR_STRING_TOO_LONG(verified this failure mode directly). Added aBUNDLE_SIZE_STATSenv-gated override requesting just{ assets: true, entrypoints: true }-- mirrors the existingBUNDLE_ANALYZERenv-gated pattern already in this file. Verified the resulting schema end-to-end against both a minimal synthetic webpack project and real stats pulled from this repo's actual production build (spaentrypoint = ~8.25MB,embedded= ~7.9MB, for reference).Why not the usual
gh-pagesstorage: benchmark-action's default is to commit history to agh-pagesbranch.apache/superset'sgh-pagesbranch is already live production infrastructure -- the Helm chart index published bysuperset-helm-release.yml(confirmed via its recent commit history) -- not free real estate, and I didn't want this to risk stomping on it. Instead this usesexternal-data-json-pathwithactions/cache: restored on every run (PR or push) so PRs get a same-baseline comparison and regression comment, but only saved back to the cache on push tomaster, so an unmerged PR's numbers (including ones that regress on purpose to test something) never become the shared baseline. No git branch is touched by any code path here, and no PAT/GitHub App is needed --comment-on-alertonly needs the default per-jobGITHUB_TOKEN(contents: write+pull-requests: write, scoped to this one job, auto-revoked at job end).TESTING INSTRUCTIONS
pre-commit run(prettier, oxlint, frontend type-checking,zizmorGHA security audit) passes on all three touched files.BUNDLE_SIZE_STATS-gated stats override produces the exactentrypoints.<name>.assets: [{name, size}]shape the reducer expects, and the reducer correctly extracts JS/CSS sizes per tracked entrypoint.BUNDLE_SIZE_STATS=true npm run build -- --json=stats.json) to confirm it completes with 0 errors and to pull real entrypoint sizes for sanity-checking the numbers above.bundle-sizejob should run, and its job summary should show a size comparison table.ADDITIONAL INFORMATION