Use GitHub Actions problem matcher to highlight warnings

This commit is contained in:
Mat Sutcliffe
2023-11-19 01:37:00 +00:00
committed by Lars Toenning
parent cc2dee8185
commit 1b16a012fe
2 changed files with 14 additions and 100 deletions

View File

@@ -66,15 +66,14 @@ jobs:
- name: Run clang-format
run: |
scripts/run_clang_format.py
- uses: Trass3r/setup-cpp@master
- name: Run cppcheck
id: cppcheck
run: |
sudo apt-get -y install cppcheck
sudo cpan Path::Class
cppcheck --template=gcc --inline-suppr --std=c++17 --enable=style,unusedFunction -i externals \
-i src/plugins/weatherdata/gfs/g2clib -DCPPCHECK --force --suppressions-list=cppcheck.supp \
--library=qt.cfg --library=posix.cfg . 2> >(tee error.log >&2)
perl scripts/warnings.pl error.log
--library=qt.cfg --library=posix.cfg .
buildLinux:
runs-on: ubuntu-20.04
@@ -115,7 +114,6 @@ jobs:
run: |
sudo apt-get -y install dbus-x11 doxygen graphviz libglu1-mesa-dev libopus-dev libsodium-dev libpulse-dev libdbus-1-dev libevent-dev libpng-dev ninja-build
pip3 install requests
sudo cpan Path::Class
- name: Checkout repository
uses: actions/checkout@v3
with:
@@ -136,18 +134,15 @@ jobs:
env:
VATSIM_ID: ${{ secrets.VATSIM_ID }}
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
- uses: Trass3r/setup-cpp@master
- name: Build swift (without symbols)
if: ${{ env.do_symbols != 'true' }}
run: |
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" 2> >(tee error.log >&2)
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file"
- name: Build swift (with symbols)
if: ${{ env.do_symbols == 'true' }}
run: |
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload 2> >(tee error.log >&2)
- name: Check warnings
id: warnings
run: |
perl scripts/warnings.pl error.log
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload
- name: Upload installer
uses: actions/upload-artifact@v3
with:
@@ -229,20 +224,15 @@ jobs:
env:
VATSIM_ID: ${{ secrets.VATSIM_ID }}
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
- uses: Trass3r/setup-cpp@master
- name: Build swift (without symbols)
if: ${{ env.do_symbols != 'true' }}
shell: bash
run: |
python -u scripts/build.py -w 64 -t msvc -d -q "-DVATSIM_KEY_JSON=$vatsim_key_file" 2>&1 | tee error.log
python -u scripts/build.py -w 64 -t msvc -d -q "-DVATSIM_KEY_JSON=$env:vatsim_key_file"
- name: Build swift (with symbols)
if: ${{ env.do_symbols == 'true' }}
shell: bash
run: |
python -u scripts/build.py -w 64 -t msvc -d -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload 2>&1 | tee error.log
- name: Check warnings
id: warnings
run: |
perl.exe scripts\warnings.pl error.log
python -u scripts/build.py -w 64 -t msvc -d -q "-DVATSIM_KEY_JSON=$env:vatsim_key_file" --upload
- name: Upload installer
uses: actions/upload-artifact@v3
with:
@@ -324,20 +314,15 @@ jobs:
env:
VATSIM_ID: ${{ secrets.VATSIM_ID }}
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
- uses: Trass3r/setup-cpp@master
- name: Build swift (without symbols)
if: ${{ env.do_symbols != 'true' }}
shell: bash
run: |
python -u scripts/build.py -w 32 -t msvc -d -q "-DVATSIM_KEY_JSON=$vatsim_key_file" 2>&1 | tee error.log
python -u scripts/build.py -w 32 -t msvc -d -q "-DVATSIM_KEY_JSON=$env:vatsim_key_file"
- name: Build swift (with symbols)
if: ${{ env.do_symbols == 'true' }}
shell: bash
run: |
python -u scripts/build.py -w 32 -t msvc -d -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload 2>&1 | tee error.log
- name: Check warnings
id: warnings
run: |
perl.exe scripts\warnings.pl error.log
python -u scripts/build.py -w 32 -t msvc -d -q "-DVATSIM_KEY_JSON=$env:vatsim_key_file" --upload
- name: Upload installer
uses: actions/upload-artifact@v3
with:
@@ -394,7 +379,6 @@ jobs:
- name: Install dependencies
run: |
pip3 install requests
cpan Path::Class
- name: Checkout repository
uses: actions/checkout@v3
with:
@@ -410,18 +394,15 @@ jobs:
env:
VATSIM_ID: ${{ secrets.VATSIM_ID }}
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
- uses: Trass3r/setup-cpp@master
- name: Build swift (without symbols)
if: ${{ env.do_symbols != 'true' }}
run: |
python3 -u scripts/build.py -w 64 -t clang -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" 2> >(tee error.log >&2)
python3 -u scripts/build.py -w 64 -t clang -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file"
- name: Build swift (with symbols)
if: ${{ env.do_symbols == 'true' }}
run: |
python3 -u scripts/build.py -w 64 -t clang -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload 2> >(tee error.log >&2)
- name: Check warnings
id: warnings
run: |
perl scripts/warnings.pl error.log
python3 -u scripts/build.py -w 64 -t clang -d -j2 -q "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload
- name: Upload installer
uses: actions/upload-artifact@v3
with:

View File

@@ -1,67 +0,0 @@
#!/usr/bin/perl
#
# Convert C++ compiler warnings into Github Actions workflow commands
#
# SPDX-FileCopyrightText: Copyright (C) 2020 swift Project Community / contributors
# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
use strict;
use warnings;
use File::Spec;
use Cwd;
my %cmds;
while (<<>>)
{
chomp;
my %result = extractWarning($_);
next if not %result;
$result{file} = toRelativePath($result{file});
$result{file} =~ s(\\)(/)g if $^O eq 'MSWin32';
if (exists $result{line}) {
++$cmds{"::warning file=$result{file},line=$result{line}::$result{msg}"};
} else {
++$cmds{"::warning file=$result{file}::$result{msg}"};
}
}
print "$_\n" for sort keys %cmds;
my $bool = %cmds ? 'true' : 'false';
open my $GITHUB_OUTPUT, ">> $ENV{GITHUB_OUTPUT}" or die "open: $!";
print $GITHUB_OUTPUT "warnings=$bool\n";
sub extractWarning
{
my $text = shift;
my %result = extractGccWarning($text);
return %result if %result;
return extractMsvcWarning($text);
}
sub extractGccWarning
{
my $text = shift;
$text =~ m(^\s*(?<loc>.*?): warning: (?<msg>.*)$) or return ();
my ($loc, $msg) = @+{ qw(loc msg) };
$loc =~ m(^(?<file>.*?):(?<loc>[0-9:]+)$) or return (file => $loc, msg => $msg);
my ($file, $line) = ($+{file}, split ':', $+{loc});
return (file => $file, line => $line, msg => $msg);
}
sub extractMsvcWarning
{
my $text = shift;
$text =~ m(^\s*(?<loc>.*?): warning (?<msg>[A-Z]+[0-9]+: .*)$) or return ();
my ($loc, $msg) = @+{ qw(loc msg) };
$loc =~ m(^(?<file>.*)\((?<loc>[0-9,]+)\)$) or return (file => $loc, msg => $msg);
my ($file, $line) = ($+{file}, split ',', $+{loc});
return (file => $file, line => $line, msg => $msg);
}
sub toRelativePath
{
my $path = shift;
return $path if not File::Spec->file_name_is_absolute($path);
return File::Spec->rel2abs($path) if index($path, getcwd()) == 0;
return $path;
}