Skip to content

[Pro] Add RSC SSR synchrony regression tests: complete payload must render before setTimeout(0) #2885

[Pro] Add RSC SSR synchrony regression tests: complete payload must render before setTimeout(0)

[Pro] Add RSC SSR synchrony regression tests: complete payload must render before setTimeout(0) #2885

Workflow file for this run

name: Bundle Size
permissions:
contents: read
on:
pull_request:
paths:
- 'packages/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.tool-versions'
- '.size-limit.json'
- '.github/workflows/bundle-size.yml'
- '.bundle-size-skip-branch'
jobs:
check-skip:
runs-on: ubuntu-22.04
outputs:
skip: ${{ steps.skip-check.outputs.skip }}
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Check if branch should skip size check
id: skip-check
env:
BRANCH: ${{ github.head_ref }}
run: |
SKIP_FILE=".bundle-size-skip-branch"
SKIP_BRANCH=$(grep -v '^[[:space:]]*#' "$SKIP_FILE" 2>/dev/null | grep -v '^[[:space:]]*$' | tr -d '[:space:]' || echo "")
if [ "$SKIP_BRANCH" = "$BRANCH" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::Branch '$BRANCH' is set to skip size check"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
check-bundle-size:
needs: check-skip
if: needs.check-skip.outputs.skip != 'true'
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
env:
CI_JOB_NUMBER: 1
steps:
# 1. Read the PR's runtime before switching branches, then keep that Node
# version for both base and PR builds to avoid cross-version size skew.
# Also keep the PR's size-limit config because the base branch may not have it.
- name: Checkout PR branch for runtime config
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
# The merge commit and its two parents are enough for the base-SHA
# derivation below; no full-history checkout is needed.
fetch-depth: 2
- name: Determine base SHA from the PR merge commit
id: base-sha
env:
MERGE_SHA: ${{ github.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# For pull_request events github.sha is the ephemeral merge commit
# (refs/pull/N/merge): the PR head merged into the base-branch tip. The
# PR-head sizes are built from this merge commit, so the base sizes must be
# built from its FIRST PARENT to share the exact same base-branch baseline.
#
# Using the live base tip (github.event.pull_request.base.sha) instead lets
# the two builds drift apart whenever the PR branch is behind the base
# branch: unrelated growth that landed on the base branch gets mis-attributed
# to the PR, producing uniform false-positive size increases across every
# tracked bundle (including OSS bundles the PR never touched).
if [ "$MERGE_SHA" = "$HEAD_SHA" ]; then
echo "::error::Bundle size check needs a mergeable PR: github.sha equals the PR head, so no merge commit exists (the branch likely conflicts with the base branch). Rebase / resolve conflicts and re-run."
exit 1
fi
read -ra parents <<< "$(git rev-list --parents -n 1 "$MERGE_SHA")"
# parents[0] = merge commit, [1] = first parent (base), [2] = second parent (head)
if [ "${#parents[@]}" -eq 0 ]; then
echo "::error::Could not read parents of github.sha ($MERGE_SHA); the commit is not reachable in this checkout. Ensure this job checks out with fetch-depth: 2 or deeper."
exit 1
fi
if [ "${#parents[@]}" -ne 3 ]; then
echo "::error::Expected github.sha ($MERGE_SHA) to be a 2-parent merge commit, found $(( ${#parents[@]} - 1 )) parent(s); cannot determine a matching base baseline. Ensure this job checks out with fetch-depth: 2 or deeper."
exit 1
fi
base_sha="${parents[1]}"
head_parent="${parents[2]}"
if [ "$head_parent" != "$HEAD_SHA" ]; then
echo "::error::Merge commit second parent ($head_parent) does not match the PR head ($HEAD_SHA); unexpected merge structure."
exit 1
fi
echo "base-sha=$base_sha" >> "$GITHUB_OUTPUT"
echo "Base baseline (merge commit first parent): $base_sha"
echo "PR head (merge commit second parent): $head_parent"
- name: Read runtime versions
id: tool-versions
uses: ./.github/actions/read-tool-versions
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ steps.tool-versions.outputs.node-version }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Save size-limit config
run: cp .size-limit.json /tmp/size-limit-config.json
# 2. Get base branch sizes from the merge commit's first parent so the base
# and PR-head builds share the same base-branch baseline (see base-sha step).
- name: Checkout base branch
uses: actions/checkout@v4
with:
# Only the working tree at the base parent is needed (not its history), so
# the default shallow fetch-depth is enough; checkout@v4 fetches this SHA
# directly since it is reachable from the base branch.
ref: ${{ steps.base-sha.outputs.base-sha }}
persist-credentials: false
- name: Copy size-limit config to base branch
run: cp /tmp/size-limit-config.json .size-limit.json
- name: Install base dependencies
run: pnpm install --frozen-lockfile
- name: Build base branch
run: pnpm run build
- name: Verify build artifacts
run: |
missing=0
for pkg in react-on-rails react-on-rails-pro react-on-rails-pro-node-renderer; do
if ! ls packages/$pkg/lib/*.js >/dev/null 2>&1; then
echo "::error::Missing build artifacts in packages/$pkg/lib/"
missing=1
fi
done
if [ $missing -eq 1 ]; then
exit 1
fi
echo "All build artifacts verified"
- name: Measure base branch sizes
run: |
pnpm exec size-limit --json > /tmp/base-sizes.json
echo "Base branch sizes:"
cat /tmp/base-sizes.json
# 3. Checkout PR and set dynamic limits
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Install PR dependencies
run: pnpm install --frozen-lockfile
- name: Set dynamic limits (base + 0.5KB)
run: node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json
- name: Copy .size-limit.json file with limits to tmp directory
run: cp .size-limit.json /tmp/.size-limit-with-limits.json
# 4. Run the action with dynamic limits
- name: Check bundle size
uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
package_manager: pnpm
build_script: build-for-size-limit
skip_step: install