Skip to content

fix: disable ANSI colors when GitHub reporter is auto-enabled#9236

Closed
slegarraga wants to merge 1 commit intobiomejs:mainfrom
slegarraga:fix/github-reporter-colors
Closed

fix: disable ANSI colors when GitHub reporter is auto-enabled#9236
slegarraga wants to merge 1 commit intobiomejs:mainfrom
slegarraga:fix/github-reporter-colors

Conversation

@slegarraga
Copy link

Summary

When biome ci runs in GitHub Actions, the GitHub reporter is automatically enabled via the GITHUB_ACTIONS environment variable (added in #9120). However, the color output was still being forced on in the get_color() method, causing ANSI escape sequences (ESC[0m) to wrap GitHub reporter output lines and break GitHub's annotation parsing.

Fix

In the get_color() method, before force-enabling colors for CI, check if we're running inside GitHub Actions. If so, disable colors — matching the existing behavior when --reporter=github is explicitly passed.

This implements option 1 from the issue: make biome ci (when GITHUB_ACTIONS=true) behave the same as --reporter=default --reporter=github with respect to color output.

The cfg!(debug_assertions) guard is included (consistent with ci.rs) to avoid false positives in Biome's own CI test suite.

Closes #9189

When `biome ci` runs in GitHub Actions, the GitHub reporter is
automatically enabled via the GITHUB_ACTIONS environment variable.
However, the color output was still being forced on, causing ANSI
escape sequences (ESC[0m) to corrupt the GitHub reporter output
and break GitHub's annotation parsing.

This fix checks for the GITHUB_ACTIONS environment variable in the
color resolution logic and disables colors when running in GitHub
Actions, consistent with the existing behavior when --reporter=github
is explicitly passed.

Closes biomejs#9189
@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: 723e749

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

@github-actions github-actions bot added the A-CLI Area: CLI label Feb 25, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

Walkthrough

When running in CI mode without explicit color configuration, the code now detects GitHub Actions via the GITHUB_ACTIONS environment variable and disables colour output in that environment. If GitHub Actions is not detected, colours remain enabled in CI. A minor comment wording fix is also included.

Possibly related PRs

Suggested labels

A-CLI

Suggested reviewers

  • siketyan
  • mdevils
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: disabling ANSI colors when GitHub Actions automatically enables the GitHub reporter.
Description check ✅ Passed The description clearly explains the problem, the fix, and implementation details related to the changeset in the PR.
Linked Issues check ✅ Passed The PR fully implements option 1 from #9189 by detecting GitHub Actions and disabling colours in get_color() before forcing them for CI.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the GitHub Actions colour handling issue; no unrelated modifications are present.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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.

🧹 Nitpick comments (1)
crates/biome_cli/src/commands/mod.rs (1)

727-736: Add an explanatory comment above the cfg!(debug_assertions) guard to match ci.rs.

ci.rs (lines 155–156) already has a comment explaining why the guard exists ("This is funny, but we need to disable this at the moment, otherwise all our tests that run biome ci IN OUR CI, will get false positives. Call it CI-ception"). The new code in mod.rs has none, leaving future readers guessing. Either add a similar short comment, or extract the check into a tiny helper function for consistency and testability:

♻️ Optional refactor — extract helper for testability
+    fn is_github_actions() -> bool {
+        // Skip in debug builds to avoid test-suite env-var pollution
+        if cfg!(debug_assertions) {
+            return false;
+        }
+        std::env::var("GITHUB_ACTIONS")
+            .ok()
+            .is_some_and(|v| v == "true")
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_cli/src/commands/mod.rs` around lines 727 - 736, The code
computing is_github_actions uses a cfg!(debug_assertions) guard without
explanation; add a brief comment above that guard (similar to the one in ci.rs)
describing why we skip the GITHUB_ACTIONS check in debug builds (to avoid CI
runs in tests producing false positives / "CI-ception"), or alternatively
extract the logic into a small helper function (e.g., is_github_actions()) and
place the explanatory comment on that helper for clarity and testability;
reference the existing variable name is_github_actions and the ColorsArg::Off
return so the change is made where this check is performed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_cli/src/commands/mod.rs`:
- Around line 727-736: The code computing is_github_actions uses a
cfg!(debug_assertions) guard without explanation; add a brief comment above that
guard (similar to the one in ci.rs) describing why we skip the GITHUB_ACTIONS
check in debug builds (to avoid CI runs in tests producing false positives /
"CI-ception"), or alternatively extract the logic into a small helper function
(e.g., is_github_actions()) and place the explanatory comment on that helper for
clarity and testability; reference the existing variable name is_github_actions
and the ColorsArg::Off return so the change is made where this check is
performed.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d2ca15 and 723e749.

📒 Files selected for processing (1)
  • crates/biome_cli/src/commands/mod.rs

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Changeset missing.

// However, when running inside GitHub Actions, we need to disable colors
// so the auto-enabled GitHub reporter output is not corrupted by ANSI escape codes
if matches!(self, Self::Ci { .. }) && cli_options.colors.is_none() {
let is_github_actions = if cfg!(debug_assertions) {
Copy link
Member

Choose a reason for hiding this comment

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

Please extract this code into a utility function. We have the same code in another place. Please keep the comment of the other code

@Netail
Copy link
Member

Netail commented Feb 25, 2026

Duplicate of #9215

@Netail Netail marked this as a duplicate of #9215 Feb 25, 2026
@ematipico
Copy link
Member

Yeah we should go with the other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 GitHub reporter output is invalid when colors are enabled

3 participants