mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
[CI] Make cppcheck and compiler warnings visible in Github Actions runs
This commit is contained in:
46
.github/workflows/build.yml
vendored
46
.github/workflows/build.yml
vendored
@@ -46,6 +46,8 @@ jobs:
|
|||||||
checks:
|
checks:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
needs: preBuild
|
needs: preBuild
|
||||||
|
outputs:
|
||||||
|
warnings: ${{ steps.cppcheck.outputs.warnings }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -53,17 +55,21 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Run cppcheck
|
- name: Run cppcheck
|
||||||
|
id: cppcheck
|
||||||
run: |
|
run: |
|
||||||
sudo apt install cppcheck
|
sudo apt install cppcheck
|
||||||
|
sudo cpan Path::Class
|
||||||
cppcheck --template=gcc --inline-suppr --std=c++14 --enable=style,unusedFunction -i externals \
|
cppcheck --template=gcc --inline-suppr --std=c++14 --enable=style,unusedFunction -i externals \
|
||||||
--suppressions-list=cppcheck.supp --library=qt.cfg --library=posix.cfg . | tee error.log
|
--suppressions-list=cppcheck.supp --library=qt.cfg --library=posix.cfg . | tee error.log
|
||||||
ls -l error.log
|
perl scripts/warnings.pl error.log
|
||||||
|
|
||||||
buildLinux:
|
buildLinux:
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-16.04
|
||||||
needs: preBuild
|
needs: preBuild
|
||||||
env:
|
env:
|
||||||
BITROCK_BUILDER: ~/installbuilder/bin/builder
|
BITROCK_BUILDER: ~/installbuilder/bin/builder
|
||||||
|
outputs:
|
||||||
|
warnings: ${{ steps.warnings.outputs.warnings }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
@@ -80,6 +86,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt install doxygen graphviz libglu1-mesa-dev libopus-dev libsodium-dev libpulse-dev libdbus-1-dev libevent-dev
|
sudo apt install doxygen graphviz libglu1-mesa-dev libopus-dev libsodium-dev libpulse-dev libdbus-1-dev libevent-dev
|
||||||
pip3 install tee
|
pip3 install tee
|
||||||
|
sudo cpan Path::Class
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@@ -99,12 +106,14 @@ jobs:
|
|||||||
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
||||||
run: |
|
run: |
|
||||||
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file"
|
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file"
|
||||||
ls -l error.log
|
|
||||||
- name: Build swift (with symbols)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file" --upload
|
python3 -u scripts/build.py -w 64 -t gcc -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file" --upload
|
||||||
ls -l error.log
|
- name: Check warnings
|
||||||
|
id: warnings
|
||||||
|
run: |
|
||||||
|
perl scripts/warnings.pl error.log
|
||||||
- name: Upload installer
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
@@ -127,6 +136,8 @@ jobs:
|
|||||||
needs: preBuild
|
needs: preBuild
|
||||||
env:
|
env:
|
||||||
BITROCK_BUILDER: "$(USERPROFILE)/installbuilder/bin/builder-cli.exe"
|
BITROCK_BUILDER: "$(USERPROFILE)/installbuilder/bin/builder-cli.exe"
|
||||||
|
outputs:
|
||||||
|
warnings: ${{ steps.warnings.outputs.warnings }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
@@ -162,12 +173,14 @@ jobs:
|
|||||||
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
||||||
run: |
|
run: |
|
||||||
python.exe -u scripts\build.py -w 64 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file"
|
python.exe -u scripts\build.py -w 64 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file"
|
||||||
dir error.log
|
|
||||||
- name: Build swift (with symbols)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
python.exe -u scripts\build.py -w 64 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file" --upload
|
python.exe -u scripts\build.py -w 64 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file" --upload
|
||||||
dir error.log
|
- name: Check warnings
|
||||||
|
id: warnings
|
||||||
|
run: |
|
||||||
|
perl scripts/warnings.pl error.log
|
||||||
- name: Upload installer
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
@@ -190,6 +203,8 @@ jobs:
|
|||||||
needs: preBuild
|
needs: preBuild
|
||||||
env:
|
env:
|
||||||
BITROCK_BUILDER: "$(USERPROFILE)/installbuilder/bin/builder-cli.exe"
|
BITROCK_BUILDER: "$(USERPROFILE)/installbuilder/bin/builder-cli.exe"
|
||||||
|
outputs:
|
||||||
|
warnings: ${{ steps.warnings.outputs.warnings }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
@@ -225,12 +240,14 @@ jobs:
|
|||||||
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
||||||
run: |
|
run: |
|
||||||
python.exe -u scripts\build.py -w 32 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file"
|
python.exe -u scripts\build.py -w 32 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file"
|
||||||
dir error.log
|
|
||||||
- name: Build swift (with symbols)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
python.exe -u scripts\build.py -w 32 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file" --upload
|
python.exe -u scripts\build.py -w 32 -t msvc -d -e $env:eol_months -q "SWIFT_CONFIG_JSON+=$env:vatsim_key_file" --upload
|
||||||
dir error.log
|
- name: Check warnings
|
||||||
|
id: warnings
|
||||||
|
run: |
|
||||||
|
perl scripts/warnings.pl error.log
|
||||||
- name: Upload installer
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
@@ -253,6 +270,8 @@ jobs:
|
|||||||
needs: preBuild
|
needs: preBuild
|
||||||
env:
|
env:
|
||||||
BITROCK_BUILDER: /Applications/installbuilder/bin/Builder.app/Contents/MacOS/installbuilder.sh
|
BITROCK_BUILDER: /Applications/installbuilder/bin/Builder.app/Contents/MacOS/installbuilder.sh
|
||||||
|
outputs:
|
||||||
|
warnings: ${{ steps.warnings.outputs.warnings }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
@@ -274,6 +293,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
pip3 install requests
|
pip3 install requests
|
||||||
pip3 install tee
|
pip3 install tee
|
||||||
|
cpan Path::Class
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@@ -293,12 +313,14 @@ jobs:
|
|||||||
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
if: ${{ ! (env.do_symbols == 'true' && env.do_vatsim_key == 'true') }}
|
||||||
run: |
|
run: |
|
||||||
python3 -u scripts/build.py -w 64 -t clang -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file"
|
python3 -u scripts/build.py -w 64 -t clang -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file"
|
||||||
ls -l error.log
|
|
||||||
- name: Build swift (with symbols)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
if: ${{ env.do_symbols == 'true' && env.do_vatsim_key == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
python3 -u scripts/build.py -w 64 -t clang -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file" --upload
|
python3 -u scripts/build.py -w 64 -t clang -d -j2 -e $eol_months -q "SWIFT_CONFIG_JSON+=$vatsim_key_file" --upload
|
||||||
ls -l error.log
|
- name: Check warnings
|
||||||
|
id: warnings
|
||||||
|
run: |
|
||||||
|
perl scripts/warnings.pl error.log
|
||||||
- name: Upload installer
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
@@ -351,11 +373,13 @@ jobs:
|
|||||||
- name: Prepare Discord message
|
- name: Prepare Discord message
|
||||||
run: |
|
run: |
|
||||||
result=SUCCESS
|
result=SUCCESS
|
||||||
echo ${{ join(needs.*.result, ' ') }} | grep -q cancel && result=CANCELLED
|
expr ${{ join(needs.*.outputs.warnings, ' + ') }} && result=WARNING
|
||||||
echo ${{ join(needs.*.result, ' ') }} | grep -q fail && result=FAILED
|
echo ${{ join(needs.*.result, ' ') }} | grep -q fail && result=FAILED
|
||||||
|
echo ${{ join(needs.*.result, ' ') }} | grep -q cancel && result=CANCELLED
|
||||||
[[ $result = SUCCESS ]] && emoji=white_check_mark
|
[[ $result = SUCCESS ]] && emoji=white_check_mark
|
||||||
[[ $result = CANCELLED ]] && emoji=grey_question
|
[[ $result = WARNING ]] && emoji=warning
|
||||||
[[ $result = FAILED ]] && emoji=x
|
[[ $result = FAILED ]] && emoji=x
|
||||||
|
[[ $result = CANCELLED ]] && emoji=grey_question
|
||||||
echo "::set-env name=result::$result"
|
echo "::set-env name=result::$result"
|
||||||
echo "::set-env name=emoji::$emoji"
|
echo "::set-env name=emoji::$emoji"
|
||||||
- name: Send Discord message
|
- name: Send Discord message
|
||||||
|
|||||||
74
scripts/warnings.pl
Normal file
74
scripts/warnings.pl
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Convert C++ compiler warnings into Github Actions workflow commands
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 swift Project Community / contributors
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Path::Class;
|
||||||
|
|
||||||
|
my %cmds;
|
||||||
|
while (<<>>)
|
||||||
|
{
|
||||||
|
chomp;
|
||||||
|
my %result = extractWarning($_);
|
||||||
|
next if not %result;
|
||||||
|
$result{file} = toRelativePath($result{file})->as_foreign('Unix');
|
||||||
|
if (exists $result{line}) {
|
||||||
|
++$cmds{"::warning file=$result{file},line=$result{line}::$result{msg}"};
|
||||||
|
} else {
|
||||||
|
++$cmds{"::warning file=$result{file}::$result{msg}"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my @cmds = sort keys %cmds;
|
||||||
|
my $count = scalar @cmds;
|
||||||
|
print "$_\n" for @cmds;
|
||||||
|
print "::set-output name=warnings::$count\n";
|
||||||
|
|
||||||
|
sub extractWarning
|
||||||
|
{
|
||||||
|
my $line = shift;
|
||||||
|
my %result = extractGccWarning($line);
|
||||||
|
return %result if %result;
|
||||||
|
return extractMsvcWarning($line);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub extractGccWarning
|
||||||
|
{
|
||||||
|
my $line = shift;
|
||||||
|
$line =~ 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, $loc) = ($+{file}, split ':', $+{loc});
|
||||||
|
return (file => $file, line => $loc, msg => $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub extractMsvcWarning
|
||||||
|
{
|
||||||
|
my $line = shift;
|
||||||
|
$line =~ 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, $loc) = ($+{file}, split ',', $+{loc});
|
||||||
|
return (file => $file, line => $loc, msg => $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub toRelativePath
|
||||||
|
{
|
||||||
|
my $path = shift;
|
||||||
|
my $file = file($path);
|
||||||
|
return $file if $file->is_relative;
|
||||||
|
return $file->relative if dir()->absolute()->subsumes($file);
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user