forked from jaegertracing/jaeger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hariom Gupta <102638746+hari45678@users.noreply.github.com>
- Loading branch information
Showing
1 changed file
with
35 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,71 @@ | ||
name: Bundle Size Check | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-check: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: packages/jaeger-ui | ||
|
||
steps: | ||
- uses: actions/checkout@v4 # v4.2.1 | ||
|
||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
|
||
- name: Read .npmrc | ||
id: npmrc | ||
run: | | ||
NODE_VERSION=$(grep 'node=' .npmrc | cut -d'=' -f2) | ||
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 # v4.1.0 | ||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: '20' | ||
node-version: ${{ steps.npmrc.outputs.node_version }} | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Calculate bundle size | ||
run: | | ||
TOTAL_SIZE=$(du -sb build | cut -f1) | ||
TOTAL_SIZE=$(du -sb packages/jaeger-ui/build | cut -f1) | ||
echo "$TOTAL_SIZE" > new_bundle_size.txt | ||
echo "Total bundle size: $TOTAL_SIZE bytes" | ||
- name: Restore previous bundle size | ||
id: cache-bundle-size | ||
uses: actions/cache@v4 | ||
with: | ||
path: /home/runner/work/jaeger-ui/jaeger-ui/packages/jaeger-ui/bundle_size.txt | ||
path: bundle_size.txt | ||
key: bundle-size-jaeger-ui | ||
|
||
- name: Compare bundle sizes | ||
if: steps.cache-bundle-size.outputs.cache-hit == 'true' | ||
run: | | ||
if [ -f bundle_size.txt ]; then | ||
OLD_BUNDLE_SIZE=$(cat bundle_size.txt) | ||
NEW_BUNDLE_SIZE=$(cat new_bundle_size.txt) | ||
echo "Previous bundle size: $OLD_BUNDLE_SIZE bytes" | ||
echo "New bundle size: $NEW_BUNDLE_SIZE bytes" | ||
SIZE_CHANGE=$(( $NEW_BUNDLE_SIZE - $OLD_BUNDLE_SIZE )) | ||
PERCENTAGE_CHANGE=$(( SIZE_CHANGE * 100 / $OLD_BUNDLE_SIZE )) | ||
echo "Size change: $PERCENTAGE_CHANGE%" | ||
if [ $PERCENTAGE_CHANGE -gt 2 ]; then | ||
echo "❌ Bundle size increased by more than 2% ($PERCENTAGE_CHANGE%)" | ||
exit 1 | ||
else | ||
echo "✅ Bundle size change is within acceptable range ($PERCENTAGE_CHANGE%)" | ||
fi | ||
OLD_BUNDLE_SIZE=$(cat bundle_size.txt) | ||
NEW_BUNDLE_SIZE=$(cat new_bundle_size.txt) | ||
echo "Previous bundle size: $OLD_BUNDLE_SIZE bytes" | ||
echo "New bundle size: $NEW_BUNDLE_SIZE bytes" | ||
SIZE_CHANGE=$(( $NEW_BUNDLE_SIZE - $OLD_BUNDLE_SIZE )) | ||
PERCENTAGE_CHANGE=$(( SIZE_CHANGE * 100 / $OLD_BUNDLE_SIZE )) | ||
echo "Size change: $PERCENTAGE_CHANGE%" | ||
if [ $PERCENTAGE_CHANGE -gt 2 ]; then | ||
echo "❌ Bundle size increased by more than 2% ($PERCENTAGE_CHANGE%)" | ||
exit 1 | ||
else | ||
echo "No previous bundle size found. This will be the baseline." | ||
echo "✅ Bundle size change is within acceptable range ($PERCENTAGE_CHANGE%)" | ||
fi | ||
- name: Remove previous *_bundle_*.txt file | ||
run: | | ||
rm -rf bundle_size.txt | ||
mv new_bundle_size.txt bundle_size.txt | ||
pwd | ||
ls | ||
- name: Update bundle size file | ||
run: rm -f bundle_size.txt && mv new_bundle_size.txt bundle_size.txt | ||
|
||
- name: Save new bundle size | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: /home/runner/work/jaeger-ui/jaeger-ui/packages/jaeger-ui/bundle_size.txt | ||
path: bundle_size.txt | ||
key: bundle-size-jaeger-ui | ||
|
||
- name: Upload bundle size artifact | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: bundle-size | ||
path: /home/runner/work/jaeger-ui/jaeger-ui/packages/jaeger-ui/bundle_size.txt | ||
retention-days: 30 |