-
Notifications
You must be signed in to change notification settings - Fork 34
59 lines (49 loc) · 2.2 KB
/
clang-tidy-lint.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
47
48
49
50
51
52
53
54
55
56
57
58
59
name: 🔍 Static Analysis
on:
pull_request:
branches: [ main ]
env:
BUILD_TYPE: Release
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install xorg-dev libglu1-mesa-dev gcc-11 g++-11 clang-tidy
- name: Make all changed headers reachable
run: |
git diff -U0 --name-only HEAD^ | grep -oP 'core/include/\K.*.hpp' | awk '{ $0= "#include <" $0 ">"; print }' > core/src/extra.cpp
git diff -U0 --name-only HEAD^ | grep -oP 'core/src/\K.*.hpp' | awk '{ $0= "#include \"" $0 "\""; print }' >> core/src/extra.cpp
sed -i '/set(CUBOS_CORE_SOURCE/a "src/extra.cpp"' core/CMakeLists.txt
git add core/src/extra.cpp
git diff -U0 --name-only HEAD^ | grep -oP 'engine/include/\K.*.hpp' | awk '{ $0= "#include <" $0 ">"; print }' > engine/src/extra.cpp
git diff -U0 --name-only HEAD^ | grep -oP 'engine/src/\K.*.hpp' | awk '{ $0= "#include \"" $0 "\""; print }' >> engine/src/extra.cpp
sed -i '/set(CUBOS_ENGINE_SOURCE/a "src/extra.cpp"' engine/CMakeLists.txt
git add engine/src/extra.cpp
- name: Prepare compile_commands.json
run: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_CORE_SAMPLES=ON -DBUILD_CORE_TESTS=ON -DBUILD_ENGINE_SAMPLES=ON -DUSE_CLANG_TIDY=ON
shell: bash
env:
CC: gcc-11
CXX: g++-11
- name: Build glad
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target glad
- name: Analyze
run: |
run-clang-tidy -j$(nproc) -p=build \
-header-filter="(core|engine)/(src|include)/.*" \
files "($(git diff -U0 --name-only HEAD^ | grep -vP '.*/lib/.*' | paste -s -d\|))" \
-export-fixes clang-tidy-fixes.yaml || true
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clang_tidy_fixes: clang-tidy-fixes.yaml
request_changes: true
suggestions_per_comment: 10