Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/squawk/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub fn check_and_comment_on_pr(
exclude_paths: &[String],
pg_version: Option<Version>,
assume_in_transaction: bool,
github_annotations: bool,
) -> Result<()> {
let UploadToGithubArgs {
paths,
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions crates/squawk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand All @@ -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")?;
}
Expand All @@ -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,
Expand Down
Loading