Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-snails-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#9109](https://github.com/biomejs/biome/issues/9109), where the GitHub reporter wasn't correctly enabled when `biome ci` runs on GitHub Actions.
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/biome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ biome_json_parser = { workspace = true }
directories = { workspace = true }
insta = { workspace = true }
regex = { workspace = true }
serial_test = "3.3.1"
tokio = { workspace = true, features = ["io-util"] }

[target.'cfg(all(target_family="unix", not(all(target_arch = "aarch64", target_env = "musl"))))'.dependencies]
Expand Down
29 changes: 22 additions & 7 deletions crates/biome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::CliDiagnostic;
use crate::changed::get_changed_files;
use crate::cli_options::CliOptions;
use crate::cli_options::{CliOptions, CliReporter, CliReporterKind};
use crate::runner::execution::{AnalyzerSelectors, Execution, ExecutionEnvironment, VcsTargeted};
use crate::runner::impls::commands::traversal::{LoadEditorConfig, TraversalCommand};
use crate::runner::impls::executions::summary_verb::SummaryVerbExecution;
Expand Down Expand Up @@ -44,7 +44,7 @@ pub(crate) struct CiCommandPayload {

struct CiExecution {
/// Whether the CI is running in a specific environment, e.g. GitHub, GitLab, etc.
_environment: Option<ExecutionEnvironment>,
environment: Option<ExecutionEnvironment>,
/// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled
vcs_targeted: VcsTargeted,
/// Whether assist diagnostics should be promoted to error, and fail the CLI
Expand Down Expand Up @@ -115,6 +115,15 @@ impl Execution for CiExecution {
fn summary_phrase(&self, files: usize, duration: &Duration) -> MarkupBuf {
SummaryVerbExecution.summary_verb("Checked", files, duration)
}

fn environment_to_reporter(&self) -> Option<CliReporter> {
self.environment.map(|e| match e {
ExecutionEnvironment::GitHub => CliReporter {
kind: CliReporterKind::GitHub,
destination: None,
},
})
}
}

impl LoadEditorConfig for CiCommandPayload {
Expand Down Expand Up @@ -143,13 +152,19 @@ impl TraversalCommand for CiCommandPayload {
_console: &mut dyn Console,
_workspace: &dyn Workspace,
) -> Result<Box<dyn Execution>, CliDiagnostic> {
// Ref: https://docs.github.com/actions/learn-github-actions/variables#default-environment-variables
let is_github = std::env::var("GITHUB_ACTIONS")
.ok()
.is_some_and(|value| value == "true");
// 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
let is_github = if cfg!(debug_assertions) {
false
} else {
// Ref: https://docs.github.com/actions/learn-github-actions/variables#default-environment-variables
std::env::var("GITHUB_ACTIONS")
.ok()
.is_some_and(|value| value == "true")
};

Ok(Box::new(CiExecution {
_environment: if is_github {
environment: if is_github {
Some(ExecutionEnvironment::GitHub)
} else {
None
Expand Down
7 changes: 6 additions & 1 deletion crates/biome_cli/src/runner/execution.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cli_options::CliOptions;
use crate::cli_options::{CliOptions, CliReporter};
use biome_configuration::analyzer::AnalyzerSelector;
use biome_console::MarkupBuf;
use biome_diagnostics::Category;
Expand Down Expand Up @@ -161,6 +161,11 @@ pub(crate) trait Execution: Send + Sync + std::panic::RefUnwindSafe {

/// Used when printing summary
fn summary_phrase(&self, files: usize, duration: &Duration) -> MarkupBuf;

/// Uses additional reporters based on the environment execution
fn environment_to_reporter(&self) -> Option<CliReporter> {
None
}
}

#[derive(Debug, Default, Clone)]
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/src/runner/finalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub trait Finalizer {

pub(crate) struct FinalizePayload<'a, I> {
pub(crate) fs: &'a dyn FileSystem,
pub(crate) workspace: &'a dyn Workspace,
pub(crate) scan_duration: Option<Duration>,
pub(crate) console: &'a mut dyn Console,
pub(crate) cli_options: &'a CliOptions,
Expand Down
Loading
Loading