diff --git a/crates/squawk/src/github.rs b/crates/squawk/src/github.rs index 6bf9fa14..b17fa65b 100644 --- a/crates/squawk/src/github.rs +++ b/crates/squawk/src/github.rs @@ -78,6 +78,7 @@ pub fn check_and_comment_on_pr( exclude_paths: &[String], pg_version: Option, assume_in_transaction: bool, + github_annotations: bool, ) -> Result<()> { let UploadToGithubArgs { paths, @@ -136,9 +137,11 @@ pub fn check_and_comment_on_pr( COMMENT_HEADER, )?; - let stdout = io::stdout(); - let mut handle = stdout.lock(); - fmt_github_annotations(&mut handle, &file_results)?; + if github_annotations { + let stdout = io::stdout(); + let mut handle = stdout.lock(); + fmt_github_annotations(&mut handle, &file_results)?; + } let violations: usize = file_results.iter().map(|f| f.violations.len()).sum(); diff --git a/crates/squawk/src/main.rs b/crates/squawk/src/main.rs index 9eb0d602..2722cb8c 100644 --- a/crates/squawk/src/main.rs +++ b/crates/squawk/src/main.rs @@ -216,6 +216,8 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log let mut clap_app = Opt::clap(); let is_stdin = !atty::is(Stream::Stdin); + let github_annotations = std::env::var("GITHUB_ACTIONS").is_ok() + && !std::env::var("SQUAWK_DISABLE_GITHUB_ANNOTATIONS").is_ok(); match opts.cmd { Some(Command::Server) => { squawk_server::run().context("language server failed")?; @@ -230,6 +232,7 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log &excluded_paths, pg_version, assume_in_transaction, + github_annotations, ) .context("Upload to GitHub failed")?; } @@ -255,8 +258,6 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log debug(&mut handle, &found_paths, read_stdin, &kind, opts.verbose)?; } else { let reporter = opts.reporter.unwrap_or(Reporter::Tty); - let github_annotations = std::env::var("GITHUB_ACTIONS").is_ok() - && !std::env::var("SQUAWK_DISABLE_GITHUB_ANNOTATIONS").is_ok(); let exit_code = check_and_dump_files( &mut handle, &found_paths,