-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (77 loc) · 2.78 KB
/
code-checks.yml
File metadata and controls
90 lines (77 loc) · 2.78 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Static Checks
on:
push:
branches: [ main, develop ] # never pushing directly to main
pull_request:
branches: [ main, develop ]
workflow_dispatch:
permissions:
contents: read
packages: read # to pull from private GHCR
jobs:
analyze:
runs-on: ubuntu-22.04
container:
image: ghcr.io/voismart/freeswitch-sdk:ci # make org name dynamic in case of future org name changes
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Format check
run: |
set -eux
ALL_FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp')"
FILES="$(echo "$ALL_FILES" | grep -v '^libs/' || true)"
if [ -n "$FILES" ]; then
clang-format --dry-run --Werror $FILES
fi
- name: Configure
run: |
set -eux
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Analyze
run: |
set -eux
scan-build --status-bugs cmake --build build -j"$(nproc)"
ALL_FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx')"
FILES="$(echo "$ALL_FILES" | grep -v '^libs/' || true)"
if [ -n "$FILES" ]; then
clang-tidy -p build $FILES \
--warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*'
else
echo "No source files found for clang-tidy analysis."
fi
cppcheck --enable=warning,performance,portability --std=c++17 --force \
--project=build/compile_commands.json \
--suppress=missingIncludeSystem \
-i build -i libs 2> cppcheck-warn.log
cppcheck --enable=style --std=c++17 --force \
--project=build/compile_commands.json \
--suppress=missingIncludeSystem \
-i build -i libs 2> cppcheck-style.log || true
if [ -s cppcheck-style.log ]; then
echo "Style issues found by cppcheck:"
cat cppcheck-style.log
else
echo "No style issues found by cppcheck."
fi
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: static-checks-logs
path: |
cppcheck-warn.log
cppcheck-style.log
build/compile_commands.json