-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (69 loc) · 2.42 KB
/
linting.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
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
name: Linting pipeline
on:
workflow_call:
# push:
# branches-ignore:
# - main
jobs:
lint-python:
runs-on: self-hosted
id: python
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Format Python Code with Black
run: |
black .
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Apply Black formatting" || echo "No changes to commit"
git push origin HEAD
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# for main branch should verify the ros package gets built sucessfully, unit tests run
# for this, if the normal cpp format dont work with I() then use the ament_lint from ros
lint-cpp:
runs-on: self-hosted
id: cpp
steps:
- name: Checkout Code
uses: actions/checkout@v3
# path agnostic ros2 colcon build
- name: Run Colcon build
- name: Locate and Run Clang-Tidy
run: |
COMPILE_COMMANDS_PATH=$(find build/ -name compile_commands.json | head -n 1)
if [ -z "$COMPILE_COMMANDS_PATH" ]; then
echo "Error: compile_commands.json not found!"
exit 1
fi
echo "Using compile_commands.json located at: $COMPILE_COMMANDS_PATH"
find src/ -name "*.cpp" | xargs clang-tidy --fix --fix-errors -p $(dirname $COMPILE_COMMANDS_PATH)
# Format C++ files with clang-format
- name: Auto-fix C++ Formatting Issues
run: |
find . -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i
- name: Commit and Push Changes
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Auto-format code with clang-tidy/clang-format" || echo "No changes to commit"
git push origin HEAD
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# bug checks
# compilation
# linting/formatting
# Ament_flake8
# Ament_lint_cmake
# Ament_xmllint
# Black
# Clang-tidy
# Isort
# flake8 --fix or autopep8 --in-place --aggressive --aggressive
# git config --global user.email "[email protected]"
# how to run inside container, need to make linting/formatting container w/ git, python, etc.
# git config --global user.name "github-actions"
# git config --global user.email "[email protected]"