-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (96 loc) · 3.3 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Linting pipeline
run-name: Linting pipeline triggered by ${{ github.actor }}
on:
workflow_call:
# push:
# branches-ignore:
# - main
jobs:
lint-python:
runs-on: self-hosted
id: python
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Print branch
run: |
echo "Checked out branch: ${{ github.head_ref }}"
- name: Show directory contents
run: |
echo "Current directory: $(pwd)"
echo "Directory contents:"
ls -la
- name: List files in the repository
run: |
echo "github workspace folder"
ls ${{ github.workspace }}
- name: Check current directory
run: pwd
- name: List files in current directory
run: ls -la
- name: List root directory
run: ls -la /
- name: List runner's work directory
run: ls -la /home/runner/work
- name: List GitHub workspace directory
run: ls -la ${{ github.workspace }}
- name: Show environment variables
run: env
- 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]"