Skip to content

Commit

Permalink
Refactor bundle size workflow
Browse files Browse the repository at this point in the history
Consolidate results and produce simpler markdown table
  • Loading branch information
necolas committed Aug 21, 2024
1 parent 2de3db8 commit 1816392
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 64 deletions.
69 changes: 48 additions & 21 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,53 @@ name: performance
on: [pull_request]

jobs:
runtime-size:
name: runtime-size
size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: necolas/compressed-size-action@master
with:
name: 'runtime library'
build-script: 'build -w @stylexjs/stylex'
pattern: './packages/stylex/lib/{stylex.js,StyleXSheet.js}'
repo-token: '${{ secrets.GITHUB_TOKEN }}'

bundle-size:
name: bundle-size
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: necolas/compressed-size-action@master
with:
name: 'e2e bundles'
build-script: 'build'
pattern: './apps/rollup-example/.build/{stylex.css,bundle.js}'
repo-token: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/checkout@v4
with:
fetch-depth: 50
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 'Setup temporary files'
run: |
echo "BASE_JSON=$(mktemp)" >> $GITHUB_ENV
echo "PATCH_JSON=$(mktemp)" >> $GITHUB_ENV
- name: 'Benchmark base'
run: |
git checkout -f ${{ github.event.pull_request.base.sha }}
npm install --loglevel error
npm run build
if npm run size -w scripts -- -o ${{ env.BASE_JSON }}; then
echo "Ran successfully on base branch"
else
echo "{}" > ${{ env.BASE_JSON }} # Empty JSON as default
echo "Benchmark script not found on base branch, using default values"
fi
- name: 'Benchmark patch'
run: |
git checkout -f ${{ github.event.pull_request.head.sha }}
npm install --loglevel error
npm run build
npm run size -w scripts -- -o ${{ env.PATCH_JSON }}
echo "Ran successfully on patch branch"
- name: 'Collect results'
id: collect
run: |
echo "table<<EOF" >> $GITHUB_OUTPUT
npm run size:compare -w scripts -- ${{ env.BASE_JSON }} ${{ env.PATCH_JSON }} >> markdown
cat markdown >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 'Post comment'
uses: edumserrano/find-create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- workflow-benchmarks-size-data -->'
comment-author: 'github-actions[bot]'
body: |
<!-- workflow-benchmarks-size-data -->
### workflow: benchmarks/size
Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.
${{ steps.collect.outputs.table }}
edit-mode: replace
146 changes: 103 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
"gen-types": "./gen-types.js",
"rewrite-imports": "./rewrite-imports.js"
},
"scripts": {
"size": "./size.js",
"size:compare": "./size-compare.js"
},
"dependencies": {
"brotli-size": "^4.0.0",
"clean-css": "^5.3.3",
"flow-api-translator": "0.19.2",
"terser": "^5.31.0",
"yargs": "17.7.2"
}
}
Loading

0 comments on commit 1816392

Please sign in to comment.