Skip to content

fix(cli): disable colors for auto GitHub reporter in ci#9235

Closed
Cyber-Isy wants to merge 1 commit intobiomejs:mainfrom
Cyber-Isy:fix/9189-github-reporter-colors
Closed

fix(cli): disable colors for auto GitHub reporter in ci#9235
Cyber-Isy wants to merge 1 commit intobiomejs:mainfrom
Cyber-Isy:fix/9189-github-reporter-colors

Conversation

@Cyber-Isy
Copy link
Copy Markdown

Summary

Fix biome ci color handling when GitHub reporter is auto-enabled via environment detection.

When biome ci runs in GitHub Actions (without explicit --reporter flags), the GitHub reporter is auto-selected later in execution, but color mode was still forced to --colors=force. This can wrap workflow command lines with ANSI reset sequences and break GitHub annotations.

What changed

  • In commands/mod.rs::get_color():
    • keep existing explicit reporter behavior (--reporter=github => colors off)
    • additionally disable colors for ci when:
      • colors were not explicitly set
      • running in GitHub Actions environment
  • preserve existing forced-color behavior for non-GitHub CI contexts
  • add helper is_github_actions_environment() aligned with ci.rs debug/test behavior (CI-ception guard)
  • add unit test asserting GitHub env auto-detection stays disabled in debug builds

Why

This aligns automatic GitHub reporter path with explicit --reporter=github behavior and ensures GitHub workflow commands are parseable.

Closes #9189

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: d02ce5b

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
@Cyber-Isy Cyber-Isy closed this Feb 25, 2026
@Cyber-Isy Cyber-Isy deleted the fix/9189-github-reporter-colors branch February 25, 2026 01:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Walkthrough

This change introduces a runtime check to detect GitHub Actions environments and automatically disables colour output when running biome ci under GitHub Actions, provided the user hasn't explicitly requested colours. It adds logic to the colour selection flow in the CLI to return ColorsArg::Off when all conditions are met: running in CI mode, colours not forced by the user, and the GitHub Actions environment is detected. The change includes tests verifying the environment detection behaves correctly in debug builds.

Possibly related PRs

  • #7441: Modifies CLI colour handling and ColorsArg usage in crates/biome_cli to control ANSI output behaviour.

Suggested labels

A-CLI

Suggested reviewers

  • siketyan
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: disabling colours for the auto-enabled GitHub reporter in CI mode.
Description check ✅ Passed The description is well-detailed and directly addresses the changeset, explaining what changed, why, and how it aligns with issue #9189.
Linked Issues check ✅ Passed The PR directly addresses issue #9189 by implementing the preferred approach: disabling colours when running in GitHub Actions to prevent ANSI sequences from breaking workflow command parsing.
Out of Scope Changes check ✅ Passed All changes are in-scope: the is_github_actions_environment() helper, colour logic updates in get_color(), and the test to verify debug-build behaviour are all necessary for the fix.

✏️ 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
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_cli/src/commands/mod.rs`:
- Around line 917-919: The rustdoc "Checks if the fix file options are
incompatible." is currently placed above is_github_actions_environment(), so
move that /// doc comment to directly precede the
check_fix_incompatible_arguments function declaration instead; ensure the doc
comment uses /// and is removed from above is_github_actions_environment() so
generated docs correctly document check_fix_incompatible_arguments.
- Around line 1045-1049: Gate the test function
github_actions_env_is_disabled_in_debug_builds with #[cfg(debug_assertions)] so
it only runs in debug builds; locate the test (which calls
is_github_actions_environment()) and add the attribute above the fn declaration
to match the function's debug-only behavior and prevent failures when running
tests in release/CI environments.

ℹ️ 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 d02ce5b.

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

Comment on lines 917 to +919
/// Checks if the fix file options are incompatible.
fn is_github_actions_environment() -> bool {
// Keep behavior aligned with `ci.rs` to avoid CI-ception in debug/test builds.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Misplaced rustdoc now documents the wrong function.

At Line 917, “Checks if the fix file options are incompatible.” now sits above is_github_actions_environment(). Please move that doc comment back to check_fix_incompatible_arguments so generated docs stay accurate.

✏️ Suggested fix
-/// Checks if the fix file options are incompatible.
 fn is_github_actions_environment() -> bool {
     // Keep behavior aligned with `ci.rs` to avoid CI-ception in debug/test builds.
@@
 }
 
+/// Checks if the fix file options are incompatible.
 fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), CliDiagnostic> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Checks if the fix file options are incompatible.
fn is_github_actions_environment() -> bool {
// Keep behavior aligned with `ci.rs` to avoid CI-ception in debug/test builds.
fn is_github_actions_environment() -> bool {
// Keep behavior aligned with `ci.rs` to avoid CI-ception in debug/test builds.
// ... rest of function
}
/// Checks if the fix file options are incompatible.
fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), CliDiagnostic> {
// ... function implementation
}
🤖 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 917 - 919, The rustdoc
"Checks if the fix file options are incompatible." is currently placed above
is_github_actions_environment(), so move that /// doc comment to directly
precede the check_fix_incompatible_arguments function declaration instead;
ensure the doc comment uses /// and is removed from above
is_github_actions_environment() so generated docs correctly document
check_fix_incompatible_arguments.

Comment on lines +1045 to +1049
#[test]
fn github_actions_env_is_disabled_in_debug_builds() {
// This prevents CI-ception for test runs in GitHub Actions.
assert!(!is_github_actions_environment());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the exact test mentioned
cat -n crates/biome_cli/src/commands/mod.rs | sed -n '1040,1055p'

Repository: biomejs/biome

Length of output: 424


🏁 Script executed:

# Search for the is_github_actions_environment function to understand what it does
rg -A 10 "fn is_github_actions_environment" crates/biome_cli/src/

Repository: biomejs/biome

Length of output: 768


🏁 Script executed:

# Check if there are any related tests or comments that explain the intent
rg -B 5 "github_actions_env_is_disabled" crates/biome_cli/src/

Repository: biomejs/biome

Length of output: 429


Gate this debug-only test with #[cfg(debug_assertions)].

The function is_github_actions_environment() already conditions on debug builds internally, but the test itself runs in release mode too—where it'd fail if GITHUB_ACTIONS is set. The test name says debug-only, so gating it keeps intent and behaviour aligned.

Suggested fix
+    #[cfg(debug_assertions)]
     #[test]
     fn github_actions_env_is_disabled_in_debug_builds() {
         // This prevents CI-ception for test runs in GitHub Actions.
         assert!(!is_github_actions_environment());
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[test]
fn github_actions_env_is_disabled_in_debug_builds() {
// This prevents CI-ception for test runs in GitHub Actions.
assert!(!is_github_actions_environment());
}
#[cfg(debug_assertions)]
#[test]
fn github_actions_env_is_disabled_in_debug_builds() {
// This prevents CI-ception for test runs in GitHub Actions.
assert!(!is_github_actions_environment());
}
🤖 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 1045 - 1049, Gate the test
function github_actions_env_is_disabled_in_debug_builds with
#[cfg(debug_assertions)] so it only runs in debug builds; locate the test (which
calls is_github_actions_environment()) and add the attribute above the fn
declaration to match the function's debug-only behavior and prevent failures
when running tests in release/CI environments.

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

1 participant