Skip to content

Commit ebb08e6

Browse files
committed
measure bundle size on CI
1 parent 1f3b212 commit ebb08e6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,49 @@ jobs:
177177
ignore_links: 'https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/.* https://mybinder.org/v2/gh/jupyter/notebook/main https://nbviewer.jupyter.org https://stackoverflow.com https://github.com/[^/]+/?$'
178178
ignore_glob: 'ui-tests/test/notebooks/*'
179179

180+
bundle_size:
181+
name: Bundle Size
182+
runs-on: ubuntu-latest
183+
timeout-minutes: 20
184+
steps:
185+
- uses: actions/checkout@v6
186+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
187+
188+
- name: Install dependencies
189+
run: jlpm
190+
191+
- name: Measure bundle sizes
192+
run: |
193+
measure() {
194+
find notebook/static -name "$1" -print0 2>/dev/null | xargs -0 cat 2>/dev/null | wc -c | tr -d ' '
195+
}
196+
197+
jlpm build
198+
DEV_JS=$(measure "*.js")
199+
DEV_MAP=$(measure "*.js.map")
200+
201+
jlpm clean
202+
jlpm build:prod:minimize
203+
MIN_JS=$(measure "*.js")
204+
MIN_MAP=$(measure "*.js.map")
205+
206+
jlpm clean
207+
jlpm build:prod:release
208+
REL_JS=$(measure "*.js")
209+
REL_MAP=$(measure "*.js.map")
210+
211+
fmt() { numfmt --to=iec "$1"; }
212+
213+
{
214+
echo "## Bundle Size Report"
215+
echo ""
216+
echo "| Build | JS Size | Source Maps |"
217+
echo "|-------|---------|-------------|"
218+
echo "| dev | $(fmt $DEV_JS) | $(fmt $DEV_MAP) |"
219+
echo "| prod:minimize | $(fmt $MIN_JS) | $(fmt $MIN_MAP) |"
220+
echo "| prod:release | $(fmt $REL_JS) | $(fmt $REL_MAP) |"
221+
} >> $GITHUB_STEP_SUMMARY
222+
180223
test_lint:
181224
name: Test Lint
182225
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)