-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (29 loc) · 962 Bytes
/
Check syntax.yaml
File metadata and controls
37 lines (29 loc) · 962 Bytes
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
name: Check syntax
on:
pull_request:
push:
branches:
- master
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install cpplint
run: |
sudo apt install cpplint
- name: Check C++ Syntax
run: |
cpp_files=$(find . -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp")
total_errors=0
for file in $cpp_files; do
errors=$(cpplint --filter=-build/include_subdir --extensions=cc,cpp,h,hpp --linelength=120 --recursive --repository=. --root=src $file | wc -l)
total_errors=$((total_errors + errors - 1))
done
if [[ $total_errors -gt 0 ]]; then
echo "Too many errors ($total_errors), failing the build."
exit 1
else
echo "Acceptable number of errors ($total_errors)."
fi