Skip to content

Commit 2499901

Browse files
Include error location in GitHub Action diagnostic messages (#1696)
This ensures that if you look at the GitHub Actions _logs_, you see the entire message, including the location: ![Screen Shot 2023-01-06 at 3 08 06 PM](https://user-images.githubusercontent.com/1309177/211091772-df6f1deb-c741-435c-be2e-6ee22347a073.png) The downside is that the location gets repeated inline: ![Screen Shot 2023-01-06 at 3 08 30 PM](https://user-images.githubusercontent.com/1309177/211091800-57020736-95fa-4e41-acb3-eb11c848ba7e.png) See: #1693.
1 parent 12d2526 commit 2499901

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/printer.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,30 @@ impl<'a> Printer<'a> {
223223
self.post_text(diagnostics);
224224
}
225225
SerializationFormat::Github => {
226-
// Generate error workflow command in GitHub Actions format
227-
// https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
226+
// Generate error workflow command in GitHub Actions format.
227+
// See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
228228
diagnostics.messages.iter().for_each(|message| {
229+
let label = format!(
230+
"{}{}{}{}{}{} {} {}",
231+
relativize_path(Path::new(&message.filename)),
232+
":",
233+
message.location.row(),
234+
":",
235+
message.location.column(),
236+
":",
237+
message.kind.code().as_ref(),
238+
message.kind.body(),
239+
);
229240
println!(
230-
"::notice title=Ruff,file={},line={},col={},endLine={},endColumn={}::({}) \
231-
{}",
241+
"::error title=Ruff \
242+
({}),file={},line={},col={},endLine={},endColumn={}::{}",
243+
message.kind.code(),
232244
relativize_path(Path::new(&message.filename)),
233245
message.location.row(),
234246
message.location.column(),
235247
message.end_location.row(),
236248
message.end_location.column(),
237-
message.kind.code(),
238-
message.kind.body(),
249+
label,
239250
);
240251
});
241252
}

0 commit comments

Comments
 (0)