-
Notifications
You must be signed in to change notification settings - Fork 67
fix compressed-diff workflow #3589
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
base: develop
Are you sure you want to change the base?
Changes from 10 commits
0ee2bd0
b22aecd
09ee926
8a4bb86
578558d
cd83e62
1a6704d
efb3052
a740f0e
71acb10
9b93e2d
061a4e9
61a69d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,138 @@ | ||||||||||||||||||||||||||||||||
| name: Build Size Comparison | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||
| branches: [ master, develop ] | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| build-and-compare: | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Skip the entire job for forked PRs to avoid secret access failures.
jobs:
build-and-compare:
+ if: ${{ github.event.pull_request.head.repo.fork == false }}
runs-on: ubuntu-latest📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout current PR | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Checkout base branch | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| ref: ${{ github.base_ref }} | ||||||||||||||||||||||||||||||||
| path: base-branch | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Checkout Premium Repo (Current PR) | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| repository: 'bfintal/Stackable-Premium' | ||||||||||||||||||||||||||||||||
| ref: 'v3' | ||||||||||||||||||||||||||||||||
| path: 'pro__premium_only' | ||||||||||||||||||||||||||||||||
| token: '${{ secrets.ACCESS_KEY }}' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Checkout Premium Repo (Base Branch) | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| repository: 'bfintal/Stackable-Premium' | ||||||||||||||||||||||||||||||||
| ref: 'v3' | ||||||||||||||||||||||||||||||||
| path: 'base-branch/pro__premium_only' | ||||||||||||||||||||||||||||||||
| token: '${{ secrets.ACCESS_KEY }}' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Setup Node | ||||||||||||||||||||||||||||||||
| uses: actions/setup-node@v3 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| node-version: 14.x | ||||||||||||||||||||||||||||||||
| cache: 'npm' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update setup-node action and Node.js version (Node 14 is EOL; action v3 flagged). Use actions/setup-node@v4 and a supported LTS (18.x or 20.x). Also cache all lockfiles via cache-dependency-path. - - name: Setup Node
- uses: actions/setup-node@v3
+ - name: Setup Node
+ uses: actions/setup-node@v4
with:
- node-version: 14.x
- cache: 'npm'
+ node-version: 20.x
+ cache: 'npm'
+ cache-dependency-path: |
+ package-lock.json
+ pro__premium_only/package-lock.json
+ base-branch/package-lock.json
+ base-branch/pro__premium_only/package-lock.json📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)40-40: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| - name: Install Dependencies (Current PR) | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| npm ci --legacy-peer-deps | ||||||||||||||||||||||||||||||||
| cd pro__premium_only | ||||||||||||||||||||||||||||||||
| npm ci --legacy-peer-deps | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Install Dependencies (Base Branch) | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| cd base-branch | ||||||||||||||||||||||||||||||||
| npm ci --legacy-peer-deps | ||||||||||||||||||||||||||||||||
| cd pro__premium_only | ||||||||||||||||||||||||||||||||
| npm ci --legacy-peer-deps | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Build Current PR | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| npm run build:no-translate | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Build Base Branch | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| cd base-branch | ||||||||||||||||||||||||||||||||
| npm run build:no-translate | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Create Zip Files | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| # Create zip for current PR | ||||||||||||||||||||||||||||||||
| cd build/stackable | ||||||||||||||||||||||||||||||||
| zip -r ../../current-build.zip . -x "*.map" "node_modules/*" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Create zip for base branch | ||||||||||||||||||||||||||||||||
| cd ../../base-branch/build/stackable | ||||||||||||||||||||||||||||||||
| zip -r ../../../base-build.zip . -x "*.map" "node_modules/*" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Move zip files to root directory for easier access | ||||||||||||||||||||||||||||||||
| cd ../../../ | ||||||||||||||||||||||||||||||||
| ls -la *.zip | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Compare Build Sizes | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| echo "## 📦 Build Size Comparison" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Check if files exist | ||||||||||||||||||||||||||||||||
| if [ ! -f "current-build.zip" ]; then | ||||||||||||||||||||||||||||||||
| echo "❌ **Error**: current-build.zip not found" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if [ ! -f "base-build.zip" ]; then | ||||||||||||||||||||||||||||||||
| echo "❌ **Error**: base-build.zip not found" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Get file sizes | ||||||||||||||||||||||||||||||||
| CURRENT_SIZE=$(du -h current-build.zip | cut -f1) | ||||||||||||||||||||||||||||||||
| BASE_SIZE=$(du -h base-build.zip | cut -f1) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Get exact byte sizes for calculation | ||||||||||||||||||||||||||||||||
| CURRENT_BYTES=$(stat -c%s current-build.zip) | ||||||||||||||||||||||||||||||||
| BASE_BYTES=$(stat -c%s base-build.zip) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Calculate difference | ||||||||||||||||||||||||||||||||
| DIFF_BYTES=$((CURRENT_BYTES - BASE_BYTES)) | ||||||||||||||||||||||||||||||||
| DIFF_PERCENT=$((DIFF_BYTES * 100 / BASE_BYTES)) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "| Build | Size |" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "|-------|------|" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "| **Current PR** | **$CURRENT_SIZE** |" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "| Base Branch | $BASE_SIZE |" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if [ $DIFF_BYTES -gt 0 ]; then | ||||||||||||||||||||||||||||||||
| echo "📈 **Size increased by** $(numfmt --to=iec $DIFF_BYTES) (+$DIFF_PERCENT%)" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| elif [ $DIFF_BYTES -lt 0 ]; then | ||||||||||||||||||||||||||||||||
| echo "📉 **Size decreased by** $(numfmt --to=iec $((DIFF_BYTES * -1))) (-$((DIFF_PERCENT * -1))%)" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| echo "✅ **No size change**" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "### 📁 Build Contents" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo "**Current PR build contents:**" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| unzip -l current-build.zip | head -20 >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Upload Build Artifacts | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: build-comparison | ||||||||||||||||||||||||||||||||
| path: | | ||||||||||||||||||||||||||||||||
| current-build.zip | ||||||||||||||||||||||||||||||||
| base-build.zip | ||||||||||||||||||||||||||||||||
| retention-days: 7 | ||||||||||||||||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add explicit permissions and concurrency to harden and speed up the workflow.
name: Build Size Comparison on: pull_request: branches: [ master, develop ] +permissions: + contents: read + issues: write + pull-requests: write + +concurrency: + group: build-size-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true📝 Committable suggestion
🤖 Prompt for AI Agents