-
Notifications
You must be signed in to change notification settings - Fork 26
46 lines (42 loc) · 1.97 KB
/
cppcheck.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: cppcheck
on: [push]
jobs:
build:
name: cppcheck-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create test file
run: |
echo $'#include \"danish_stem.h\" \#include \"dutch_stem.h\" \#include \"english_stem.h\" \#include \"finnish_stem.h\" \#include \"french_stem.h\" \#include \"german_stem.h\" \#include \"italian_stem.h\" \#include \"norwegian_stem.h\" \#include \"portuguese_stem.h\" \#include \"russian_stem.h\" \#include \"spanish_stem.h\" \#include \"swedish_stem.h\"' > ./src/test.cpp
- name: cppcheck
uses: deep5050/cppcheck-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN}}
std: c++17
inline_suppression: enable
exclude_check: ./tests
output_file: cppcheck_report.txt
- name: print output
run: |
REPORTFILE=./cppcheck_report.txt
WARNINGSFILE=./warnings.txt
if test -f "$REPORTFILE"; then
# Filter innocuous warnings and write the remaining ones to another file.
# Note that you can add more warnings by adding it in the parenthesis,
# with "\|" in front of it. For example, "(missingIncludeSystem\|useStlAlgorithm\)"
sed 's/\[\(missingIncludeSystem\|internalAstError\|unmatchedSuppression\|useStlAlgorithm\)\]//g' "$REPORTFILE" > "$WARNINGSFILE"
# are there any remaining warnings?
if grep -qP '\[[a-zA-Z0-9]{5,}\]' "$WARNINGSFILE"; then
# print the remaining warnings
echo Warnings detected:
echo ==================
cat "$WARNINGSFILE" | grep -P '\[[a-zA-Z0-9]{5,}\]'
# fail the job
exit 1
else
echo No warnings detected
fi
else
echo "$REPORTFILE" not found
fi