Skip to content

Commit 3e12549

Browse files
committed
fix: set SARIF results path as relative in CI environment
1 parent 5b2a16e commit 3e12549

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,18 @@ async fn main() -> Result<()> {
282282
groupend!();
283283
}
284284

285-
action.set_sarif_results(sarif_output.display().to_string());
285+
// If the action is running in Actions, the SARIF file must be a relative path
286+
// This is because we assume that this code is running in a container which mounts
287+
// the repository at /github/workspace
288+
if let Ok(_) = std::env::var("CI") {
289+
// If running in a CI environment, set the SARIF as a relative path
290+
let relative_path = sarif_output.strip_prefix(&cwd).unwrap_or(&sarif_output);
291+
log::debug!("CI environment detected, setting SARIF path as relative: {}", relative_path.display());
292+
action.set_sarif_results(relative_path.display().to_string());
293+
} else {
294+
log::debug!("Setting SARIF path as absolute: {}", sarif_output.display());
295+
action.set_sarif_results(sarif_output.display().to_string());
296+
}
286297

287298
log::info!("All databases created and analyzed");
288299

0 commit comments

Comments
 (0)