Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
118 changes: 118 additions & 0 deletions .github/workflows/bump-size-limits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: 'Auto-bump size-limit thresholds'

on:
schedule:
- cron: '0 9 * * 5' # Friday 09:00 UTC
workflow_dispatch:

permissions:
contents: write
pull-requests: write
issues: write

concurrency:
group: bump-size-limits
cancel-in-progress: false

jobs:
bump:
name: Bump size-limit thresholds
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.GITFLOW_APP_ID }}
private-key: ${{ secrets.GITFLOW_APP_PRIVATE_KEY }}

- name: Checkout develop
uses: actions/checkout@v6
with:
ref: develop
token: ${{ steps.app-token.outputs.token }}

- name: Set up Node
uses: actions/setup-node@v6
with:
node-version-file: 'package.json'

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Build packages
run: yarn build

- name: Run bumper
id: bump
# Capture stdout AND exit code without failing the step on exit-2 (no-op).
run: |
set +e
node scripts/bump-size-limits.mjs > /tmp/bump-summary.md
code=$?
set -e
echo "exit_code=$code" >> "$GITHUB_OUTPUT"
if [ "$code" -ne 0 ] && [ "$code" -ne 2 ]; then
echo "::error::bump script failed with exit code $code"
cat /tmp/bump-summary.md || true
exit "$code"
fi
cat /tmp/bump-summary.md

- name: Commit and push
if: steps.bump.outputs.exit_code == '0'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
slug=$(gh api /user --jq '.login')
Comment thread
chargome marked this conversation as resolved.
Outdated
id=$(gh api /user --jq '.id')
git checkout -B bot/bump-size-limits
git add .size-limit.js
git -c "user.name=$slug" \
-c "user.email=$id+$slug@users.noreply.github.com" \
commit -m "chore(size-limit): auto-bump weekly drift"
git push --force-with-lease origin bot/bump-size-limits

- name: Open or update PR
if: steps.bump.outputs.exit_code == '0'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
existing=$(gh pr list --head bot/bump-size-limits --base develop --state open --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh pr edit "$existing" --body-file /tmp/bump-summary.md
echo "Updated existing PR #$existing"
else
gh pr create \
--base develop \
--head bot/bump-size-limits \
--title "chore(size-limit): weekly auto-bump" \
--body-file /tmp/bump-summary.md \
--label "Dev: CI"
fi

- name: Open or comment on failure issue
Comment thread
chargome marked this conversation as resolved.
if: failure()
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
title='Weekly size-limit auto-bump failure'
existing=$(gh issue list --search "in:title \"$title\"" --state open --json number,title --jq ".[] | select(.title == \"$title\") | .number" | head -n1)
if [ -n "$existing" ]; then
gh issue comment "$existing" --body "Auto-bump workflow failed again: $RUN_URL"
else
body=$(cat <<EOF
The weekly size-limit auto-bump workflow failed.

Run: $RUN_URL

This issue will be commented on for repeat failures.
EOF
)
gh issue create \
--title "$title" \
--body "$body" \
--label "Dev: CI"
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dedupe-deps:fix": "yarn-deduplicate yarn.lock",
"postpublish": "nx run-many -t postpublish --parallel=1",
"test": "nx run-many -t test --exclude \"@sentry-internal/{browser-integration-tests,bun-integration-tests,e2e-tests,integration-shims,node-integration-tests,node-core-integration-tests,cloudflare-integration-tests}\"",
"test:scripts": "vitest run scripts/bump-version.test.ts",
"test:scripts": "vitest run scripts/*.test.ts",
"test:unit": "nx run-many -t test:unit --exclude \"@sentry-internal/{browser-integration-tests,bun-integration-tests,e2e-tests,integration-shims,node-integration-tests,node-core-integration-tests,cloudflare-integration-tests}\"",
"test:update-snapshots": "nx run-many -t test:update-snapshots",
"test:pr": "nx affected -t test --exclude \"@sentry-internal/{browser-integration-tests,bun-integration-tests,e2e-tests,integration-shims,node-integration-tests,node-core-integration-tests,cloudflare-integration-tests}\"",
Expand Down
27 changes: 27 additions & 0 deletions scripts/__fixtures__/size-limit-sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = [
{
name: '@sentry/browser',
path: 'packages/browser/build/npm/esm/prod/index.js',
gzip: true,
limit: '27 KB',
},
{
name: '@sentry/browser - with treeshaking flags',
path: 'packages/browser/build/npm/esm/prod/index.js',
gzip: true,
limit: '25 KB',
},
{
name: 'CDN Bundle (incl. Tracing)',
path: 'packages/browser/build/bundles/bundle.tracing.min.js',
gzip: true,
limit: '46.5 KB',
},
{
name: '@sentry/cloudflare (withSentry)',
path: 'packages/cloudflare/build/esm/index.js',
gzip: false,
brotli: false,
limit: '420 KiB',
},
];
Loading
Loading