Skip to content

Commit

Permalink
add clang-tidy step to build-and-test
Browse files Browse the repository at this point in the history
Signed-off-by: Autumn60 <[email protected]>
  • Loading branch information
Autumn60 committed Jul 23, 2024
1 parent 364ddfd commit 97d7b56
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/merge_compile_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json
import os


def merge_compile_commands(output_file):
"""Merge all compile_commands.json files into one."""
compile_commands = []
for root, dirs, files in os.walk("."):
if "compile_commands.json" in files:
with open(os.path.join(root, "compile_commands.json"), "r") as f:
compile_commands.extend(json.load(f))
with open(output_file, "w") as f:
json.dump(compile_commands, f, indent=2)


if __name__ == "__main__":
merge_compile_commands("compile_commands.json")
14 changes: 13 additions & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
id: build_test
run: |
. /opt/ros/${{ matrix.rosdistro }}/setup.sh &&
colcon build
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
continue-on-error: true

- name: build_test command success
Expand All @@ -64,3 +64,15 @@ jobs:
- name: run_test command failure
if: steps.run_test.outcome == 'failure'
run: echo "result - failure" && exit 1

- name: Install clang-tidy
run: apt-get install clang-tidy

- name: Merge compile_commands.json
run: |
python3 .github/merge_compile_commands.py
- name: Run clang-tidy
run: |
clang-tidy -p compile_commands.json find src/ -name "*.cpp"
continue-on-error: true
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ repos:
rev: v0.10.0
hooks:
- id: flake8-ros
exclude: ^\.github/merge_compile_commands\.py$
- id: prettier-xacro

Check warning on line 47 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (xacro)
- id: prettier-launch-xml
- id: prettier-package-xml
Expand Down

0 comments on commit 97d7b56

Please sign in to comment.