Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github: Update the style checker action for CheriBSD #2067

Merged
merged 6 commits into from
Apr 9, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: Style Checker

on:
pull_request: # maybe pull_request_target
branches: [ main ]
branches: [ dev ]
types: [ opened, reopened, edited, synchronize ]

permissions:
Expand All @@ -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
20 changes: 14 additions & 6 deletions tools/build/checkstyle9.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -91,6 +92,7 @@
'patch!' => \$chk_patch,
'branch!' => \$chk_branch,
'emacs!' => \$emacs,
'github!' => \$github,
'terse!' => \$terse,
'f|file!' => \$file,
'strict!' => \$no_warnings,
Expand Down Expand Up @@ -1173,13 +1175,17 @@
}

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);

Expand Down Expand Up @@ -1395,6 +1401,8 @@
#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);

Check warning on line 1404 in tools/build/checkstyle9.pl

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
$prefix = "file=$realfile,line=$realline:\:" if ($github && !$file);

Check warning on line 1405 in tools/build/checkstyle9.pl

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters

$here = "#$linenr: " if (!$file);
$here = "#$realline: " if ($file);
Expand Down
Loading