forked from magma/magma
-
Notifications
You must be signed in to change notification settings - Fork 1
301 lines (287 loc) · 11.2 KB
/
reviewdog-workflow.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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# Copyright 2022 The Magma Authors.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# owner: any
# purpose: Linting various components
# remediation: -
name: PR Lint Reviewdog
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number}}
cancel-in-progress: true
# Applies on all review jobs below
# See Reviewdog doc provided at https://github.com/reviewdog/reviewdog
# github-pr-check: Adds lint as annotations in the PR that can be toggled by pressing 'a'
# github-pr-review: Adds lint as GitHub comments
jobs:
files_changed:
runs-on: ubuntu-20.04
outputs:
changed_cpp: ${{ steps.changes.outputs.cpp }}
changed_javascript: ${{ steps.changes.outputs.javascript }}
changed_python: ${{ steps.changes.outputs.python }}
changed_terraform: ${{ steps.changes.outputs.terraform }}
steps:
# Need to get git on push event
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
if: github.event_name == 'push'
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # [email protected]
id: changes
with:
filters: |
cpp:
- ["lte/gateway/c/**", "orc8r/gateway/c/**", "lte/gateway/python/**"]
javascript:
- ["nms/**", "**/*.js"]
python:
- ["**/*.py"]
terraform:
- ["**/*.tf"]
cpplint:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_cpp == 'true' }}
##
# Cpplint aims to lint to the Google Style guide. For detailed
# rationale on each linting rule, see
# https://google.github.io/styleguide/cppguide.html
##
# To suppress false-positive errors of a certain category, add a
# 'NOLINT(category)' comment to the line. NOLINT or NOLINT(*)
# suppresses errors of all categories on that line.
##
# For details on cpplint options see the detailed comments in
# https://github.com/google/styleguide/blob/gh-pages/cpplint/cpplint.py
##
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
# TODO: Switch to a release version, once a release of action-cpplint is available.
# See also https://github.com/reviewdog/action-cpplint/issues/29
- name: cpplint
uses: reviewdog/action-cpplint@a5d486c641b1ae5fd018b4fe6bf7bef3bc6e506e
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
flags: --linelength=120
filter: "-build/include_subdir\
,-build/c++11\
,-build/include_what_you_use\
"
reviewdog_flags: -fail-on-error
golangci-lint:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_go == 'true' }}
runs-on: ubuntu-20.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: golangci-lint
uses: reviewdog/action-golangci-lint@53f8eabb87b40b1a2c63ec75b0d418bd0f4aa919 # [email protected]
with:
golangci_lint_flags: '--config=../../.golangci.yml'
reporter: github-pr-review
workdir: src/go/
hadolint:
name: dockerfile-lint
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: hadolint
uses: reviewdog/action-hadolint@55be5d2c4b0b80d439247b128a9ded3747f92a29 # pin@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
# Ignore DL3005-"Do not use apt-get upgrade or dist-upgrade"
hadolint_ignore: DL3005
eslint:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_javascript == 'true' }}
name: eslint
runs-on: ubuntu-20.04
steps:
- name: Check out code.
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: setup node
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # [email protected]
with:
node-version: 16
- name: install dependencies
run: yarn install
working-directory: 'nms/'
- name: eslint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
workdir: 'nms/'
markdownlint:
name: markdownlint
runs-on: ubuntu-20.04
steps:
- name: Check out code.
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: markdownlint
uses: reviewdog/action-markdownlint@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
filter_mode: added
reporter: github-pr-review
fail_on_error: false
markdownlint_flags: "--config ./docs/readmes/.markdownlint.yaml ."
misspell:
name: misspell
runs-on: ubuntu-20.04
steps:
- name: Check out code.
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: misspell
uses: reviewdog/action-misspell@811b1e15f531430be3a5784e3d591bd657df18b0 # pin@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
locale: "US"
exclude: |
./nms/yarn.lock
mypy:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_python == 'true' }}
name: mypy
runs-on: ubuntu-20.04
steps:
- name: Check out code.
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Run mypy with reviewdog
uses: tsuyoshicho/action-mypy@176f65a2ad781202baffaf870e5715d768d799a8 # [email protected]
with:
github_token: ${{ secrets.github_token }}
filter_mode: file
reporter: github-pr-review
shellcheck:
name: shellcheck
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: shellcheck
uses: reviewdog/action-shellcheck@66c9a47bf02255b250284a82251cb4cadf5043f5 # pin@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
pattern: "*.sh" # Optional.
tflint:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_terraform == 'true' }}
name: tflint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Run tflint with reviewdog
uses: reviewdog/action-tflint@86b1913cb664b079cb435014ad64835acf66c639 # [email protected]
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
fail_on_error: true
level: info
wemake-python-styleguide:
needs: files_changed
if: ${{ needs.files_changed.outputs.changed_python == 'true' }}
name: wemake-python-styleguide
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Get changed Python files
id: py-changes
# Set outputs.py_files_list to be a list of modified python files.
# It is important to use the github.event.pull_request.head.sha here,
# because the github.sha is identical to the github.event.pull_request.base.sha
# due to the pull_request_target trigger.
run: |
echo "py_files_list=$(git diff --name-only --diff-filter=ACMRT \
${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
| grep .py$ | xargs)" >> $GITHUB_OUTPUT
- name: wemake-python-styleguide
uses: wemake-services/wemake-python-styleguide@657508a0b169e15faeda641c4d9c7bc2afda484b # [email protected]
with:
reporter: github-pr-review
path: ${{ steps.py-changes.outputs.py_files_list }}
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
- name: Info for local execution
if: failure()
run: |
echo "Running linting tools failed. This should be equivalent to running './lte/gateway/python/precommit.py --lint --diff' locally."
exit 1
yamllint:
name: yamllint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # [email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: yamllint
uses: reviewdog/action-yamllint@8c429dfe4fc47b1ce1fa99a64e94693880d5dc30 # pin@v1
with:
github_token: ${{ secrets.github_token }}
filter_mode: added
reporter: github-pr-review
level: warning
yamllint_flags: "-d .github/workflows/config/yamllint_config.yml ."