-
Notifications
You must be signed in to change notification settings - Fork 4
232 lines (227 loc) · 8.33 KB
/
ros2_style.yaml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: ros2_style
on:
workflow_call:
inputs:
python_version:
default: "3.12"
required: false
type: string
jobs:
changes:
name: changes
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
cpp: ${{ steps.changes.outputs.cpp }}
cpp_files: ${{ steps.changes.outputs.cpp_files }}
python: ${{ steps.changes.outputs.python }}
python_files: ${{ steps.changes.outputs.python_files }}
cmake: ${{ steps.changes.outputs.cmake }}
cmake_files: ${{ steps.changes.outputs.cmake_files }}
yaml: ${{ steps.changes.outputs.yaml }}
yaml_files: ${{ steps.changes.outputs.yaml_files }}
xml: ${{ steps.changes.outputs.xml }}
xml_files: ${{ steps.changes.outputs.xml_files }}
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: changed-file-filter
id: changes
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
with:
filters: |
cpp:
- added|modified: '**.h'
- added|modified: '**.hpp'
- added|modified: '**.hh'
- added|modified: '**.hxx'
- added|modified: '**.c'
- added|modified: '**.cpp'
- added|modified: '**.cc'
- added|modified: '**.cxx'
python:
- added|modified: '**.py'
cmake:
- added|modified: '**/CMakeLists.txt'
- added|modified: '**.cmake'
yaml:
- added|modified: '**.yaml'
- added|modified: '**.yml'
xml:
- added|modified: '**/package.xml'
- added|modified: '**.xacro'
- added|modified: '**.urdf'
list-files: "shell"
clang:
name: C++ style
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.cpp == 'true'
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Download config
# yamllint disable-line rule:line-length
run: wget https://raw.githubusercontent.com/sbgisen/.github/main/ros2/.clang-format -O .clang-format
- uses: DoozyX/clang-format-lint-action@c71d0bf4e21876ebec3e5647491186f8797fde31 # v0.18.2
with:
source: ${{ needs.changes.outputs.cpp_files }}
exclude: ""
extensions: "h,hpp,hh,hxx,c,cpp,cc,cxx"
clangFormatVersion: 16
style: file
inplace: true
- name: suggester / clang-format
uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e # v1.6.0
with:
tool_name: clang-format
filter_mode: file
fail_on_error: true
python:
name: Python style
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.python == 'true'
steps:
- name: Check out source repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Python3 environment
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: Download config
run: wget https://raw.githubusercontent.com/sbgisen/.github/main/pyproject.toml -O pyproject.toml
- name: yapf format
run: |
pip3 install yapf
yapf -ip --style pyproject.toml ${{ needs.changes.outputs.python_files }}
- name: Restore config
run: git diff --name-only | grep pyproject.toml | xargs git checkout
- name: suggester / autopep8
uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e # v1.6.0
with:
tool_name: yapf
filter_mode: file
fail_on_error: true
- name: Setup reviewdog
uses: reviewdog/action-setup@8f2ec89e6b467ca9175527d2a1641bbd0c05783b # v1.0.3
- name: ruff lint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
pip3 install ruff
cd ${{ github.workspace }}
wget https://raw.githubusercontent.com/sbgisen/.github/main/pyproject.toml -O pyproject.toml
file_list="${{ needs.changes.outputs.python_files }}"
ruff check --config pyproject.toml |\
reviewdog -name="ruff" -reporter=github-pr-review -efm='%f:%l:%c: %*[^0-9]%n %m' \
-filter-mode=file -fail-level=any
- name: isort # ref #53
run: |
pip3 install isort
cd ${{ github.workspace }}
file_list="${{ needs.changes.outputs.python_files }}"
isort --sp pyproject.toml ${file_list}
git diff --name-only | grep pyproject.toml | xargs git checkout
- name: suggester / isort
uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e # v1.6.0
with:
tool_name: isort
filter_mode: file
fail_on_error: true
cmake:
name: CMake style
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.cmake == 'true'
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python3 environment
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: Download config
# yamllint disable-line rule:line-length
run: wget https://raw.githubusercontent.com/sbgisen/.github/main/ros2/.cmake-format -O .cmake-format
- name: cmake-format
run: |
pip3 install cmake-format
cmake-format -c .cmake-format -i ${{ needs.changes.outputs.cmake_files }}
git diff --name-only | grep .cmake-format | xargs git checkout
- name: suggester / cmake-format
uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e # v1.6.0
with:
tool_name: cmake-format
filter_mode: file
fail_on_error: true
- name: Setup reviewdog
uses: reviewdog/action-setup@8f2ec89e6b467ca9175527d2a1641bbd0c05783b # v1.0.3
- name: cmake-lint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
pip3 install ament-lint-cmake-py
ament_lint_cmake ${{ needs.changes.outputs.cmake_files }} |\
reviewdog -name="cmake-lint" -reporter=github-pr-review -efm='%f:%l: %m' \
-filter-mode=file -fail-level=any
yamllint:
name: YAML style
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.yaml == 'true'
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Download config
run: wget https://raw.githubusercontent.com/sbgisen/.github/main/.yamllint -O .yamllint
- name: yamllint
uses: reviewdog/action-yamllint@8c429dfe4fc47b1ce1fa99a64e94693880d5dc30 # v1.6.1
with:
reporter: github-pr-review
filter_mode: file
fail_on_error: true
yamllint_flags: -s -c .yamllint ${{ needs.changes.outputs.yaml_files }}
xml:
name: XML style
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.xml == 'true'
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python3 environment
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}
- name: xml format
run: |
sudo apt update
sudo apt install libxml2-utils
echo ${{ needs.changes.outputs.xml_files }} |\
xargs -n 1 | xargs -I {} bash -c "xmllint --format {} |\
diff -B {} - |\
patch {}"
- name: suggester / xmllint
uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e # v1.6.0
with:
tool_name: xmllint
filter_mode: file
fail_on_error: true
- name: Setup reviewdog
uses: reviewdog/action-setup@8f2ec89e6b467ca9175527d2a1641bbd0c05783b # v1.0.3
- name: xmllint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
pip3 install ament-xmllint
ament_xmllint ${{ needs.changes.outputs.xml_files }} 2>&1 1>/dev/null |\
reviewdog -name="xmllint" -reporter=github-pr-review -efm='%f:%l: %m' \
-filter-mode=file -fail-level=any