generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 126
178 lines (149 loc) Β· 4.26 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
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@v3
with:
fetch-depth: 0
- name: Check commits
uses: wagoid/commitlint-github-action@v5
lint-markdown:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Lint regular markdown files
uses: avto-dev/markdown-lint@v1.5.0
with:
args: '**/*.md'
ignore: 'CHANGELOG.md docs/**/*.md'
- name: Lint generated markdown files
uses: avto-dev/markdown-lint@v1.5.0
with:
args: 'docs/**/*.md'
config: 'docs/.markdownlint.yaml'
lint-yaml:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Lint yaml files
uses: ibiqlik/action-yamllint@v3.1.1
lint-json:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- 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@v3
with:
fetch-depth: 0
- name: Find changed go files
id: changed-go-files
uses: tj-actions/changed-files@v35.9.2
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/setup-go@v4.0.1
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
go-version: '1.20'
cache: false
- name: Lint go code (golangci-lint)
uses: golangci/golangci-lint-action@v3
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
version: v1.53
- name: Lint go code (gofumpt)
if: steps.changed-go-files.outputs.any_changed == 'true'
run: |
go install mvdan.cc/gofumpt@v0.4.0
if [ "$(gofumpt -l .)" != "" ]; then
echo "β Code is not gofumpt!"
exit 1
fi
echo "β
Code is gofumpt!"
lint-dockerfile:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Lint dockerfile (hadolint)
uses: hadolint/hadolint-action@v3.1.0
with:
verbose: true
lint-proto:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find changed proto files
id: changed-proto-files
uses: tj-actions/changed-files@v35.9.2
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@v3
- name: Setup Go environment
uses: actions/setup-go@v4.0.1
with:
go-version: '1.20'
- name: Generate command documentation
run: |
make doc-command
- name: Generate proto and documentation
run: |
make doc-proto
- 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