fix(cli): disable colors for auto GitHub reporter in ci#9235
fix(cli): disable colors for auto GitHub reporter in ci#9235Cyber-Isy wants to merge 1 commit intobiomejs:mainfrom
Conversation
|
WalkthroughThis change introduces a runtime check to detect GitHub Actions environments and automatically disables colour output when running Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
| /// 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. |
There was a problem hiding this comment.
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.
| /// 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.
| #[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()); | ||
| } |
There was a problem hiding this comment.
🧩 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.
| #[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.
Summary
Fix
biome cicolor handling when GitHub reporter is auto-enabled via environment detection.When
biome ciruns in GitHub Actions (without explicit--reporterflags), 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
commands/mod.rs::get_color():--reporter=github=> colors off)ciwhen:is_github_actions_environment()aligned withci.rsdebug/test behavior (CI-ception guard)Why
This aligns automatic GitHub reporter path with explicit
--reporter=githubbehavior and ensures GitHub workflow commands are parseable.Closes #9189