diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 8860a24fe594..ddea2a7493ae 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -8,7 +8,7 @@ name: Style Checker on: pull_request: # maybe pull_request_target - branches: [ main ] + branches: [ dev ] types: [ opened, reopened, edited, synchronize ] permissions: @@ -31,4 +31,4 @@ jobs: - name: Run checker run: | sha=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) - tools/build/checkstyle9.pl ${sha}..${{ github.event.pull_request.head.sha }} + git diff ${sha}..${{ github.event.pull_request.head.sha }} | tools/build/checkstyle9.pl --github - || true diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl index 8b30baa10fc9..df9ec2bbd7c1 100755 --- a/tools/build/checkstyle9.pl +++ b/tools/build/checkstyle9.pl @@ -25,6 +25,7 @@ my $chk_branch = undef; my $tst_only; my $emacs = 0; +my $github = 0; my $terse = 0; my $file = undef; my $color = "auto"; @@ -91,6 +92,7 @@ sub help { 'patch!' => \$chk_patch, 'branch!' => \$chk_branch, 'emacs!' => \$emacs, + 'github!' => \$github, 'terse!' => \$terse, 'f|file!' => \$file, 'strict!' => \$no_warnings, @@ -1173,13 +1175,17 @@ sub report { } my $output = ''; - $output .= BOLD if $color; + my $do_color = $color && !$github; + $output .= BOLD if $do_color; + $output .= "::error " if $github && $level eq 'ERROR'; + $output .= "::warning " if $github && $level eq 'WARNING'; $output .= $prefix; - $output .= RED if $color && $level eq 'ERROR'; - $output .= MAGENTA if $color && $level eq 'WARNING'; - $output .= $level . ':'; - $output .= RESET if $color; - $output .= ' ' . $msg . "\n"; + $output .= RED if $do_color && $level eq 'ERROR'; + $output .= MAGENTA if $do_color && $level eq 'WARNING'; + $output .= $level . ':' if !$github; + $output .= RESET if $do_color; + $output .= ' ' if (!$github); + $output .= $msg . "\n"; $output = (split('\n', $output))[0] . "\n" if ($terse); @@ -1395,6 +1401,8 @@ sub process { #make up the handle for any error we report on this line $prefix = "$filename:$realline: " if ($emacs && $file); $prefix = "$filename:$linenr: " if ($emacs && !$file); + $prefix = "file=$filename,line=$realline:\:" if ($github && $file); + $prefix = "file=$realfile,line=$realline:\:" if ($github && !$file); $here = "#$linenr: " if (!$file); $here = "#$realline: " if ($file);