Skip to content

Conversation

@AbanoubGhadban
Copy link
Collaborator

@AbanoubGhadban AbanoubGhadban commented Dec 3, 2025

Summary

  • This PR started as an attempt to make CI use the @size-limit/time plugin to measure the execution time of each client bundle and ensure it doesn't exceed the base branch execution time by more than 20%.
  • Later, found that the @size-limit/time plugin is not good at all at detecting that because of the runtime noise on CI.
  • So, CI will only look for the download time of chunks at the browser for now, until finding another tool that run the code multiple time on CI and get average execution time to get rid of runtime noise.
  • However, the following changes are made:
    • The feature of measring the execution time and comparing it to the base branch is already added to the bin/compare-bundle-sizes script, so if you can run it locally with a noise mitigated environment you can do that by changing the running values at .size-limit.json file to true.
    • Removed the compare command from the scripts/bundle-size.mjs script as it's not needed and used the default comparison behavior at the size-limit package.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR introduces automated execution time tracking to the bundle-size CI workflow. It removes legacy size-limit entries, adds time-based threshold enforcement to prevent import execution time increases exceeding 20%, and restructures the build and comparison workflow to compute dynamic limits upfront and apply them during the build process.

Changes

Cohort / File(s) Summary
CI workflow configuration
.github/workflows/bundle-size.yml
Updated to copy computed size limits to a temporary location after calculating dynamic limits; changed build script reference from build to build-for-size-limit.
Build scripts and npm tasks
package.json
Added new build-for-size-limit script that loads precomputed limits from /tmp/.size-limit-with-limits.json before running the standard build.
Bundle-size CLI tool
scripts/bundle-size.mjs
Removed the compare command entirely; introduced timePercentageThreshold (0.2 default) and createLimitEntry helper to compute and enforce execution time-based limits alongside size limits; replaced formatDiff with formatTime for time-value rendering.
CI orchestration script
bin/compare-bundle-sizes
Replaced explicit size measurement and comparison logic with dynamic limit calculation via a node script (set-limits using base branch results); added git restore step for .size-limit.json cleanup.
Size-limit configuration
.size-limit.json
Removed entries for react-on-rails, react-on-rails-pro, and react-on-rails-pro-node-renderer packages; added "running": false flag to gzip and brotli configurations for remaining client-bundled entries.
Documentation
CHANGELOG.md, CONTRIBUTING.md
Added "Total Execution Time CI Monitoring" entry describing automated tracking and 20% threshold enforcement; updated contributor workflow description to reflect reporting of both size and execution time metrics.

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions
    participant Script as bin/compare-bundle-sizes
    participant NodeScript as scripts/bundle-size.mjs
    participant Build as build-for-size-limit
    participant SizeLimit as size-limit tool
    participant Report as Report Results

    GHA->>Script: Trigger bundle-size workflow
    Script->>NodeScript: Run set-limits (base branch data)
    NodeScript->>NodeScript: Calculate size + time limits<br/>(apply 20% time threshold)
    NodeScript->>GHA: Save limits to /tmp/.size-limit-with-limits.json
    Script->>Build: Execute build-for-size-limit
    Build->>Build: Copy limits from /tmp to .size-limit.json
    Build->>SizeLimit: Run standard build with new limits
    SizeLimit->>SizeLimit: Measure bundle size & execution time
    SizeLimit->>SizeLimit: Compare against dynamic limits
    SizeLimit->>Report: Pass/Fail result
    Report->>GHA: Report to PR
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • scripts/bundle-size.mjs: Review the new time-based limit calculation logic in createLimitEntry and ensure timePercentageThreshold is correctly applied; verify removal of compare command doesn't break existing workflows
  • bin/compare-bundle-sizes: Validate the dynamic limit workflow shift (base → set-limits → build) and ensure .size-limit.json restoration doesn't cause unintended side effects
  • .size-limit.json: Confirm that removed entries are intentional legacy cleanup and that "running": false doesn't disable unwanted measurements

Possibly related PRs

Suggested labels

review-needed, full-ci

Suggested reviewers

  • Judahmeek

Poem

🐰 Hopping through bundles, both swift and small,
Time limits and sizes, we're tracking them all!
No more compare commands, just dynamic delight,
Execution times checked—every build runs just right! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request: adding execution time tracking and checking in the CI pipeline alongside the existing bundle size checks.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review Feedback

Summary

This PR deletes a temporary file (packages/react-on-rails-pro/temp.js) containing only console.log('hello');. The change itself is straightforward and safe.

Issues Identified

1. Misleading PR Title ⚠️

  • Current: "Add running time check on CI"
  • Actual change: Removes a temporary test file
  • Recommendation: Update the title to accurately reflect the change, such as:
    • "Remove temporary test file temp.js"
    • "Clean up: Remove temp.js from react-on-rails-pro"

2. Missing PR Description 📝

  • The PR body is completely empty
  • Recommendation: Add a brief description explaining:
    • Why this file was created in the first place
    • Why it's being removed now
    • Whether it was accidentally committed or used for testing

3. Commit Message Mismatch

  • Commit message: "reverted temp.js"
  • The word "reverted" suggests undoing a change, but without context, it's unclear what's being reverted
  • Recommendation: Use a more descriptive commit message like:
    • "chore: remove temporary test file temp.js"
    • "cleanup: delete accidentally committed temp.js"

Code Quality Assessment

Positives:

  • The deletion is safe - removing a temp file won't break anything
  • No dependency on this file exists in the codebase
  • All CI checks are passing or in progress

⚠️ Considerations:

  • Ensure this file wasn't serving any purpose in local development or testing workflows
  • Verify this wasn't meant to be part of a larger PR that includes the actual "running time check on CI" feature

Recommendations

  1. Update the PR title to match the actual change
  2. Add a PR description explaining the context
  3. Verify this is not part of a larger change that was accidentally split
  4. Consider whether this should be merged to master or closed if it was a mistake

Questions for Author

  • Was this file committed by accident?
  • Is there a separate PR coming for the "running time check on CI" feature mentioned in the title?
  • Should this be combined with other cleanup work or merged as-is?

Review performed according to project guidelines in CLAUDE.md

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.33 KB (0%)
react-on-rails/client bundled (gzip) (time) 62.33 KB (0%)
react-on-rails/client bundled (brotli) 53.48 KB (0%)
react-on-rails/client bundled (brotli) (time) 53.48 KB (0%)
react-on-rails-pro/client bundled (gzip) 63.38 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 63.38 KB (-0.01% 🔽)
react-on-rails-pro/client bundled (brotli) 54.44 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 54.44 KB (0%)
registerServerComponent/client bundled (gzip) 170.07 KB (0%)
registerServerComponent/client bundled (gzip) (time) 170.07 KB (0%)
registerServerComponent/client bundled (brotli) 83.46 KB (0%)
registerServerComponent/client bundled (brotli) (time) 83.46 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 164.61 KB (+0.01% 🔺)
wrapServerComponentRenderer/client bundled (gzip) (time) 164.61 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 78.58 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 78.58 KB (0%)

@claude
Copy link

claude bot commented Dec 3, 2025

Updated Code Review - Multi-Commit PR

I see this PR actually contains two separate changes across two commits:

Commit 1: "reverted temp.js"

  • Removes packages/react-on-rails-pro/temp.js (test file with console.log('hello');)
  • ✅ Safe cleanup change

Commit 2: "don't run code on non-time limited entries"

This is the actual meaningful change and requires careful review:

Changes in scripts/bundle-size.mjs (lines 104-105):

// OLD:
const sizeLimitEntry = { ...entry, limit: ` B` };
if (!sizeLimitEntry.running) {
  return sizeLimitEntry;
}

// NEW:
const sizeLimitEntry = { ...entry, running: false, limit: ` B` };
if (!baseEntry.running) {
  return sizeLimitEntry;
}

Critical Issues Found 🚨

1. Logic Bug - Wrong Variable Reference

  • Line 105: Changed from !sizeLimitEntry.running to !baseEntry.running
  • Problem: This changes the conditional logic to check the base entry instead of the current entry
  • Impact: The function now checks if the base entry has running time data, not the current entry
  • Question: Is this intentional? The commit message suggests "don't run code on non-time limited entries", but this changes which entry we're checking

2. Force-Setting running: false

  • Line 104: Now explicitly sets running: false in the spread
  • Problem: This overwrites any running property from the original entry
  • Impact: Even if entry.running was true, it's now forced to false
  • Consequence: This might prevent time-based checks from running when they should

Questions for Author ❓

  1. What is the intended behavior? Should we check baseEntry.running or sizeLimitEntry.running?
  2. Why force running: false? What problem does this solve?
  3. Test coverage: Are there tests for this logic? The change affects when time-based limits are created (lines 115-122)
  4. Example scenario:
    • If entry has running: true but baseEntry has running: false, what should happen?
    • If baseEntry has running: true, should we still force running: false on the output?

Recommendations 📋

  1. Add comprehensive PR description explaining:

    • The bug this fixes or feature this adds
    • Why the logic changed from checking sizeLimitEntry to baseEntry
    • Why we're forcing running: false
  2. Add test cases for this logic if they don't exist:

    // Test: entry with running=true, baseEntry with running=false
    // Test: entry with running=false, baseEntry with running=true
    // Test: both with running=true
  3. Clarify the commit message: "don't run code on non-time limited entries" doesn't clearly explain the baseEntry vs sizeLimitEntry change

  4. Update PR title to: "Fix running time check logic in bundle size script" (or similar)

Potential Regression Risk ⚠️

The size-limit report shows significant increases in running time (up to +165%):

  • registerServerComponent/client bundled (gzip): +165.46% 🔺
  • react-on-rails-pro/client bundled (gzip): +142.03% 🔺

Are these increases expected? Or are they related to the logic changes in this PR?


Bottom line: This needs clarification before merging. The logic change is subtle but potentially breaking. Please explain the intended behavior and add tests if possible.

cc: @AbanoubGhadban

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review

Summary

This PR adds running time checks to the bundle size CI workflow. The changes enable measurement of not just bundle size, but also loading/running time for JavaScript bundles.


Positive Aspects

  1. Good Fix for Time Check Logic (Line 104-106 in bundle-size.mjs)

    • Fixed the conditional from !sizeLimitEntry.running to !baseEntry.running
    • This correctly checks if the base entry has running time data before adding time limits
  2. Clean Workflow Integration

    • The build-for-size-limit script cleanly copies the config before building
  3. Proper Cleanup

    • Removed the temporary temp.js file

CRITICAL Issue: Workflow Logic Bug

Problem: The workflow has a config overwrite bug at line 114 in bundle-size.yml

Current flow:

  • Line 106: Set dynamic limits (updates .size-limit.json)
  • Line 114: build-for-size-limit copies /tmp config AGAIN, overwriting dynamic limits!

This is a BUG! The dynamic limits set in line 106 are being overwritten before the size check runs.

Fix Required - Choose one:

Option 1: Use regular build script

build_script: build

Option 2: Update temp file after setting limits

node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json
cp .size-limit.json /tmp/size-limit-config.json

Other Issues

MEDIUM: Path Assumptions

  • The build-for-size-limit script assumes /tmp/size-limit-config.json exists
  • Will fail if run outside CI context
  • Add error handling or CI check

LOW: Missing Tests

  • No unit tests for createLimitEntry function changes
  • Should test entries with/without running time data

LOW: Performance

  • Workflow builds twice (lines 76 and 114)
  • Consider caching build outputs

Priority Actions

  1. HIGH: Fix the config overwrite bug (critical issue above)
  2. MEDIUM: Add error handling to build-for-size-limit script
  3. LOW: Add unit tests
  4. LOW: Optimize redundant builds

Conclusion

The core logic fix is correct, but there is a critical workflow bug where dynamic limits are overwritten. Please fix before merging.

Great work on adding time measurement!

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review Feedback

Overview

This PR implements runtime performance checking in the bundle size CI workflow and includes cleanup of temporary files.


Positives

  1. Smart workflow optimization: The new build-for-size-limit script prevents duplicate builds
  2. Critical bug fix: The change from !sizeLimitEntry.running to !baseEntry.running fixes a logic error
  3. Proper cleanup: Removal of temp.js file

Critical Issues

1. Misleading PR Title

  • Current: Add running time check on CI
  • Problem: The title suggests adding a new feature, but this is actually fixing existing logic
  • Evidence: .size-limit.json already has running: true on all entries
  • Recommendation: Update to Fix running time check and optimize bundle size workflow

2. Missing PR Description
The PR body is empty. Please add context about what bug was fixed and why.


Code Quality Issues

3. Logic Bug Fix (scripts/bundle-size.mjs:104-105)

The fix is correct - checking baseEntry.running instead of sizeLimitEntry.running. However, there's a design issue: we're always creating sizeLimitEntry with running: false, which means the output config won't have running: true even when time limits are added.

Consider preserving the running flag from baseEntry.

4. Workflow Complexity

The workaround of copying .size-limit.json to /tmp and back adds hidden coupling. If someone runs pnpm build-for-size-limit locally without the file in /tmp, it will fail silently.

Recommendation: Add a safety check or document this dependency in comments.


Best Practices

5. Missing Tests
According to CLAUDE.md, infrastructure code should be tested. Please manually verify the running time logic works end-to-end.

6. Commit Message Quality

  • reverted temp.js - what was reverted?
  • don't run code on non-time limited entries - missing context
    Better: fix: check baseEntry.running instead of sizeLimitEntry.running

Security and Performance

  • No security concerns
  • Performance improvement: Avoids unnecessary rebuild in CI
  • No breaking changes

Action Items Before Merging

  1. Update PR title to accurately describe the changes
  2. Add PR description explaining the bug fix
  3. Verify running: false on line 104 is intentional
  4. Add safety check or documentation for build-for-size-limit
  5. Manually test the running time logic end-to-end

Overall: Solid bug fix with good workflow optimization. Main concerns are documentation and the subtle logic around the running flag.

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review

Hi @AbanoubGhadban! I've reviewed PR #2163. Here's my feedback:

📋 Summary

This PR fixes the bundle size CI workflow to properly check running time in addition to bundle size. The key fix is changing line 105 in scripts/bundle-size.mjs from checking entry.running to baseEntry.running.


✅ Positive Findings

  1. Critical Bug Fix: The logic error on line 105 is correctly fixed:

    • Before: if (\!sizeLimitEntry.running) - checked the wrong object
    • After: if (\!baseEntry.running) - correctly checks if base has running metrics

    This ensures running time checks are only created when the base entry actually has timing data.

  2. Improved Workflow: The new approach of copying .size-limit.json to /tmp before running size checks is cleaner and prevents race conditions where the file might be modified during the check.

  3. Clean Separation: The new build-for-size-limit script properly separates the build-with-limits step from regular builds.

  4. Good Cleanup: Removed the temp.js file that appears to have been leftover test/debug code.


🔍 Potential Issues & Questions

1. Missing Test Coverage

The bundle-size.mjs script has no tests. Since this bug went undetected, consider adding tests for the createLimitEntry function:

// Test cases to consider:
// - baseEntry with running property
// - baseEntry without running property (the bug scenario)
// - Verify limit calculation is correct
// - Verify time threshold calculation

2. File Path Dependency

The workflow now depends on /tmp/.size-limit-with-limits.json existing at a specific path. If step 106 ("Set dynamic limits") fails, step 108-109 will also fail. Consider:

  • Adding verification that the file was created
  • Or using a workflow artifact instead of /tmp
# Potential improvement:
- name: Set dynamic limits (base + 0.5KB)
  run: node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json
  
- name: Verify limits were set
  run: test -f .size-limit.json || exit 1

- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

3. Error Handling in build-for-size-limit

The new build-for-size-limit script doesn't handle the case where /tmp/.size-limit-with-limits.json doesn't exist:

"build-for-size-limit": "cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

If cp fails, the entire command fails. This is good for fail-fast, but might want clearer error messaging.

4. Documentation Gap

Consider adding a comment in .github/workflows/bundle-size.yml explaining why we copy the file to /tmp and restore it later. This workflow complexity might confuse future maintainers.


🎯 Testing Recommendations

Before merging, verify:

  1. Test with entries that have running times: Ensure time checks are created
  2. Test with entries without running times: Ensure only size limits are created (no crash)
  3. Test the full CI workflow: Run the bundle-size workflow end-to-end
  4. Check the copied file: Verify /tmp/.size-limit-with-limits.json contains expected limits

🔐 Security & Performance

✅ No security concerns
✅ No performance concerns - the changes are workflow-only


📝 Style & Conventions

According to CLAUDE.md:

  • ✅ Changes should trigger bundle exec rubocop - but these are JS/YAML files only, so N/A
  • ⚠️ Consider running pnpm run lint to verify ESLint compliance for the JS changes
  • ✅ File formatting looks correct

💡 Suggestions for Follow-up

  1. Add unit tests for scripts/bundle-size.mjs, especially createLimitEntry()
  2. Add inline comments explaining the /tmp file dance
  3. Consider consolidating the copy/restore logic into the script itself rather than the workflow

✨ Overall Assessment

This is a good fix for a legitimate bug. The logic error would have prevented running time checks from working when base entries lacked running metrics. The workflow improvements are sensible.

Recommendation: Approve with suggestions for follow-up improvements (tests, documentation).

Great work tracking this down! 🎉

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review - PR #2163

Summary

This PR makes changes to the bundle size CI workflow and fixes a bug in the bundle size script logic. However, there are critical issues that need to be addressed before merging.


🚨 Critical Issues

1. Major Workflow Bug - Runner Configuration

runs-on: node20  # Line 39

Problem: node20 is not a valid GitHub Actions runner. Valid options are:

  • ubuntu-latest, ubuntu-22.04, ubuntu-20.04
  • windows-latest, macos-latest, etc.

Impact: This workflow will fail immediately with "Unable to resolve action" error.

Fix Required: Change to:

runs-on: ubuntu-22.04

And add back the Node.js setup step that was removed:

- name: Setup Node
  uses: actions/setup-node@v4
  with:
    node-version: '22'

2. Misleading PR Title

  • Title: "Add running time check on CI"
  • Reality: This fixes existing logic + removes temp file + changes workflow

The running time check already exists (all entries in .size-limit.json have running: true). This PR is fixing a bug where time checks weren't created for entries where the base branch lacked running data.

Recommended Title: "Fix bundle size workflow and running time check logic"


📝 Code Quality Issues

3. Logic Fix is Correct but Needs Testing (scripts/bundle-size.mjs:105)

// Changed from:
if (!sizeLimitEntry.running) {
// To:
if (!baseEntry.running) {

This fix is correct. It properly checks whether the base entry has running time data before attempting to create time-based limits.

Missing tests: This critical logic has no unit tests. According to CLAUDE.md, infrastructure code should be tested.

4. Unnecessary Complexity in Workflow

The workflow now:

  1. Sets dynamic limits (line 101)
  2. Copies .size-limit.json to /tmp (line 104)
  3. Uses build-for-size-limit which copies it back (package.json:79)

Question: Why copy to /tmp if we're immediately using it in the next step? The size-limit-action runs in the same job, so the file should still be there.

Potential simplification: Just use regular build script and remove the copy/restore logic.


🐛 Additional Issues

5. Missing Error Handling

"build-for-size-limit": "cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

If run locally (outside CI), this will fail with "No such file or directory". Consider adding:

"build-for-size-limit": "test -f /tmp/.size-limit-with-limits.json && cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

6. Empty PR Description

The PR body is completely empty. According to CLAUDE.md best practices, please add:

  • What bug this fixes
  • Why the change from sizeLimitEntry.running to baseEntry.running
  • Why the workflow changes were needed

✅ Positive Aspects

  1. Good cleanup: Removing temp.js file
  2. Correct logic fix: The baseEntry.running check is the right fix
  3. No security concerns: Changes are isolated to CI workflow

🧪 Testing Required

Before merging, please:

  1. Test the workflow runs successfully with the runner fix applied
  2. Verify the script works for both entries with and without running time data
  3. Run locally: node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json (create test base-sizes.json)
  4. Check CI passes: Ensure all checks pass after fixing the runner issue

📋 Action Items

Must fix before merge:

  1. ❌ Change runs-on: node20 to runs-on: ubuntu-22.04
  2. ❌ Add back Node.js setup step or explain why it's not needed
  3. ❌ Add PR description explaining the changes
  4. ❌ Update PR title to accurately reflect changes

Should address:
5. ⚠️ Add tests for createLimitEntry function
6. ⚠️ Simplify workflow or document why the /tmp copy is necessary
7. ⚠️ Add error handling to build-for-size-limit script


Recommendation

BLOCK MERGE until critical issue #1 (invalid runner) is fixed. The workflow will not run with runs-on: node20.

Once fixed and tested, this will be a good improvement. The core logic fix is sound.


According to CLAUDE.md:

  • ✅ File changes look good (JS/YAML only, no Ruby)
  • ⚠️ Run pnpm run lint to verify formatting
  • ✅ No security concerns identified

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review Feedback

Thank you for working on adding running time checks to CI! Here's my detailed review:

🚨 Critical Issues

1. Invalid GitHub Actions Syntax (Blocking)

runs:
  using: 'node20'

This is incorrect syntax. The runs key is for custom actions, not workflow jobs. This will cause the workflow to fail immediately.

Fix:

runs-on: ubuntu-22.04

You accidentally replaced runs-on with runs. This needs to be reverted.


2. Missing Node.js Setup Step

You removed the Node.js setup step but pnpm and other tools depend on it:

# This was removed but is needed:
- name: Setup Node
  uses: actions/setup-node@v4
  with:
    node-version: '22'

Why this matters: While pnpm/action-setup can install Node, it's better to be explicit and use the standard setup-node action for consistency with other workflows.


🐛 Bugs & Logic Issues

3. Incorrect Variable Reference in bundle-size.mjs

Line 105 in scripts/bundle-size.mjs:

if (!baseEntry.running) {  // ✅ Correct - checking baseEntry

Good catch! The original code had:

if (!sizeLimitEntry.running) {  // ❌ Wrong - sizeLimitEntry doesn't have 'running'

This is a valid bug fix. However, it should be mentioned in the PR description.


⚠️ Design & Architecture Concerns

4. Confusing Workflow - File Copying Between Steps

The new workflow:

  1. Sets dynamic limits → writes to .size-limit.json
  2. Copies to /tmp/.size-limit-with-limits.json
  3. Runs build-for-size-limit which copies it back

This is unnecessarily complex and fragile:

  • The file is being passed through /tmp between steps
  • The build-for-size-limit script assumes /tmp/.size-limit-with-limits.json exists
  • If any step fails, you have orphaned temp files

Better approach:

  • Just run the build directly after setting limits
  • Don't copy to /tmp and back
  • Keep the modified .size-limit.json in place

Suggested simplification:

- name: Set dynamic limits (base + 0.5KB)
  run: node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json

- name: Check bundle size
  uses: andresz1/size-limit-action@v1
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    package_manager: pnpm
    build_script: build
    skip_step: install

Remove the new build-for-size-limit script entirely.


5. Deleted File Without Explanation

packages/react-on-rails-pro/temp.js was deleted. This appears unrelated to the PR's purpose.

Questions:

  • Why was this file deleted?
  • Is this cleanup or does it affect the functionality?
  • Should this be in a separate PR?

📝 Missing Documentation

6. Empty PR Description

The PR description is completely empty. Based on CLAUDE.md requirements:

Required information:

  • What problem does this solve?
  • What changes were made?
  • How was it tested?
  • Why the bug fix in bundle-size.mjs?

🧪 Testing Concerns

7. No Evidence of Local Testing

Per CLAUDE.md critical requirements:

CRITICAL - LOCAL TESTING REQUIREMENTS:

  1. NEVER claim a test is "fixed" without running it locally first

Required before merge:

# Test the workflow locally or explain why you can't
# At minimum, test the script:
node scripts/bundle-size.mjs set-limits --base /tmp/test-sizes.json

# Test the new package.json script:
cp .size-limit.json /tmp/.size-limit-with-limits.json
pnpm run build-for-size-limit

Document in PR:

  • What testing was done?
  • Were there any CI runs that validated this?

🎯 Summary

Must fix before merge:

  1. ❌ Fix runs:runs-on: ubuntu-22.04
  2. ❌ Restore Node.js setup step
  3. ❌ Add PR description explaining changes
  4. ⚠️ Consider simplifying the workflow (remove temp file copying)

Good changes:

  • ✅ Bug fix in bundle-size.mjs (line 105) - checking baseEntry.running instead of entry.running

Questions needing answers:

  • Why was temp.js deleted?
  • Has this been tested locally or in CI?
  • Why the complex file copying approach?

📚 References

Please address the critical issues and update the PR description with context about these changes. Happy to review again once updated!

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review: Add Running Time Check on CI

Overview

This PR disables running time limits in the CI bundle size checks while keeping the configuration in place for potential local use. The approach taken is pragmatic and addresses a real environmental difference between the limit-setting script and the size-limit action.


Strengths

  1. Clear Problem Statement: The TODO comment clearly explains why time limits are disabled on CI - different execution environments produce incomparable timing values.

  2. Minimal Impact: The change only affects time-based limits, not size limits, which continue to work correctly.

  3. Preserves Local Functionality: By checking process.env.CI rather than removing time limit code entirely, local developers can still benefit from time limits if running the script locally.

  4. Proper Workflow: The new build-for-size-limit script correctly copies the limits file before building, ensuring the action uses the right configuration.


🔍 Issues & Suggestions

1. Logic Issue in Time Limit Condition ⚠️

Location: scripts/bundle-size.mjs:108

if (\!baseEntry.running || process.env.CI) {
  return sizeLimitEntry;
}

Problem: The condition \!baseEntry.running || process.env.CI has a subtle issue. According to your .size-limit.json, ALL entries have "running": true. This means:

  • When baseEntry.running === true (which it always is), \!baseEntry.running is false
  • So the first part of the OR never triggers
  • Time limits are only skipped when process.env.CI is truthy

However, this exposes a logical inconsistency: if an entry doesn't have running: true in the config, you'd skip time limits even locally, which might not be intended.

Suggested fix:

// Skip time limit on CI because this script runs on a different environment than the `andresz1/size-limit-action`
// So, this script calculates different timing values than those obtained by the `andresz1/size-limit-action` action
// TODO: fork `andresz1/size-limit-action` and add time limits on the same environment used to run the check
if (\!baseEntry.running) {
  // Entry doesn't measure running time at all
  return sizeLimitEntry;
}

if (process.env.CI) {
  // Skip time limits on CI due to environment differences
  return sizeLimitEntry;
}

This makes the logic clearer and separates the two concerns.

2. File Copy Timing Risk ⚠️

Location: .github/workflows/bundle-size.yml:108-109 and package.json:79

The workflow copies .size-limit.json to /tmp/.size-limit-with-limits.json AFTER setting limits, then the build script copies it back. This creates a risk:

Potential Issue: If the build-for-size-limit script runs before the file is copied to /tmp, or if multiple jobs run concurrently, you could have race conditions.

Why it works now: The workflow steps are sequential, so this is safe in the current implementation.

Suggestion: Consider renaming the build script to make its dependency clearer:

"build-for-size-limit": "cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

Or add a comment in the workflow explaining the dependency:

# Copy limits file to temp location so build-for-size-limit can restore it
- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

3. Typo in Comment

Location: scripts/bundle-size.mjs:107

// TODO: fork `andresz1/size-limit-action` and make it time limits on the same environment used to run the check

Should be: "and add time limits" or "and enable time limits" (not "make it time limits")

4. Missing Deletion Justification

Location: packages/react-on-rails-pro/temp.js (deleted)

The deleted temp.js file appears unrelated to this PR's goal. While it's good to clean up temporary files, it would be helpful to mention this in the PR description or commit message for clarity.


🛡️ Security Considerations

✅ No security concerns. The changes:

  • Don't introduce user input handling
  • Don't modify authentication/authorization
  • Don't expose sensitive data
  • Use environment variables appropriately

Performance Considerations

Positive Impact: Disabling unreliable time checks prevents false positives that would block PRs unnecessarily.

⚠️ Trade-off: You lose runtime performance regression detection in CI. The TODO comment acknowledges this needs a better solution.

Recommendation: Consider tracking this TODO in an issue so it doesn't get forgotten. Runtime performance regression detection is valuable when done correctly.


🧪 Test Coverage

⚠️ No tests for the script changes

Suggestions:

  1. Add a test case that verifies process.env.CI properly disables time limits
  2. Test that size limits are still set correctly when CI=true
  3. Add a test for the \!baseEntry.running path

Example test structure:

// test/bundle-size.test.mjs
describe('createLimitEntry', () => {
  it('skips time limits when CI is set', () => {
    process.env.CI = 'true';
    const result = createLimitEntry(
      { name: 'test', running: true },
      { size: 1000, running: 0.5, loading: 0.3 },
      512,
      0.2
    );
    expect(result).not.toHaveProperty('limit', expect.stringContaining('ms'));
    delete process.env.CI;
  });
});

📋 Compliance with CLAUDE.md

Follows project guidelines:

  • Changes are focused and minimal
  • Comments explain the "why"
  • TODO provides a path forward

⚠️ Consider adding:

  • Entry in CHANGELOG.md (if this is user-facing)
  • Update to documentation about bundle size checks

🎯 Recommendations

  1. High Priority: Fix the logic condition in scripts/bundle-size.mjs:108 to separate the two concerns
  2. Medium Priority: Fix the typo in the TODO comment
  3. Low Priority: Add test coverage for the script logic
  4. Low Priority: Create a GitHub issue for the TODO to ensure follow-up

Approval Status

The changes are functionally sound and achieve the stated goal of disabling unreliable time checks on CI. The logic issue identified is minor and doesn't affect the current behavior (since all entries have running: true), but should be fixed for code clarity and future maintainability.

Recommended action: Address the logic separation suggestion, then this is ready to merge.

@AbanoubGhadban AbanoubGhadban changed the base branch from add-running-time-check-on-ci-base to master December 3, 2025 11:51
@size-limit/time is not accurate at all in detecting changes in runtime
@AbanoubGhadban
Copy link
Collaborator Author

Seems that @size-limit/time is not accurate at all in detecting the changes in runtime. We need to use another solution that the code multiple times and get the average runtime value to avoid the runtime noise. So, we only used the @size-limit/time for measuring the download time which seems that the plugin is good at measring it.

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review - PR #2163: Add running time check on CI

📊 Summary

This PR extends the existing bundle size CI check to also monitor JavaScript execution time (loading + running). It tracks performance regressions by comparing the total execution time of client-side imports between the PR and base branch, failing if any import increases by more than 20%.


✅ Strengths

  1. Smart Architecture

    • Reuses existing bundle-size infrastructure elegantly
    • The createLimitEntry function conditionally creates time entries only when running: false is set, showing good defensive programming (scripts/bundle-size.mjs:99-123)
    • Dynamic limit generation prevents hardcoded thresholds
  2. Clean Simplification

    • Removed 158 lines of comparison logic that's now handled by size-limit itself
    • Deleted the compare command - simplified the API surface
    • The workflow change to use build-for-size-limit script is clever - it restores the dynamic limits before building
  3. Good Integration

    • bin/compare-bundle-sizes updated to use the same approach as CI (lines 66-70)
    • Added cleanup for .size-limit.json restoration (line 28)
    • CONTRIBUTING.md documentation updated appropriately
  4. Configuration Clarity

    • All entries in .size-limit.json now explicitly set running: false, making intent clear
    • Removed redundant raw/gzip/brotli entries for non-bundled files (good cleanup)

⚠️ Issues & Concerns

1. Critical: File Restoration Logic May Be Flawed

Location: bin/compare-bundle-sizes:28, .github/workflows/bundle-size.yml:108-109,117

Issue: The workflow copies .size-limit.json to /tmp/.size-limit-with-limits.json (line 109), then the build-for-size-limit script is supposed to restore it (package.json:79). However:

"build-for-size-limit": "cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

Problem: This only works if the temp file exists. In local development or if the workflow step fails, this will break. Also, the bin/compare-bundle-sizes script uses git restore .size-limit.json in cleanup (line 28), which may conflict with uncommitted changes.

Recommendation:

  • Add error handling: cp /tmp/.size-limit-with-limits.json .size-limit.json 2>/dev/null || true
  • Or better: make build-for-size-limit check if the file exists first
  • Consider adding a comment explaining why this indirection is needed

2. Typo in Comment

Location: scripts/bundle-size.mjs:21

// 20% is a big ration, but the current approach is not accurate enough

Fix: "ration" → "ratio"

3. Potential Timing Accuracy Issues

Location: scripts/bundle-size.mjs:109-114

const { loading, running } = baseEntry;
const loadingMs = loading * 1000;
const runningMs = running * 1000;

Concerns:

  • size-limit's time measurements can vary significantly between runs (V8 warmup, system load, etc.)
  • 20% threshold is very loose (as the comment acknowledges)
  • No documentation on what "loading" vs "running" actually measures
  • The base measurements are taken once - what if they're an outlier?

Questions:

  • Should we run size-limit multiple times and average the results?
  • Should there be documentation about when this will/won't catch regressions?
  • Are there any size-limit configuration options to make timing more stable?

4. Missing Validation

Location: scripts/bundle-size.mjs:99-123

The code assumes:

  • baseEntry.running exists if it's truthy
  • baseEntry.loading and baseEntry.running are numbers

Recommendation: Add validation:

if (\!baseEntry.running || typeof baseEntry.loading \!== 'number' || typeof baseEntry.running \!== 'number') {
  console.log(`  Skipping time check - invalid timing data`);
  return sizeLimitEntry;
}

5. Changelog Entry Confusion

Location: CHANGELOG.md:28

The changelog says "Compares PR client import execution times against the base branch and fails if any import increases by more than 20%."

But looking at .size-limit.json, all entries have "running": false, which means NO time limits will be created by createLimitEntry (line 105-107 returns early).

Critical Question: Is this intentional (time checking disabled for now) or a bug? If intentional, the changelog entry is misleading.

6. Documentation Gaps

Missing:

  • How to enable time checking (set running: true in .size-limit.json?)
  • What do the time measurements actually represent?
  • Why is 20% the chosen threshold?
  • Expected behavior when time limits are enabled
  • How to debug timing issues locally

🔍 Testing Concerns

Per CLAUDE.md critical requirements, have you tested this locally?

Required local testing checklist:

  • Run bin/compare-bundle-sizes with time checking enabled (running: true)
  • Verify the cleanup in bin/compare-bundle-sizes doesn't lose uncommitted changes
  • Test pnpm run build-for-size-limit when /tmp/.size-limit-with-limits.json doesn't exist
  • Verify size-limit actually measures and enforces time limits
  • Test with an intentional performance regression (add delay in a component)

From CLAUDE.md: "NEVER claim a test is 'fixed' without running it locally first"

Question: Can you confirm you've tested time limit enforcement locally, not just bundle size?


🎯 Security Considerations

No security issues identified. The changes are limited to CI configuration and build scripts.


📈 Performance Considerations

Positive: No runtime performance impact - this is CI-only

Neutral: CI time may increase slightly if time measurements take longer to stabilize


🧪 Test Coverage

Missing:

  • No tests for createLimitEntry function
  • No tests for time limit generation logic
  • No tests for the new build-for-size-limit script

Recommendation: Consider adding unit tests for scripts/bundle-size.mjs, especially:

  • Time limit calculation with various thresholds
  • Behavior when running is false vs true vs missing
  • Edge cases (zero times, negative times, missing properties)

📝 Recommendations Summary

Must Fix:

  1. Clarify why all entries have running: false - is time checking actually enabled?
  2. Fix typo: "ration" → "ratio"
  3. Add validation for time properties before using them
  4. Document how to enable/use time checking

Should Fix:

  1. Add error handling to build-for-size-limit script
  2. Add tests for the new time limit logic
  3. Document timing accuracy limitations
  4. Consider averaging multiple runs for stable baselines

Nice to Have:

  1. Add examples of what kind of changes trigger time limit failures
  2. Document the cleanup behavior in bin/compare-bundle-sizes

🎬 Conclusion

The architecture is solid and the simplification is welcome. However, there's a critical disconnect between what the PR claims to add ("running time check") and what's actually enabled (all entries have running: false).

Recommendation: Either:

  1. Enable time checking by setting running: true for at least some entries and verify it works, OR
  2. Update the PR title/description to clarify this is infrastructure preparation for time checking (not yet active)

Once the running: false confusion is clarified and the typo is fixed, this should be good to merge.


Reviewed with reference to: CLAUDE.md critical requirements, testing guidelines, and CI best practices.

@AbanoubGhadban AbanoubGhadban changed the base branch from master to add-running-time-check-on-ci-base December 3, 2025 11:59
@claude
Copy link

claude bot commented Dec 3, 2025

Code Review: Add Running Time Check on CI

Overview

This PR adds execution time monitoring to the bundle size CI workflow, introducing a 20% threshold for performance regressions. The implementation is solid overall with good architectural decisions.


Strengths

  1. Smart workaround for size-limit-action limitation: The approach of copying .size-limit.json to /tmp and creating a build-for-size-limit script is clever. This avoids modifying the third-party action while preserving the dynamic limit configuration.

  2. Appropriate threshold choice: The 20% time threshold (vs 0.5KB for size) acknowledges measurement variability in timing tests. The inline comment explaining this rationale is helpful.

  3. Correct bug fix in scripts/bundle-size.mjs:105: Changing from !sizeLimitEntry.running to !baseEntry.running is correct - you need to check if the base entry has timing data, not the current entry being constructed.

  4. Clean separation of concerns: Disabling running: false in .size-limit.json by default and only enabling it via the script keeps the config file clean and makes the workflow explicit.


🔍 Issues & Suggestions

1. Documentation Gap (Minor)

The CONTRIBUTING.md section on "Bundle Size Checks" should be updated to mention execution time monitoring.

Impact: Low - users might be confused when CI reports time-based failures without documentation.


2. Missing Error Handling for Time Limits (Medium)

In scripts/bundle-size.mjs:115-122, when running: true is detected, the code returns a flat array with both size and time entries. However, if baseEntry.running is false, only a single entry is returned.

Potential issue: If the base branch has running: false but the PR branch sets running: true, the time limit will be set based on base measurements that do not exist. This could cause confusing CI failures.

Impact: Medium - edge case but could confuse contributors during workflow changes.


3. Temp File Cleanup (Low)

The workflow creates /tmp/.size-limit-with-limits.json (line 109) but never explicitly cleans it up. While GitHub Actions runners clean /tmp between runs, it would be better to be explicit with cleanup.

Impact: Very Low - purely cosmetic since GitHub runners reset state.


4. Consider Logging Time Limit Value (Low)

In scripts/bundle-size.mjs:112-113, you log the base times but not the computed limit. Adding this would help debugging.

Impact: Low - quality-of-life improvement for debugging CI failures.


🧪 Testing Considerations

Question: Has this been tested with an actual performance regression? The 20% threshold seems reasonable but might need tuning based on real-world variance.


🎯 Architectural Decisions

  1. Why disable running by default? ✅ Good choice - avoids spurious CI failures from timing variance on every PR.

  2. Why copy to /tmp instead of modifying in place? ✅ Correct - the size-limit-action runs build which would overwrite the file. The temp copy preserves dynamic limits.

  3. Why build-for-size-limit instead of modifying the action? ✅ Smart - keeps the third-party action unmodified and makes the workflow transparent.


📝 Nitpicks

  1. Line 21 in scripts/bundle-size.mjs: "big ration" should be "big ratio" (typo in existing code, not introduced by this PR)

  2. The deleted temp.js file - good cleanup! Was this a test file?


Verdict

Approve with minor suggestions. The core implementation is sound and the architectural decisions are well-reasoned. The identified issues are minor and do not block merging:

Recommendation: Merge as-is and address documentation in a follow-up, unless you want to add the error handling for completeness.

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review - PR #2163

I've reviewed this PR and have feedback on code quality, implementation approach, and potential issues.

Positive Aspects

  1. Good Problem Recognition: Correctly identified that @size-limit/time plugin is unreliable on CI due to runtime noise
  2. Pragmatic Decision: Focusing on download time (deterministic) rather than execution time (noisy) is sensible
  3. Preserved Local Testing: Keeping execution time measurement capability in the script for local use is valuable
  4. Clean Refactor: The changes to bundle-size.mjs improve robustness with defensive defaults

Critical Issues

1. Workflow Complexity and Fragility (High Priority)

The new workflow introduces a complex file copying pattern. Lines 108-109 copy config to /tmp, then line 117 uses a custom build script that copies it back. This creates circular file copying where the build script silently overwrites .size-limit.json.

Problems:

  • CI-specific build script that can't be tested locally in normal workflow
  • Hidden mutation during build
  • Fragile state management

Better approach: Check if size-limit-action supports a --config parameter to pass /tmp/.size-limit-with-limits.json directly, or inline the build steps instead of using the action.

2. Logic Error in bundle-size.mjs (Medium Priority)

Line 105-106 checks baseEntry.running and baseEntry.loading to decide if timing should be enabled. This checks the base branch measurement instead of the current entry config (entry.running).

Why it matters: If entry.running = true but baseEntry.running = false, timing limits won't be created, making behavior inconsistent with .size-limit.json config.

Correct logic should check entry.running first, then verify baseEntry has timing data.

3. Defensive Defaults Have Side Effects (Low Priority)

Line 109 silently defaults missing loading/running to 0. Previously this would error. This could hide configuration issues.

Better: Explicitly check for undefined and warn.

Minor Issues

  1. Missing Documentation: PR mentions bin/compare-bundle-sizes script capability but no docs updated
  2. Unexplained temp.js Deletion: No context about why this file existed or if it's related

Testing Concerns

Per CLAUDE.md: Build scripts MUST be tested manually. Required:

  • Test clean install: rm -rf node_modules && pnpm install --frozen-lockfile
  • Test new build script: pnpm run build-for-size-limit
  • Verify normal build still works: pnpm run build

Questions: Has build-for-size-limit been tested locally? What happens if run outside CI?

Recommendation

Request changes for issues 1 and 2. The core logic change (disabling running: false) is correct, but the CI workflow needs simplification to be maintainable.

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review

Thank you for this PR! I've reviewed the changes and have the following feedback:

✅ Positive Aspects

  1. Good pragmatic approach: Recognizing that @size-limit/time plugin has too much runtime noise on CI and pivoting to download time monitoring is the right call.

  2. Reduced threshold: Lowering from 20% to 10% for time threshold is more strict and will catch regressions earlier.

  3. Local testing capability preserved: Keeping the execution time comparison feature in bin/compare-bundle-sizes for local use is smart.

  4. Cleanup: Removing the unused temp.js file is good housekeeping.

🐛 Critical Issue - Duplicate Step in Workflow

Location: .github/workflows/bundle-size.yml lines 108-112

There's a duplicate step that copies the size-limit config file:

- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

Action Required: Remove one of these duplicate steps (lines 111-112).

⚠️ Potential Issues

1. Defensive Programming - Null Safety

Location: scripts/bundle-size.mjs line 105

The condition change from:

if (!sizeLimitEntry.running) {

to:

if (!baseEntry.running && !baseEntry.loading) {

This is checking baseEntry properties, but then line 109 uses default values for optional properties:

const { loading = 0, running = 0 } = baseEntry;

Recommendation: The logic is correct, but consider if the condition should be:

if (!baseEntry.running && !baseEntry.loading) {
  return sizeLimitEntry;
}

This properly checks the base entry (which is what you're comparing against) rather than the size limit entry. However, this change appears intentional and correct given the context.

2. Build Script Coordination

Location: package.json line 79

New script added:

"build-for-size-limit": "cp /tmp/.size-limit-with-limits.json .size-limit.json && pnpm build"

Consideration: This script modifies .size-limit.json in the working directory during CI. While this works, ensure this doesn't cause issues if:

  • Multiple jobs run in parallel (shouldn't be an issue in this workflow)
  • Local developers accidentally run this command (it would overwrite their config with CI limits)

Suggestion: Add a comment in package.json or document this script is CI-only.

📝 Minor Improvements

1. Typo in Comment

Location: scripts/bundle-size.mjs line 21

// 10% is a big ration, but the current approach...

Should be: "ratio" not "ration"

2. Changelog Entry

Location: CHANGELOG.md line 28

The changelog update correctly reflects the pivot from execution time to download time monitoring. Good documentation!

🧪 Testing Recommendations

Before merging, please verify:

  1. Workflow syntax: Ensure the workflow runs successfully with the duplicate step removed
  2. Build artifacts: Confirm build-for-size-limit script produces expected artifacts
  3. Size limit action: Verify the action correctly reads the limits from the modified config file

📊 Security & Performance

  • ✅ No security concerns identified
  • ✅ No performance regressions expected
  • ✅ Changes are appropriately scoped to CI and tooling

Summary

This is a well-reasoned pivot from a noisy execution time measurement approach to a more reliable download time monitoring solution. The main issue is the duplicate workflow step that needs to be removed. Otherwise, the implementation looks solid.

Action Items:

  1. ❗ Remove duplicate step in .github/workflows/bundle-size.yml (lines 111-112)
  2. Fix typo: "ration" → "ratio" in scripts/bundle-size.mjs
  3. Consider documenting that build-for-size-limit is CI-only

Great work on recognizing the limitations of the initial approach and adapting accordingly! 🎉

@claude
Copy link

claude bot commented Dec 3, 2025

Code Review Feedback for PR #2163

Thanks for your work on improving the bundle size monitoring! I've reviewed the changes and have the following feedback:

🎯 Overall Assessment

The PR effectively addresses the limitations of runtime execution time measurement in CI by focusing on download time monitoring instead. The changes are well-reasoned and properly documented.


Strengths

  1. Good Problem Analysis: The PR description clearly explains why execution time monitoring was disabled (runtime noise on CI) and provides a pragmatic alternative (download time monitoring).

  2. Preservation of Capability: The execution time measurement feature is preserved in the local bin/compare-bundle-sizes script, which can be manually enabled by changing running values to true in .size-limit.json.

  3. Documentation: The CHANGELOG.md update accurately reflects the change from "Execution Time" to "Download Time" monitoring.

  4. Cleanup: Removal of packages/react-on-rails-pro/temp.js is good housekeeping.


🐛 Issues Found

Critical: Duplicate Step in Workflow

# Lines 108-112 in .github/workflows/bundle-size.yml
- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

- name: Copy .size-limit.json file with limits to tmp directory
  run: cp .size-limit.json /tmp/.size-limit-with-limits.json

Action Required: Remove the duplicate step (lines 111-112).


🔍 Code Quality Observations

1. Typo in Comment

// scripts/bundle-size.mjs:21
// 10% is a big ratio, but the current approach is not accurate enough to detect rations less than that

Suggestion: Change "rations" to "ratios".

2. Logical Improvement in bundle-size.mjs

// Line 105 - BEFORE
if (!baseEntry.running && !baseEntry.loading) {
  return sizeLimitEntry;
}

// Line 109 - AFTER
const { loading = 0, running = 0 } = baseEntry;

The logic change from !baseEntry.running && !baseEntry.loading improves handling of undefined/missing values. However, consider the semantic clarity:

Current behavior: Skip time limits if BOTH running AND loading are falsy
Clearer intent: Skip time limits if NEITHER running NOR loading exist

Suggestion: Consider this more explicit check:

if (!baseEntry.running && !baseEntry.loading) {
  return sizeLimitEntry;
}
// Even better with the defaults:
const { loading = 0, running = 0 } = baseEntry;
if (loading === 0 && running === 0) {
  return sizeLimitEntry;
}

This makes the intent clearer: "only create time limit entries if we have actual time measurements."

3. Workflow Job Rename

The rename from size to check-bundle-size is good for clarity, but ensure any dependent workflows or documentation are also updated.


🧪 Testing Recommendations

Based on CLAUDE.md testing requirements:

  1. Test the workflow locally if possible:

    # Simulate the CI workflow
    pnpm install --frozen-lockfile
    pnpm run build
    pnpm exec size-limit --json > /tmp/base-sizes.json
    node scripts/bundle-size.mjs set-limits --base /tmp/base-sizes.json
    cp .size-limit.json /tmp/.size-limit-with-limits.json
    pnpm run build-for-size-limit
  2. Verify the new build script works correctly:

    # Test the new build-for-size-limit script
    pnpm run build-for-size-limit
  3. Test the local comparison tool with running time enabled:

    # Modify .size-limit.json to set running: true
    bin/compare-bundle-sizes master

📋 Pre-Commit Checklist

Per CLAUDE.md requirements:

  • Run bundle exec rubocop (Ruby linting)
  • Run pnpm run format.listDifferent (check formatting)
  • Ensure all files end with newlines
  • Test affected scripts manually (especially build-for-size-limit)

🚀 Performance Considerations

The change from 20% to 10% threshold (DEFAULT_TIME_PERCENTAGE_THRESHOLD) is good for catching regressions earlier, but since this only applies to local testing (not CI), the impact is minimal. Consider documenting this threshold choice in the script's header comment.


🔒 Security Concerns

No security issues identified. The changes are limited to build/CI configuration and don't introduce any user-facing vulnerabilities.


✏️ Suggested Changes Summary

  1. MUST FIX: Remove duplicate workflow step (lines 111-112)
  2. SHOULD FIX: Correct typo "rations" → "ratios" in comment
  3. CONSIDER: Add clarity to the time limit skipping logic
  4. VERIFY: Test build-for-size-limit script works as expected

📝 Additional Notes

  • The approach of disabling runtime checks in CI while preserving them for local testing is pragmatic and well-documented.
  • The 10% threshold for download time is appropriately conservative given measurement accuracy limitations.
  • Good job maintaining backward compatibility by preserving the execution time measurement capability for local use.

Overall, this is a solid PR that addresses a real CI reliability issue. Please fix the duplicate workflow step before merging.

@AbanoubGhadban AbanoubGhadban changed the title Add running time check on CI Add loading time check on CI Dec 3, 2025
@AbanoubGhadban AbanoubGhadban merged commit 6bc3c0a into add-running-time-check-on-ci-base Dec 3, 2025
33 checks passed
@AbanoubGhadban AbanoubGhadban deleted the add-running-time-check-on-ci branch December 3, 2025 12:38
@AbanoubGhadban AbanoubGhadban restored the add-running-time-check-on-ci branch December 4, 2025 08:00
@AbanoubGhadban AbanoubGhadban deleted the add-running-time-check-on-ci branch December 4, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants