|
1 | 1 | use crate::CliDiagnostic; |
2 | 2 | use crate::changed::get_changed_files; |
3 | | -use crate::cli_options::CliOptions; |
| 3 | +use crate::cli_options::{CliOptions, CliReporter, CliReporterKind}; |
4 | 4 | use crate::runner::execution::{AnalyzerSelectors, Execution, ExecutionEnvironment, VcsTargeted}; |
5 | 5 | use crate::runner::impls::commands::traversal::{LoadEditorConfig, TraversalCommand}; |
6 | 6 | use crate::runner::impls::executions::summary_verb::SummaryVerbExecution; |
@@ -44,7 +44,7 @@ pub(crate) struct CiCommandPayload { |
44 | 44 |
|
45 | 45 | struct CiExecution { |
46 | 46 | /// Whether the CI is running in a specific environment, e.g. GitHub, GitLab, etc. |
47 | | - _environment: Option<ExecutionEnvironment>, |
| 47 | + environment: Option<ExecutionEnvironment>, |
48 | 48 | /// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled |
49 | 49 | vcs_targeted: VcsTargeted, |
50 | 50 | /// Whether assist diagnostics should be promoted to error, and fail the CLI |
@@ -115,6 +115,15 @@ impl Execution for CiExecution { |
115 | 115 | fn summary_phrase(&self, files: usize, duration: &Duration) -> MarkupBuf { |
116 | 116 | SummaryVerbExecution.summary_verb("Checked", files, duration) |
117 | 117 | } |
| 118 | + |
| 119 | + fn environment_to_reporter(&self) -> Option<CliReporter> { |
| 120 | + self.environment.map(|e| match e { |
| 121 | + ExecutionEnvironment::GitHub => CliReporter { |
| 122 | + kind: CliReporterKind::GitHub, |
| 123 | + destination: None, |
| 124 | + }, |
| 125 | + }) |
| 126 | + } |
118 | 127 | } |
119 | 128 |
|
120 | 129 | impl LoadEditorConfig for CiCommandPayload { |
@@ -143,13 +152,19 @@ impl TraversalCommand for CiCommandPayload { |
143 | 152 | _console: &mut dyn Console, |
144 | 153 | _workspace: &dyn Workspace, |
145 | 154 | ) -> Result<Box<dyn Execution>, CliDiagnostic> { |
146 | | - // Ref: https://docs.github.com/actions/learn-github-actions/variables#default-environment-variables |
147 | | - let is_github = std::env::var("GITHUB_ACTIONS") |
148 | | - .ok() |
149 | | - .is_some_and(|value| value == "true"); |
| 155 | + // This is funny, but we need to disable this at the moment, otherwise |
| 156 | + // all our tests that run `biome ci` IN OUR CI, will get false positives. Call it CI-ception |
| 157 | + let is_github = if cfg!(debug_assertions) { |
| 158 | + false |
| 159 | + } else { |
| 160 | + // Ref: https://docs.github.com/actions/learn-github-actions/variables#default-environment-variables |
| 161 | + std::env::var("GITHUB_ACTIONS") |
| 162 | + .ok() |
| 163 | + .is_some_and(|value| value == "true") |
| 164 | + }; |
150 | 165 |
|
151 | 166 | Ok(Box::new(CiExecution { |
152 | | - _environment: if is_github { |
| 167 | + environment: if is_github { |
153 | 168 | Some(ExecutionEnvironment::GitHub) |
154 | 169 | } else { |
155 | 170 | None |
|
0 commit comments