Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle size analyzer to GH action #2942

Merged
merged 40 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a3cea9a
testing nejcm/bundle-size-reporter-action
nstolpe Nov 1, 2024
69797e5
moved uses
nstolpe Nov 1, 2024
4c276a4
move setup below checkout
nstolpe Nov 1, 2024
091895d
removed accidental package-lock
nstolpe Nov 1, 2024
a369269
removing changes to make sure actions.yml is found
nstolpe Nov 1, 2024
6b5bdce
reorganized some
nstolpe Nov 1, 2024
5e86af5
indent error
nstolpe Nov 1, 2024
b1cb284
removed token
nstolpe Nov 1, 2024
3916e0f
trying w/ env actions token
nstolpe Nov 1, 2024
55525fd
removing token
nstolpe Nov 1, 2024
dc85c40
reverted
nstolpe Nov 1, 2024
a7046ef
checkout under named section
nstolpe Nov 1, 2024
48e20a8
trying composite action
nstolpe Nov 1, 2024
95396f9
forgot to update paths
nstolpe Nov 1, 2024
d65b9d9
can't be in own job, for now at least
nstolpe Nov 1, 2024
f52bf93
commented inputs giving warning
nstolpe Nov 4, 2024
a7c991c
trying to build main so there's something to diff
nstolpe Nov 4, 2024
e65458e
moved uses up
nstolpe Nov 4, 2024
6008536
trying different sub directory config
nstolpe Nov 4, 2024
18634c3
forgot a slash
nstolpe Nov 4, 2024
5491df1
trying a cd
nstolpe Nov 4, 2024
6151c92
Added the shell
nstolpe Nov 4, 2024
542dc15
pr is not the same as br
nstolpe Nov 4, 2024
378e26a
trying working directory again
nstolpe Nov 4, 2024
6b0c5fe
seeing what's in br-base
nstolpe Nov 4, 2024
8127fcd
pnpm install
nstolpe Nov 4, 2024
5bc280e
Added some temporary new code to trigger a diff
nstolpe Nov 5, 2024
89fec93
minor modification since the last commit didn't trigger CI
nstolpe Nov 5, 2024
f12b3dd
checked out conflicted file from main
nstolpe Nov 5, 2024
b95ddb3
rebased and re-added temp function
nstolpe Nov 5, 2024
6fc30c6
added another temporary analysis verifier function
nstolpe Nov 5, 2024
475c04e
moved diff testing code to avoid failing snapshot test
nstolpe Nov 5, 2024
13086ec
removed some unused code, trying default input instead of hardcoded main
nstolpe Nov 5, 2024
c083541
cleaning up actions, seeing if setup can be skipped before building m…
nstolpe Nov 5, 2024
ce376a7
added call to diff function so it'll be included in bundle
nstolpe Nov 5, 2024
74ef9f1
only diff victory.min.js
nstolpe Nov 5, 2024
8d1492c
removed commented step
nstolpe Nov 6, 2024
6034ce2
removed fake change to demo diffing ability
nstolpe Nov 6, 2024
301d263
removed next-env.d.ts that got into docs but isn't in main
nstolpe Nov 6, 2024
b8ec38c
reverted candlestick lint change so it won't cause a version bump
nstolpe Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/actions/bundle-size/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Bundle size reporter"
description: "Post bundle size difference compared to another branch"
inputs:
branch:
description: 'Branch to compare to'
required: true
default: 'main'
paths:
description: "Paths to json file bundle size report or folder containing bundles"
required: true
default: "/"
onlyDiff:
description: "Report only different sizes"
required: false
default: "false"
filter:
description: "Regex filter based on file path"
required: false
unit:
description: "Size unit"
required: false
default: "KB"

# Comment inputs
comment:
description: "Post comment"
required: false
default: "true"
header:
description: "Comment header"
required: false
default: "Bundle size report"
append:
description: "Append comment"
required: false
default: "false"
ghToken:
description: "Github token"
required: false

runs:
using: "composite"
steps:
# Checkout branch to compare to [required]
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
path: br-base

# build main under it's checkout location, in ./br-base
- name: Build main
shell: bash
run: cd br-base && pnpm install && pnpm build

# Generate the bundle size difference report [required]
- name: Generate report
id: bundleSize
uses: nejcm/[email protected]
with:
paths: ${{ inputs.paths }}
onlyDiff: ${{ inputs.onlyDiff }}

# Post github action summary
- name: Post summary
if: ${{ steps.bundleSize.outputs.hasDifferences == 'true' }} # post only in case of changes
run: |
echo '${{ steps.bundleSize.outputs.summary }}' >> $GITHUB_STEP_SUMMARY
shell: bash

# Post github action comment
- name: Post comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.bundleSize.outputs.hasDifferences == 'true' }} # post only in case of changes
with:
number: ${{ github.event.pull_request.number }}
header: ${{ inputs.header }}
append: ${{ inputs.append }}
message: "${{ steps.bundleSize.outputs.summary }}"
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
- name: Types
run: pnpm types:check

- name: 📄 Bundle size report
uses: ./.github/actions/bundle-size # path to composite action
with:
paths: "packages/victory/dist/victory.min.js"
onlyDiff: "true"
header: "Bundle size report" # PR comment header

format:
needs: [build]
runs-on: ubuntu-latest
Expand Down
Loading