-
-
Notifications
You must be signed in to change notification settings - Fork 808
feat(cli): multi reporters #8621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
eb51b50
e426ae4
953962c
6418390
5d09acf
721d41a
74998f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||
| --- | ||||||
| "@biomejs/biome": minor | ||||||
| --- | ||||||
|
|
||||||
| Added support for multiple reporters, and the ability to save reporters on arbitrary files. | ||||||
|
|
||||||
| #### Combine two reporters in CI | ||||||
|
|
||||||
| If you run Biome on GitHub, take advantage of the reporter and still see the erros in console, you can now use both reporters: | ||||||
|
|
||||||
| ```shell | ||||||
| biome ci --reporter=default --reporter=github | ||||||
| ``` | ||||||
|
|
||||||
| #### Save reporter output to a file | ||||||
|
|
||||||
| With the new `--reporter-file` CLI option, it's now possible to save the output of all reporters to a file. The file is a path, | ||||||
| so you can pass a relative or an absolute path: | ||||||
|
|
||||||
| ```shell | ||||||
| biome ci --reporter=rdjson --reporter-file=/etc/tmp/report.json | ||||||
| biome ci --reporter=summary --reporter-file=./reports/file.txt | ||||||
| ``` | ||||||
|
|
||||||
| You can combine these two features. Form example, have the `default` reporter written on terminal, and the `rdjson` reporter written on file: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "Form" → "From" As flagged by static analysis. -You can combine these two features. Form example, have the `default` reporter written on terminal, and the `rdjson` reporter written on file:
+You can combine these two features. For example, have the `default` reporter written on terminal, and the `rdjson` reporter written on file:📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[uncategorized] ~25-~25: “Form” (shape/structure, to make) seems less likely than “from” (“originating from”). (AI_HYDRA_LEO_CP_FORM_FROM) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ```shell | ||||||
| biome ci --reporter=default --reporter=rdjson --reporter-file=/etc/tmp/report.json | ||||||
| ``` | ||||||
|
|
||||||
| *The `--reporter` and `--reporter-file` flags must appear next to each other, otherwise an error is thrown.** | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mismatched emphasis markers and grammar issue Single -*The `--reporter` and `--reporter-file` flags must appear next to each other, otherwise an error is thrown.**
+**The `--reporter` and `--reporter-file` flags must appear next to each other; otherwise, an error is thrown.**🧰 Tools🪛 LanguageTool[typographical] ~31-~31: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (THUS_SENTENCE) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,27 @@ | ||
| use crate::reporter::{Reporter, ReporterVisitor}; | ||
| use crate::reporter::{Reporter, ReporterVisitor, ReporterWriter}; | ||
| use crate::runner::execution::Execution; | ||
| use crate::{DiagnosticsPayload, TraversalSummary}; | ||
| use biome_console::{Console, ConsoleExt, markup}; | ||
| use biome_console::markup; | ||
| use biome_diagnostics::PrintGitHubDiagnostic; | ||
| use camino::{Utf8Path, Utf8PathBuf}; | ||
| use std::io; | ||
|
|
||
| pub(crate) struct GithubReporter<'a> { | ||
| pub(crate) diagnostics_payload: DiagnosticsPayload, | ||
| pub diagnostics_payload: &'a DiagnosticsPayload, | ||
| pub(crate) execution: &'a dyn Execution, | ||
| pub(crate) verbose: bool, | ||
| pub(crate) working_directory: Option<Utf8PathBuf>, | ||
| } | ||
|
|
||
| impl Reporter for GithubReporter<'_> { | ||
| fn write(self, visitor: &mut dyn ReporterVisitor) -> io::Result<()> { | ||
| fn write( | ||
| self, | ||
| writer: &mut dyn ReporterWriter, | ||
|
|
||
| visitor: &mut dyn ReporterVisitor, | ||
| ) -> io::Result<()> { | ||
| visitor.report_diagnostics( | ||
| writer, | ||
| self.execution, | ||
| self.diagnostics_payload, | ||
| self.verbose, | ||
|
|
@@ -24,11 +30,12 @@ impl Reporter for GithubReporter<'_> { | |
| Ok(()) | ||
| } | ||
| } | ||
| pub(crate) struct GithubReporterVisitor<'a>(pub(crate) &'a mut dyn Console); | ||
| pub(crate) struct GithubReporterVisitor; | ||
|
|
||
| impl ReporterVisitor for GithubReporterVisitor<'_> { | ||
| impl ReporterVisitor for GithubReporterVisitor { | ||
| fn report_summary( | ||
| &mut self, | ||
| _writer: &mut dyn ReporterWriter, | ||
| _execution: &dyn Execution, | ||
| _summary: TraversalSummary, | ||
| _verbose: bool, | ||
|
|
@@ -38,17 +45,18 @@ impl ReporterVisitor for GithubReporterVisitor<'_> { | |
|
|
||
| fn report_diagnostics( | ||
| &mut self, | ||
| writer: &mut dyn ReporterWriter, | ||
| _execution: &dyn Execution, | ||
| diagnostics_payload: DiagnosticsPayload, | ||
| diagnostics_payload: &DiagnosticsPayload, | ||
| verbose: bool, | ||
| _working_directory: Option<&Utf8Path>, | ||
| ) -> io::Result<()> { | ||
| for diagnostic in &diagnostics_payload.diagnostics { | ||
| if diagnostic.severity() >= diagnostics_payload.diagnostic_level { | ||
| if diagnostic.tags().is_verbose() && verbose { | ||
| self.0.log(markup! {{PrintGitHubDiagnostic(diagnostic)}}); | ||
| writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}}); | ||
| } else if !verbose { | ||
| self.0.log(markup! {{PrintGitHubDiagnostic(diagnostic)}}); | ||
| writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}}); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
54
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic bug: non-verbose diagnostics skipped when The condition Compare with the pattern in 🐛 Proposed fix for diagnostic in &diagnostics_payload.diagnostics {
if diagnostic.severity() >= diagnostics_payload.diagnostic_level {
- if diagnostic.tags().is_verbose() && verbose {
- writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
- } else if !verbose {
+ if diagnostic.tags().is_verbose() {
+ if verbose {
+ writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
+ }
+ } else {
writer.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
}
}
}🤖 Prompt for AI Agents |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "erros" → "errors"
📝 Committable suggestion
🤖 Prompt for AI Agents