Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add clang-tidy step to build-and-test #68

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -y

- 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 @@ -20,8 +20,8 @@
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (markdownlint)
args: [-c, .markdownlint.yaml, --fix]

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (markdownlint)

- repo: https://github.com/tcort/markdown-link-check
rev: v3.12.2
Expand All @@ -43,7 +43,8 @@
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
- id: ros-include-guard
Expand All @@ -52,18 +53,18 @@
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (shellcheck)

- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (shfmt)
args: [-w, -s, -i=4]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (isort)

- repo: https://github.com/psf/black
rev: 24.4.2
Expand All @@ -75,19 +76,19 @@
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c++, c, cuda]

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (cuda)

- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (cpplint)
args: [--quiet]
exclude: .cu

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.0
hooks:
- id: check-metaschema

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

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (metaschema)
files: ^.+/schema/.*schema\.json$

- repo: local
Expand Down
Loading