-
Notifications
You must be signed in to change notification settings - Fork 0
358 lines (316 loc) · 10.2 KB
/
Copy pathmain.yml
File metadata and controls
358 lines (316 loc) · 10.2 KB
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: main
run-name: ${{ github.head_ref }}@${{ github.sha }}
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
changed-files:
name: analyze_changed_files
runs-on: ubuntu-latest
outputs:
# modules
modClock: ${{ steps.list-changed-files.outputs.clock_all_changed_files }}
modHttpmisc: ${{ steps.list-changed-files.outputs.httpmisc_all_changed_files }}
modHue: ${{ steps.list-changed-files.outputs.hue_all_changed_files }}
modIdentifier: ${{ steps.list-changed-files.outputs.identifier_all_changed_files }}
modJsonutil: ${{ steps.list-changed-files.outputs.jsonutil_all_changed_files }}
modLogging: ${{ steps.list-changed-files.outputs.logging_all_changed_files }}
modMisc: ${{ steps.list-changed-files.outputs.misc_all_changed_files }}
modCmdCopyright: ${{ steps.list-changed-files.outputs.cmd_t0copyright_all_changed_files }}
modCmdGenGoWork: ${{ steps.list-changed-files.outputs.cmd_gen_go_work_all_changed_files }}
modCmdFiler: ${{ steps.list-changed-files.outputs.cmd_t0filer_all_changed_files }}
modCmdChangelog: ${{ steps.list-changed-files.outputs.cmd_t0changelog_all_changed_files }}
# others
anyGoMod: ${{ steps.list-changed-files.outputs.any_go_mod_all_changed_files }}
rootGoMod: ${{ steps.list-changed-files.outputs.root_go_mod_all_changed_files }}
cmdGoMod: ${{ steps.list-changed-files.outputs.cmd_go_mod_all_changed_files }}
config: ${{ steps.list-changed-files.outputs.config_all_changed_files }}
shell: ${{ steps.list-changed-files.outputs.shell_all_changed_files }}
doc: ${{ steps.list-changed-files.outputs.doc_all_changed_files }}
anyCodeAdded: ${{ steps.list-changed-files.outputs.any_code_added_files }}
anyMod: ${{
steps.list-changed-files.outputs.clock_all_changed_files
|| steps.list-changed-files.outputs.httpmisc_all_changed_files
|| steps.list-changed-files.outputs.hue_all_changed_files
|| steps.list-changed-files.outputs.identifier_all_changed_files
|| steps.list-changed-files.outputs.jsonutil_all_changed_files
|| steps.list-changed-files.outputs.logging_all_changed_files
|| steps.list-changed-files.outputs.misc_all_changed_files
|| steps.list-changed-files.outputs.cmd_copyright_all_changed_files
|| steps.list-changed-files.outputs.cmd_gen_go_work_all_changed_files
|| steps.list-changed-files.outputs.cmd_gen_vscode_tasks_all_changed_files
}}
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Changed files
id: list-changed-files
uses: tj-actions/changed-files@v45.0.1
with:
# since_last_remote_commit: true # use only for testing, it's easy to produce no changed files
files_yaml_from_source_file: .changed-files.yml
debug:
name: debug
runs-on: ubuntu-latest
if: false # change to debug
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
steps:
- name: Debug
run: true
commitlint:
name: commit_lint
runs-on: ubuntu-latest
needs: changed-files
env:
# will not be set when running on push/merge to main
PR_TITLE: ${{ github.event.pull_request.title }}
BASH_ENV: ./sh/lib/lib.sh
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
submodules: true
- name: Create package-lock.json
run: echo '{}' > package-lock.json
- name: Setup Node.js environment
uses: actions/setup-node@v4.0.3
with:
node-version: lts/iron
cache: npm
- run: |
npm --global install @commitlint/config-conventional
npm install --global @commitlint/cli@19.3.0
npm install --global cspell@8.14.2
- name: Run commitlint
env:
COMMITLINT_CONFIG_PATH: .commitlintrc.yml
CSPELL_CONFIG_PATH: .cspell.config.yml
# will not be set when running on push/merge to main
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: ./sh/lib/workflows/main/commit_lint.sh
root-go-mod:
name: root_go_mod_up_to_date
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.rootGoMod
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: 1.23.1
- name: Go mod
uses: j0hnsmith/go-mod-check@v1
with:
working-directory: .
cmd-go-mod:
name: cmd_go_mod_up_to_date
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.cmdGoMod
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: 1.23.1
- name: Go mod
uses: j0hnsmith/go-mod-check@v1
with:
working-directory: cmd
go-work:
name: go_work_up_to_date
runs-on: ubuntu-latest
needs: changed-files
if: false && needs.changed-files.outputs.anyGoMod
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
with:
submodules: true
- name: Generate go work
run: go run cmd/gengowork/main.go
- name: Diff
run: ./sh/lib/workflows/main/diff.sh
mocks:
name: go_mocks_up_to_date
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.anyMod1
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
with:
submodules: true
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: 1.23.1
- name: Mockery
uses: brokeyourbike/go-mockery-action@v0.1.7
with:
mockery-version: "2.43.0"
env:
BASH_ENV: ./sh/lib/lib.sh
- run: ./sh/lib/go/generate_mocks.sh
- name: Diff
run: ./sh/lib/workflows/main/diff.sh
shell:
name: lint_format_shell
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.shell
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Lint and format
uses: luizm/action-sh-checker@v0.8.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHFMT_OPTS: -d -i 2 -ln bash
SHELLCHECK_OPTS: -x --severity=warning
with:
sh_checker_only_diff: true
config:
name: format_config
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.config
env:
FILES: ${{ needs.changed-files.outputs.config }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Prettier
uses: actionsx/prettier@v3
with:
args: --check ${{ env.FILES }}
spellcheck:
name: spellcheck
runs-on: ubuntu-latest
needs: changed-files
# doesn't work on local ci, finds 0 files and gives false ok
if: (needs.changed-files.outputs.anyCodeAdded || needs.changed-files.outputs.doc) && github.event.local != true
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Cspell
uses: streetsidesoftware/cspell-action@v6.8.1
with:
files: "."
incremental_files_only: true
config: ./.cspell.config.yml
copyright:
name: copyright
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.anyCodeAdded
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Set up Go
uses: actions/setup-go@v5.0.2
with:
go-version: 1.23.1
- name: Run Copyright
run: |
go run ./cmd/t0copyright -check '*.go'
go run ./cmd/t0copyright -check '*.sh'
###########
# modules #
###########
clock:
name: clock
needs: changed-files
if: needs.changed-files.outputs.modClock
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: clock
httpmisc:
name: httpmisc
needs: changed-files
if: needs.changed-files.outputs.modHttpMisc
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: httpmisc
hue:
name: hue
needs: changed-files
if: needs.changed-files.outputs.modHue
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: hue
identifier:
name: identifier
needs: changed-files
if: needs.changed-files.outputs.modIdentifier
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: identifier
jsonutil:
name: jsonutil
needs: changed-files
if: needs.changed-files.outputs.modJsonutil
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: jsonutil
logging:
name: logging
needs: changed-files
if: needs.changed-files.outputs.modLogging
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: logging
misc:
name: misc
needs: changed-files
if: needs.changed-files.outputs.modMisc
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: misc
cmd-t0copyright:
name: cmd/t0copyright
needs: changed-files
if: needs.changed-files.outputs.modCmdCopyright
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: cmd/t0copyright
generate-go-work:
name: cmd/gengowork
needs: changed-files
if: needs.changed-files.outputs.modCmdGenGoWork
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: cmd/gengowork
cmd-t0filer:
name: cmd/t0filer
needs: changed-files
if: needs.changed-files.outputs.modCmdFiler
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: cmd/t0filer
cmd-t0changelog:
name: cmd/t0changelog
needs: changed-files
if: needs.changed-files.outputs.modCmdChangelog
uses: ./.github/workflows/module_pr.yml
with:
goVersion: 1.23.1
modulePath: cmd/t0changelog