Skip to content

fix(ci): handle filtered size-limit results correctly#715

Merged
yamcodes merged 6 commits intomainfrom
copilot/fix-size-limit-results
Jan 9, 2026
Merged

fix(ci): handle filtered size-limit results correctly#715
yamcodes merged 6 commits intomainfrom
copilot/fix-size-limit-results

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

The size-limit action fails when results are filtered out due to package changes, treating filtered-empty results as a failure even when size-limit executed successfully on unchanged packages.

Changes

  • Error handling logic: Distinguish between results filtered out (pass), actual execution failures (fail), and missing configs (pass)
  • Introduce hasRelevantErrors: Separate "size-limit had errors" from "errors relevant to this PR's changed packages"
  • Fail only when: filtered results contain errors OR size-limit execution failed with no results

Scenarios Fixed

Before:

  • Changed: @arkenv/vite-plugin
  • Results: 1 result for arkenv (unchanged package)
  • Behavior: Filtered out → FAIL

After:

  • Same scenario → PASS ✅ (errors in unchanged packages are not relevant)

Still fails correctly:

  • No results + execution failure → FAIL
  • Results for changed packages exceed limits → FAIL
Original prompt

This section details on the original issue you should resolve

<issue_title>size-limit fails with no results found</issue_title>
<issue_description>1. https://github.com/yamcodes/arkenv/actions/runs/20853736686/job/59914804853?pr=710
2. https://github.com/yamcodes/arkenv/actions/runs/20854193573/job/59916348950?pr=704</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Bug Fixes
    • Refined error classification to surface only truly relevant failures and ignore informational/filtered results.
    • Introduced multi-branch decision flow to avoid false failures when results are absent or all checks pass.
    • CI outputs now reflect "relevant" errors before marking a run as failed.
    • Improved final logging and exit behavior so success, warning, and failure states are reported accurately.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

⚠️ No Changeset found

Latest commit: efdbe38

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Bot user detected.

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

Replace previous hasErrors-only decision with multi-branch logic that derives hasRelevantErrors and shouldFail from filtered results and error presence; update GitHub outputs call to use hasRelevantErrors; adjust logging and exit behavior accordingly.

Changes

Cohort / File(s) Summary
Action entrypoint / control flow
\.github/actions/size-limit/src/index\.ts
Replaced single hasErrors/length check with multi-branch logic introducing shouldFail and hasRelevantErrors. Handles: no filtered results vs. present results, no results + errors, no results + no errors, and filtered results (derive relevance from ❌ statuses). Adjusted logging and exit code paths.
Output API
\.github/actions/size-limit/src/output\.ts
Updated setGitHubOutputs signature to accept hasRelevantErrors instead of hasErrors; callers updated to pass the new argument.

Sequence Diagram(s)

sequenceDiagram
  participant Runner as GitHub Action Runner
  participant SizeLimit as size-limit process
  participant Index as index.ts (action logic)
  participant Output as output.ts (setGitHubOutputs)
  participant GitHub as GitHub Outputs / Actions

  Runner->>SizeLimit: execute size-limit
  SizeLimit-->>Index: return results (+ errors info)
  Index->>Index: compute filteredResults, hasErrors, hasRelevantErrors, shouldFail
  Index->>Output: setGitHubOutputs(result, hasRelevantErrors, packagesChanged)
  Index->>GitHub: emit logs (info/warn/fail)
  Index-->>Runner: exit (0 if !shouldFail, non-zero if shouldFail)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through results both thin and thick,
Filtered, missing, true or trick—
I counted ❌ and chose what's real,
I set the outputs, logged the deal.
A rabbit's nod: the action's slick. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing the CI's handling of filtered size-limit results, which directly addresses the core issue in the PR.
Linked Issues check ✅ Passed The PR successfully implements the fix for issue #712 by distinguishing between filtered results, execution failures, and missing configs, ensuring false failures are prevented.
Out of Scope Changes check ✅ Passed All changes are focused on fixing error handling logic in the size-limit action and updating the setGitHubOutputs method signature, which are directly related to the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Copilot AI and others added 2 commits January 9, 2026 16:19
- Handle case where size-limit results are filtered out due to package changes
- Don't fail when results exist but don't match changed packages
- Only fail when size-limit truly fails or limits are exceeded for changed packages
- Add clearer logging to distinguish different "no results" scenarios

This fixes failures in PRs where size-limit runs on packages but those
packages weren't actually changed, causing filtered results to be empty.

Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
- Rename finalHasErrors to hasRelevantErrors for clarity
- Add detailed comments explaining the error handling logic
- Distinguish between "should we fail" and "should we report errors"
- Make it clear that errors are only relevant if they apply to filtered results

Addresses code review feedback about variable naming and semantics.

Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix size-limit failure with no results found fix(ci): handle filtered size-limit results correctly Jan 9, 2026
Copilot AI requested a review from yamcodes January 9, 2026 16:24
@yamcodes yamcodes marked this pull request as ready for review January 9, 2026 20:20
@github-actions github-actions bot added the github actions Pull requests that update GitHub Actions code label Jan 9, 2026
@yamcodes
Copy link
Owner

yamcodes commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@arkenv-bot
Copy link
Contributor

arkenv-bot bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (Asia/Almaty)
arkenv Ready Ready Preview, Comment Jan 10 2026, 2:46 AM (Asia/Almaty)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/actions/size-limit/src/index.ts:
- Around line 83-125: The logic when filteredResults.length > 0 incorrectly uses
the global hasErrors flag to decide failure reporting; change it to inspect the
filteredResults array for per-result failures by setting hasRelevantErrors =
filteredResults.some(r => r.status === "❌") and then shouldFail =
hasRelevantErrors so only failures among the filtered set cause the workflow to
fail; update the block that currently assigns hasRelevantErrors = hasErrors and
shouldFail = hasErrors to use filteredResults instead (refer to symbols
filteredResults, hasErrors, hasRelevantErrors, shouldFail).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1e146e and ebe8a86.

📒 Files selected for processing (1)
  • .github/actions/size-limit/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (1)
.github/actions/size-limit/src/index.ts (1)
.github/actions/size-limit/src/output.ts (1)
  • setGitHubOutputs (24-37)
🪛 GitHub Actions: autofix.ci
.github/actions/size-limit/src/index.ts

[error] 1-1: The autofix.ci action is not allowed to modify the .github directory.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test-e2e (a11y)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (2)
.github/actions/size-limit/src/index.ts (2)

127-129: LGTM!

The change correctly propagates hasRelevantErrors to GitHub outputs, ensuring downstream consumers (PR comments, status checks) only see errors relevant to the changed packages.


131-137: LGTM!

The exit logic now correctly uses shouldFail to determine workflow outcome, decoupling the exit decision from the raw hasErrors flag.

- Changed failure logic to check for explicit failures (❌)
- Ensures CI fails only when size-limit has actual errors
- Handles cases where size-limit runs but finds no configs
@yamcodes
Copy link
Owner

yamcodes commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yamcodes
Copy link
Owner

yamcodes commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/actions/size-limit/src/index.ts (2)

98-132: Comment says “don’t report”, but outputs are still written unconditionally.
The branches explicitly say “don’t report” (Lines 102-103, 114-116), but you still always compute/print the table (Lines 81-83) and always call setGitHubOutputs(...) (Line 131). If downstream steps use outputs to decide PR comments, you may still emit an empty/irrelevant comment (especially when filteredResults is empty but packagesChanged === true).
Consider either:

  • early-returning before table/output in the “no relevant results” branches, or
  • adding a shouldReport flag and gating setGitHubOutputs (and possibly console.log(result)).
Proposed minimal gating refactor (keeps current logic intact)
@@
-// Create the table
-const result = createTable(filteredResults);
-console.log(result);
+// Create the table (but only report it when we actually have relevant results)
+const result = createTable(filteredResults);

@@
 let shouldFail = false;
 let hasRelevantErrors = false;
+let shouldReport = true;

 if (filteredResults.length === 0) {
 	if (results.length > 0) {
@@
 		console.log(
 			"ℹ️ Size checks ran but no results matched changed packages. This is expected when unchanged packages have size-limit configs.",
 		);
 		hasRelevantErrors = false;
 		shouldFail = false;
+		shouldReport = false;
 	} else if (hasErrors) {
@@
 		hasRelevantErrors = true;
 		shouldFail = true;
+		shouldReport = true;
 	} else {
@@
 		console.log(
 			"ℹ️ No size-limit results found. Packages may not have size-limit configured.",
 		);
 		hasRelevantErrors = false;
 		shouldFail = false;
+		shouldReport = false;
 	}
 } else {
@@
 	hasRelevantErrors = filteredResults.some((r) => r.status === "❌");
 	shouldFail = hasRelevantErrors;
 }
+
+if (shouldReport) {
+	console.log(result);
+}

 // Set GitHub outputs
 const packagesChanged = changedPackages === null || changedPackages.size > 0;
-await setGitHubOutputs(result, hasRelevantErrors, packagesChanged);
+if (shouldReport) {
+	await setGitHubOutputs(result, hasRelevantErrors, packagesChanged);
+}

123-127: Brittle error detection via status === "❌" string.
If status is user-facing (emoji) rather than a stable enum, this can silently break failure detection. Prefer a typed status enum/value (e.g., "ok" | "fail") and render emoji at the presentation layer (createTable).

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebe8a86 and c136c71.

📒 Files selected for processing (1)
  • .github/actions/size-limit/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (1)
.github/actions/size-limit/src/index.ts (1)
.github/actions/size-limit/src/output.ts (1)
  • setGitHubOutputs (24-37)
🔇 Additional comments (1)
.github/actions/size-limit/src/index.ts (1)

83-132: No issues found. The flagged critical issue does not exist.

The call setGitHubOutputs(result, hasRelevantErrors, packagesChanged) on line 131 correctly matches the function signature in output.ts lines 24-27: parameters are passed in the correct order with matching types (string, boolean, boolean). Parameter names do not enforce type matching in TypeScript—only order and type do.

The semantic use of hasRelevantErrors as the second argument (which the function parameter names hasErrors) is intentional and correct. The GitHub action output has_errors is set to the value of hasRelevantErrors, accurately reflecting whether there are errors relevant to the PR being checked.

The decision logic (lines 98–127) correctly distinguishes between execution failures (hasErrors from runSizeLimit) and business-logic failures (status checks in filtered results), ensuring that irrelevant errors from unchanged packages don't cause false positives.

- Report config errors even if no limits are breached
- Clarify when to fail CI based on errors
- Improve message for filtered results
@yamcodes
Copy link
Owner

yamcodes commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yamcodes
Copy link
Owner

yamcodes commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/actions/size-limit/src/index.ts (1)

134-139: Consider detecting config errors when filtered results exist.

This branch only checks for ❌ in filteredResults and ignores the global hasErrors flag. If size-limit had a config/execution error but the checked packages all passed, the error would go unreported.

You could apply the same heuristic used above for consistency:

} else {
    // We have filtered results - check if any failed
    hasRelevantErrors = filteredResults.some((r) => r.status === "❌");
    
    // Also detect config errors: hasErrors is true but no limits breached
    const allResultsPassed = results.every((r) => r.status !== "❌");
    if (!hasRelevantErrors && hasErrors && allResultsPassed) {
        console.log("⚠️ Size limit had a configuration or execution error.");
        hasRelevantErrors = true;
    }
    
    shouldFail = hasRelevantErrors;
}

This matches the PR's stated objectives ("fail only when filtered results contain errors OR when size-limit execution failed with no results"), so this is optional. The current code is correct per those objectives.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c136c71 and 14e9d60.

📒 Files selected for processing (1)
  • .github/actions/size-limit/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (1)
.github/actions/size-limit/src/index.ts (1)
.github/actions/size-limit/src/output.ts (1)
  • setGitHubOutputs (24-37)
🔇 Additional comments (3)
.github/actions/size-limit/src/index.ts (3)

83-96: Clear documentation of the decision logic.

The inline comments thoroughly explain the multi-branch decision flow. The variable names shouldFail and hasRelevantErrors clearly distinguish between workflow exit behavior and error reporting state.


98-133: Logic correctly handles the filtered-to-empty scenarios.

The heuristic at line 103-104 is sound: when hasErrors is true but all results passed, the error must stem from a configuration or execution issue rather than a limit breach. This correctly distinguishes:

  • Config/execution errors → fail (lines 104-109)
  • Limit breaches in unchanged packages filtered out → pass (lines 110-119)
  • No results + execution failure → fail (lines 120-124)
  • No results + success (no configs) → pass (lines 125-133)

143-151: Correctly propagates the new error semantics.

Passing hasRelevantErrors to setGitHubOutputs ensures the GitHub workflow outputs reflect only errors relevant to the PR's changed packages. Using shouldFail for the exit condition correctly decouples the workflow exit status from the raw hasErrors flag.

- Detects when size limit had errors but no limits breached
- Marks action as failed if config/execution errors exist
- Improves error reporting for size limit action
@yamcodes yamcodes merged commit 412e394 into main Jan 9, 2026
13 checks passed
@yamcodes yamcodes deleted the copilot/fix-size-limit-results branch January 9, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

size-limit fails with no results found

2 participants