Skip to content

fix(cli): disable colors when GitHub Actions auto-enables github reporter#9215

Merged
Netail merged 3 commits intobiomejs:mainfrom
FrederickStempfle:fix/github-reporter-ansi-colors
Feb 25, 2026
Merged

fix(cli): disable colors when GitHub Actions auto-enables github reporter#9215
Netail merged 3 commits intobiomejs:mainfrom
FrederickStempfle:fix/github-reporter-ansi-colors

Conversation

@FrederickStempfle
Copy link
Contributor

Summary

Fixes #9189

When biome ci runs in GitHub Actions, the github reporter gets auto-enabled but colors are also force-enabled. This causes ANSI reset sequences to wrap the ::error/::warning lines, which prevents GitHub from recognizing them as workflow commands.

The fix checks for GITHUB_ACTIONS=true before forcing colors on, so the auto-detected path behaves the same way as explicitly passing --reporter=default --reporter=github (which already works correctly).

Uses the same cfg!(debug_assertions) guard as the existing GitHub detection in ci.rs to avoid breaking tests.

When `biome ci` runs in GitHub Actions, the github reporter is
auto-enabled but colors are force-enabled, causing ANSI escape codes
to wrap ::error/::warning workflow command lines. This breaks GitHub's
ability to parse them as workflow commands.

Closes biomejs#9189
@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 73e81d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

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

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

coderabbitai bot commented Feb 23, 2026

Walkthrough

Adds a centralized is_github_actions() helper and updates CLI color handling so that, when running in CI on GitHub Actions and the user has not explicitly set colors, the CLI disables colours (returns ColorsArg::Off). get_execution in the CI command now uses the new helper. Also adds a changeset documenting a patch release noting that GitHub Actions CI now disables colours so workflow commands aren’t wrapped in ANSI escape codes.

Possibly related PRs

  • fix(cli): logging color #7441: Modifies CLI colour handling and propagates ColorsArg into logging setup within crates/biome_cli, touching the same command modules.

Suggested reviewers

  • ematipico
  • dyc3
  • siketyan
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: disabling colours in GitHub Actions to prevent ANSI codes from corrupting the github reporter.
Description check ✅ Passed The description clearly explains the issue (#9189), the problem with ANSI escape sequences, and how the fix aligns with existing behaviour.
Linked Issues check ✅ Passed The PR implements approach (1) from issue #9189 by checking for GITHUB_ACTIONS=true before forcing colours, matching --reporter=default --reporter=github behaviour.
Out of Scope Changes check ✅ Passed All changes (colour handling logic, GitHub Actions detection helper, and colour flag refactoring) are directly related to fixing the github reporter colour issue.

✏️ 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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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)

722-722: Minor nit: stale grammatical error in the comment.

"We want force colors in CI" — "to" is missing from want to force.

✏️ One-word fix
-                // We want force colors in CI, to give a better UX experience
+                // We want to force colors in CI for a better UX
🤖 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` at line 722, Update the inline comment
text that reads "We want force colors in CI, to give a better UX experience" to
fix the grammar by adding the missing "to" so it reads "We want to force colors
in CI, to give a better UX experience"; locate and edit the comment near the
color/CI handling logic in mod.rs (the comment containing "We want force colors
in CI") to apply this one-word change.
🤖 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`:
- Line 722: Update the inline comment text that reads "We want force colors in
CI, to give a better UX experience" to fix the grammar by adding the missing
"to" so it reads "We want to force colors in CI, to give a better UX
experience"; locate and edit the comment near the color/CI handling logic in
mod.rs (the comment containing "We want force colors in CI") to apply this
one-word change.

ℹ️ 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 0385eb2 and 7f159fa.

📒 Files selected for processing (2)
  • .changeset/fix-github-reporter-colors.md
  • crates/biome_cli/src/commands/mod.rs

Comment on lines 726 to 732
if !cfg!(debug_assertions)
&& std::env::var("GITHUB_ACTIONS")
.ok()
.is_some_and(|v| v == "true")
{
return Some(&ColorsArg::Off);
}
Copy link
Member

@Netail Netail Feb 25, 2026

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

Comment forwarded from another PR; #9236 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ill extract it into a helper function one sec

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)

768-780: Solid helper — one small note on testability.

The cfg!(debug_assertions) guard is a pragmatic solution to the CI-ception problem and is well-documented. Just worth being aware that the ColorsArg::Off path in get_color (and the ExecutionEnvironment::GitHub path in ci.rs) are permanently unreachable from unit tests, so behaviour verification relies entirely on manual testing or integration/end-to-end CI runs.

If coverage matters to you, one option is an injectable seam (e.g. a #[cfg(test)] override or an environment-based escape hatch), but for something this simple it's likely overkill.

🤖 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 768 - 780, The
is_github_actions() helper currently hard-circuits debug builds via
cfg!(debug_assertions), making the ColorsArg::Off branch in get_color and
ExecutionEnvironment::GitHub in ci.rs unreachable in unit tests; add a testable
seam by allowing an override (e.g., check an environment variable like
"BIOME_FORCE_GITHUB_ACTIONS" or provide a #[cfg(test)] path) so tests can
simulate CI: modify is_github_actions() to still return false in debug by
default but honor the override env var or test-only flag, and update usages
(get_color, ExecutionEnvironment detection) to rely on the revised
is_github_actions().
🤖 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 768-780: The is_github_actions() helper currently hard-circuits
debug builds via cfg!(debug_assertions), making the ColorsArg::Off branch in
get_color and ExecutionEnvironment::GitHub in ci.rs unreachable in unit tests;
add a testable seam by allowing an override (e.g., check an environment variable
like "BIOME_FORCE_GITHUB_ACTIONS" or provide a #[cfg(test)] path) so tests can
simulate CI: modify is_github_actions() to still return false in debug by
default but honor the override env var or test-only flag, and update usages
(get_color, ExecutionEnvironment detection) to rely on the revised
is_github_actions().

ℹ️ 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 7f159fa and e4f4e68.

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

@Netail Netail requested a review from ematipico February 25, 2026 17:59
@Netail Netail merged commit b2619a1 into biomejs:main Feb 25, 2026
12 of 13 checks passed
@github-actions github-actions bot mentioned this pull request Feb 25, 2026
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