Skip to content

Commit 8a5fa65

Browse files
authored
Create cppcheck.yml
1 parent 73bdf85 commit 8a5fa65

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/cppcheck.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: cppcheck
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
name: cppcheck-test
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: cppcheck
12+
uses: deep5050/cppcheck-action@main
13+
with:
14+
github_token: ${{ secrets.GITHUB_TOKEN}}
15+
std: c++17
16+
inline_suppression: enable
17+
exclude_check: ./tests
18+
output_file: cppcheck_report.txt
19+
20+
- name: print output
21+
run: |
22+
REPORTFILE=./cppcheck_report.txt
23+
WARNINGSFILE=./warnings.txt
24+
if test -f "$REPORTFILE"; then
25+
# Filter innocuous warnings and write the remaining ones to another file.
26+
# Note that you can add more warnings by adding it in the parenthesis,
27+
# with "\|" in front of it. For example, "(missingIncludeSystem\|useStlAlgorithm\)"
28+
sed 's/\[\(missingIncludeSystem\|useStlAlgorithm\)\]//g' "$REPORTFILE" > "$WARNINGSFILE"
29+
# are there any remaining warnings?
30+
if grep -qP '\[[a-zA-Z0-9]+\]' "$WARNINGSFILE"; then
31+
# print the remaining warnings
32+
echo Warnings detected:
33+
echo ==================
34+
cat "$WARNINGSFILE" | grep -P '\[[a-zA-Z0-9]+\]'
35+
# fail the job
36+
exit 1
37+
else
38+
echo No warnings detected
39+
fi
40+
else
41+
echo "$REPORTFILE" not found
42+
fi

0 commit comments

Comments
 (0)