From d2eb0e2df4a8c5b5538754269de3db43fad7b622 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Feb 2024 22:50:19 -0700 Subject: [PATCH 1/6] checkstyle9.pl: Add --github to output for github workflows If you add "::error file=foo/bar.c:line=123:" before the error message, it will appear inline. Sponsored by: Netflix (cherry picked from commit 0949b237bb901255cc418498b91edfe497131579) --- tools/build/checkstyle9.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl index 8b30baa10fc9..8fe9b9f94da1 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, @@ -1395,6 +1397,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 = "::error file=$filename:line=$realline:\:" if ($github && $file); + $prefix = "::error file=$realfile:line=$linenr:\:" if ($github && !$file); $here = "#$linenr: " if (!$file); $here = "#$realline: " if ($file); From fc611187d6f960592883240487a8b1b54fbcba61 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Feb 2024 23:15:13 -0700 Subject: [PATCH 2/6] checkstyle9.pl: Correct github output Change the : between file and line to a ,. This should fix this... Sponsored by: Netflix (cherry picked from commit c2f5306c64e7e44390c6f21179d696bfdea3260b) --- tools/build/checkstyle9.pl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl index 8fe9b9f94da1..65f13bc1e7f2 100755 --- a/tools/build/checkstyle9.pl +++ b/tools/build/checkstyle9.pl @@ -1175,12 +1175,13 @@ sub report { } my $output = ''; - $output .= BOLD if $color; + my $do_color = $color && !$github; + $output .= BOLD if $do_color; $output .= $prefix; - $output .= RED if $color && $level eq 'ERROR'; - $output .= MAGENTA if $color && $level eq 'WARNING'; - $output .= $level . ':'; - $output .= RESET if $color; + $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 .= ' ' . $msg . "\n"; $output = (split('\n', $output))[0] . "\n" if ($terse); @@ -1397,8 +1398,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 = "::error file=$filename:line=$realline:\:" if ($github && $file); - $prefix = "::error file=$realfile:line=$linenr:\:" if ($github && !$file); + $prefix = "::error file=$filename,line=$realline:\:" if ($github && $file); + $prefix = "::error file=$realfile,line=$linenr:\:" if ($github && !$file); $here = "#$linenr: " if (!$file); $here = "#$realline: " if ($file); From 795e0f6849ab4b005f061b301369705bb65a7218 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Feb 2024 23:26:38 -0700 Subject: [PATCH 3/6] checkstyle9.pl: Another correction to github workflow Remove extra space... Sponsored by: Netflix (cherry picked from commit ac9abe93e83293cb19827a1e6cd898ff40410f47) --- tools/build/checkstyle9.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl index 65f13bc1e7f2..dd6eb624e0b4 100755 --- a/tools/build/checkstyle9.pl +++ b/tools/build/checkstyle9.pl @@ -1182,7 +1182,8 @@ sub report { $output .= MAGENTA if $do_color && $level eq 'WARNING'; $output .= $level . ':' if !$github; $output .= RESET if $do_color; - $output .= ' ' . $msg . "\n"; + $output .= ' ' if (!$github); + $output .= $msg . "\n"; $output = (split('\n', $output))[0] . "\n" if ($terse); From 550e5dc524cfd8f5f3da32a1f42f3334e455633d Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 2 Feb 2024 00:23:43 -0700 Subject: [PATCH 4/6] checkstyle9.pl: Differentiate errors and warnings Use ::error and ::warning as appropriate to give better meaning to the messages. Sponsored by: Netflix (cherry picked from commit 22d12caad69ef2d8e1c76671b44fd5493490acb7) --- tools/build/checkstyle9.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/build/checkstyle9.pl b/tools/build/checkstyle9.pl index dd6eb624e0b4..df9ec2bbd7c1 100755 --- a/tools/build/checkstyle9.pl +++ b/tools/build/checkstyle9.pl @@ -1177,6 +1177,8 @@ sub report { my $output = ''; 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 $do_color && $level eq 'ERROR'; $output .= MAGENTA if $do_color && $level eq 'WARNING'; @@ -1399,8 +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 = "::error file=$filename,line=$realline:\:" if ($github && $file); - $prefix = "::error file=$realfile,line=$linenr:\:" if ($github && !$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); From 21e79809fb83afea43c9836c968a9491939847d2 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Feb 2024 22:53:58 -0700 Subject: [PATCH 5/6] github: Enable github workflow output from checkstyle9.pl Let's see if we can get the style issues flagged inline. Sponsored by: Netflix (cherry picked from commit 33326dd5f5ed1585e370ecd5210f03e56cb3f634) --- .github/workflows/style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 8860a24fe594..08d4242df5ed 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -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 }} + tools/build/checkstyle9.pl --github ${sha}..${{ github.event.pull_request.head.sha }} From cfbf83ae15279d767edf1c465499832c0e88ff24 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 20 Mar 2024 16:42:00 -0700 Subject: [PATCH 6/6] style checker: Update for CheriBSD - Run for PRs against dev instead of main. - Make the check always succeed but still add annotations. - Check the style of the total diff instead of each patch on the branch. --- .github/workflows/style.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 08d4242df5ed..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 --github ${sha}..${{ github.event.pull_request.head.sha }} + git diff ${sha}..${{ github.event.pull_request.head.sha }} | tools/build/checkstyle9.pl --github - || true