Skip to content

Commit

Permalink
Raise errors to top of report
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Jan 25, 2024
1 parent 241e946 commit 31a7747
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions run-scalafmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,38 @@ report() {
echo
}

errors=$(mktemp)

if grep -q '^error:' "$warnings"; then
warnings="$warnings" errors="$errors" perl -e '
my $new_warnings = "$ENV{warnings}.new";
open my $warnings_in, "<", $ENV{warnings};
open my $warnings_out, ">", $new_warnings;
open my $errors, ">", $ENV{errors};
my $found_error=0;
while (<$warnings_in>) {
if ($found_error) {
print $errors $_;
} elsif (/^error:/) {
$found_error=1;
print $errors $_;
} else {
print $warnings_out $_;
}
}
close $warnings_in;
close $warnings_out;
close $errors;
rename new_warnings, $ENV{warnings};
'
fi

(
echo "# scalafmt failed ($result)"
if [ -s "$errors" ]; then
echo '# Errors'
cat "$errors"
fi
report "$output" "Output"
report "$warnings" "Warnings"
) >> "$GITHUB_STEP_SUMMARY"
Expand Down

0 comments on commit 31a7747

Please sign in to comment.