Skip to content

Commit 37d7340

Browse files
committed
Refactor bundle size workflow
Consolidate results and produce simpler markdown table
1 parent ff4f548 commit 37d7340

File tree

5 files changed

+352
-64
lines changed

5 files changed

+352
-64
lines changed

.github/workflows/performance.yml

+46-21
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,51 @@ name: performance
33
on: [pull_request]
44

55
jobs:
6-
runtime-size:
7-
name: runtime-size
6+
size:
87
runs-on: ubuntu-latest
98
steps:
10-
- uses: actions/checkout@v4
11-
- uses: necolas/compressed-size-action@master
12-
with:
13-
name: 'runtime library'
14-
build-script: 'build -w @stylexjs/stylex'
15-
pattern: './packages/stylex/lib/{stylex.js,StyleXSheet.js}'
16-
repo-token: '${{ secrets.GITHUB_TOKEN }}'
17-
18-
bundle-size:
19-
name: bundle-size
20-
runs-on: ubuntu-latest
21-
steps:
22-
- uses: actions/checkout@v4
23-
- uses: necolas/compressed-size-action@master
24-
with:
25-
name: 'e2e bundles'
26-
build-script: 'build'
27-
pattern: './apps/rollup-example/.build/{stylex.css,bundle.js}'
28-
repo-token: '${{ secrets.GITHUB_TOKEN }}'
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 50
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: '20.x'
15+
- name: 'Setup temporary files'
16+
run: |
17+
echo "BASE_JSON=$(mktemp)" >> $GITHUB_ENV
18+
echo "PATCH_JSON=$(mktemp)" >> $GITHUB_ENV
19+
- name: 'Benchmark base'
20+
run: |
21+
git checkout -f ${{ github.event.pull_request.base.sha }}
22+
npm install --loglevel error
23+
if npm run size -w @stylexjs/scripts -- -o ${{ env.BASE_JSON }}; then
24+
echo "Ran successfully on base branch"
25+
else
26+
echo "{}" > ${{ env.BASE_JSON }} # Empty JSON as default
27+
echo "Benchmark script not found on base branch, using default values"
28+
fi
29+
- name: 'Benchmark patch'
30+
run: |
31+
git checkout -f ${{ github.event.pull_request.head.sha }}
32+
npm install --loglevel error
33+
npm run size -w @stylexjs/scripts -- -o ${{ env.PATCH_JSON }}
34+
echo "Ran successfully on patch branch"
35+
- name: 'Collect results'
36+
id: collect
37+
run: |
38+
echo "table<<EOF" >> $GITHUB_OUTPUT
39+
npm run size:compare -w @stylexjs/scripts -- ${{ env.BASE_JSON }} ${{ env.PATCH_JSON }} >> markdown
40+
cat markdown >> $GITHUB_OUTPUT
41+
echo "EOF" >> $GITHUB_OUTPUT
42+
- name: 'Post comment'
43+
uses: edumserrano/find-create-or-update-comment@v3
44+
with:
45+
issue-number: ${{ github.event.pull_request.number }}
46+
body-includes: '<!-- workflow-benchmarks-size-data -->'
47+
comment-author: 'github-actions[bot]'
48+
body: |
49+
<!-- workflow-benchmarks-size-data -->
50+
### workflow: benchmarks/size
51+
Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
52+
${{ steps.collect.outputs.table }}
53+
edit-mode: replace

package-lock.json

+103-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/scripts/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
"gen-types": "./gen-types.js",
88
"rewrite-imports": "./rewrite-imports.js"
99
},
10+
"scripts": {
11+
"size": "./size.js",
12+
"size:compare": "./size-compare.js"
13+
},
1014
"dependencies": {
15+
"brotli-size": "^4.0.0",
16+
"clean-css": "^5.3.3",
1117
"flow-api-translator": "0.19.2",
18+
"terser": "^5.31.0",
1219
"yargs": "17.7.2"
1320
}
1421
}

0 commit comments

Comments
 (0)