Skip to content

Commit a63acaa

Browse files
Add skip-bundle-size-check script for bypassing size check
When an intentional size increase exceeds the 0.5KB threshold: 1. Run `bin/skip-bundle-size-check` to set the current branch 2. Commit and push the .bundle-size-skip-branch file 3. The CI will skip the size check for that branch The workflow uses a two-job approach: check-skip runs first, and the size job only runs if the branch isn't in the skip file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7f84423 commit a63acaa

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.bundle-size-skip-branch

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file allows skipping the bundle size CI check for a specific branch.
2+
# When a branch name in this file matches the PR branch, the size check is skipped.
3+
#
4+
# Usage: Run `bin/skip-bundle-size-check` to set the current branch, then commit and push.
5+
#
6+
# This is useful when you have an intentional size increase that exceeds the 0.5KB threshold.

.github/workflows/bundle-size.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,33 @@ on:
88
- 'pnpm-lock.yaml'
99
- '.size-limit.json'
1010
- '.github/workflows/bundle-size.yml'
11+
- '.bundle-size-skip-branch'
1112

1213
jobs:
14+
check-skip:
15+
runs-on: ubuntu-22.04
16+
outputs:
17+
skip: ${{ steps.skip-check.outputs.skip }}
18+
steps:
19+
- name: Checkout PR branch
20+
uses: actions/checkout@v4
21+
22+
- name: Check if branch should skip size check
23+
id: skip-check
24+
run: |
25+
SKIP_FILE=".bundle-size-skip-branch"
26+
BRANCH="${{ github.head_ref }}"
27+
SKIP_BRANCH=$(grep -v '^[[:space:]]*#' "$SKIP_FILE" 2>/dev/null | grep -v '^[[:space:]]*$' | tr -d '[:space:]' || echo "")
28+
if [ "$SKIP_BRANCH" = "$BRANCH" ]; then
29+
echo "skip=true" >> $GITHUB_OUTPUT
30+
echo "::notice::Branch '$BRANCH' is set to skip size check"
31+
else
32+
echo "skip=false" >> $GITHUB_OUTPUT
33+
fi
34+
1335
size:
36+
needs: check-skip
37+
if: needs.check-skip.outputs.skip != 'true'
1438
runs-on: ubuntu-22.04
1539
permissions:
1640
contents: read

bin/skip-bundle-size-check

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Skip bundle size check for current branch
4+
#
5+
# Usage:
6+
# bin/skip-bundle-size-check
7+
#
8+
9+
set -e
10+
11+
SKIP_FILE=".bundle-size-skip-branch"
12+
BRANCH=$(git branch --show-current)
13+
14+
if [ -z "$BRANCH" ]; then
15+
echo "Error: Not on a branch (detached HEAD?)"
16+
exit 1
17+
fi
18+
19+
# Write comment header and branch name
20+
cat > "$SKIP_FILE" << EOF
21+
# This file allows skipping the bundle size CI check for a specific branch.
22+
# When a branch name in this file matches the PR branch, the size check is skipped.
23+
#
24+
# Usage: Run \`bin/skip-bundle-size-check\` to set the current branch, then commit and push.
25+
#
26+
# This is useful when you have an intentional size increase that exceeds the 0.5KB threshold.
27+
$BRANCH
28+
EOF
29+
echo "Set '$BRANCH' as the branch to skip bundle size check"
30+
echo ""
31+
echo "Next steps:"
32+
echo " git add $SKIP_FILE"
33+
echo " git commit -m 'Skip bundle size check for $BRANCH'"
34+
echo " git push"

0 commit comments

Comments
 (0)