generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 126
235 lines (196 loc) Β· 5.51 KB
/
lint.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
name: Lint
on:
workflow_call:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-commits:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commits
uses: wagoid/commitlint-github-action@v6
lint-markdown:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint regular markdown files
uses: avto-dev/[email protected]
with:
args: "**/*.md"
ignore: "CHANGELOG.md docs/**/*.md"
- name: Lint generated markdown files
uses: avto-dev/[email protected]
with:
args: "docs/**/*.md"
config: "docs/.markdownlint.yaml"
lint-yaml:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint yaml files
uses: ibiqlik/[email protected]
lint-json:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint json files
run: |
sudo apt install -y jsonlint
find ./ -type f -name "*.json" -exec sh -c '
for file do
if ! jsonlint-php -q "$file"; then
echo "β $file"
export FAILED=1
else
echo "β
$file"
fi
done
if [ "${FAILED}" = "1" ]; then
exit 1
fi
' sh {} +
lint-go:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find changed go files
id: changed-go-files
uses: tj-actions/[email protected]
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/[email protected]
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
go-version: "1.21"
cache: false
- name: Lint go code (golangci-lint)
uses: golangci/golangci-lint-action@v6
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
version: v1.56
- name: Lint go code (gofumpt)
if: steps.changed-go-files.outputs.any_changed == 'true'
run: |
go install mvdan.cc/[email protected]
if [ "$(gofumpt -l .)" != "" ]; then
echo "β Code is not gofumpt!"
exit 1
fi
echo "β
Code is gofumpt!"
analyze-go:
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find changed go files
id: changed-go-files
uses: tj-actions/[email protected]
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.21"
cache: false
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "go"
- name: Autobuild project
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
lint-dockerfile:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint dockerfile (hadolint)
uses: hadolint/[email protected]
with:
verbose: true
lint-proto:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find changed proto files
id: changed-proto-files
uses: tj-actions/[email protected]
with:
files: |
proto/**/*.proto
- name: Lint proto files
if: steps.changed-proto-files.outputs.any_changed == 'true'
run: |
make lint-proto
lint-generated:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.21"
- name: Generate command documentation
run: |
make doc-command
- name: Generate proto and documentation
run: |
make doc-proto
- name: Generate predicates documentation
run: |
make doc-predicate
- name: Check Git diff in generated files (proto + docs)
run: |
if [[ $(git status -s | grep --fixed-strings -v "go.mod" | grep --fixed-strings -v "go.sum") != "" ]]; then
>&2 echo "β There is a diff between generated files and source code"
>&2 git status
exit 1
fi
lint-shell:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint shell scripts
uses: ludeeus/[email protected]
with:
scandir: .
version: "v0.9.0"
env:
SHELLCHECK_OPTS: -e SC2034