-
Notifications
You must be signed in to change notification settings - Fork 19
379 lines (330 loc) · 13.5 KB
/
eventlist.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
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
name: eventlist
on:
pull_request:
branches: [ main ]
paths:
- '.github/workflows/eventlist.yml'
- 'tools/eventlist/**'
- '!.github/workflows/tpip-check.yml'
- '!tools/eventlist/template/**'
push:
branches: [ main ]
paths:
- '.github/workflows/eventlist.yml'
- 'tools/eventlist/**'
- '!.github/workflows/tpip-check.yml'
- '!tools/eventlist/template/**'
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: |
github.event_name != 'release' ||
startsWith(github.ref, 'refs/tags/tools/eventlist/')
name: 'Build'
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: tools/eventlist/go.mod
check-latest: true
- name: Initialize CodeQL
if: github.event_name != 'release'
uses: github/codeql-action/init@v2
with:
languages: go
queries: security-and-quality
- name: Build linux-amd64 executable
run: |
./make.sh build -os linux -arch amd64 -outdir build/linux-amd64
working-directory: ./tools/eventlist
- name: Perform CodeQL Analysis
if: github.event_name != 'release'
uses: github/codeql-action/analyze@v2
- name: Build remaining executables
run: |
./make.sh build -os linux -arch arm64 -outdir build/linux-arm64
./make.sh build -os darwin -arch amd64 -outdir build/darwin-amd64
./make.sh build -os darwin -arch arm64 -outdir build/darwin-arm64
./make.sh build -os windows -arch amd64 -outdir build/windows-amd64
./make.sh build -os windows -arch arm64 -outdir build/windows-arm64
working-directory: ./tools/eventlist
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-linux-amd64
path: ./tools/eventlist/build/linux-amd64
retention-days: 1
if-no-files-found: error
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-linux-arm64
path: ./tools/eventlist/build/linux-arm64
retention-days: 1
if-no-files-found: error
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-darwin-amd64
path: ./tools/eventlist/build/darwin-amd64
retention-days: 1
if-no-files-found: error
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-darwin-arm64
path: ./tools/eventlist/build/darwin-arm64
retention-days: 1
if-no-files-found: error
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-windows-amd64
path: ./tools/eventlist/build/windows-amd64
retention-days: 1
if-no-files-found: error
- name: Archive eventlist
uses: actions/upload-artifact@v3
with:
name: eventlist-windows-arm64
path: ./tools/eventlist/build/windows-arm64
retention-days: 1
if-no-files-found: error
lint:
if: github.event_name == 'pull_request'
name: Lint
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: tools/eventlist/go.mod
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
working-directory: ./tools/eventlist
format:
if: github.event_name != 'pull_request'
name: Format
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: tools/eventlist/go.mod
check-latest: true
- name: Create build folder
run: mkdir build
working-directory: ./tools/eventlist
- name: Check formatting
run: |
gofmt -d . | tee build/format-check.out
test ! -s build/format-check.out
working-directory: ./tools/eventlist
vulnerability-check:
name: "Vulnerability check"
runs-on: ubuntu-latest
steps:
- name: Scan for Vulnerabilities
uses: golang/govulncheck-action@v1
with:
go-version-file: ./tools/eventlist/go.mod
check-latest: true
go-package: ./...
work-dir: ./tools/eventlist
test:
if: |
github.event_name != 'release' ||
startsWith(github.ref, 'refs/tags/tools/eventlist/')
needs: [ build ]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: 'Test (${{ matrix.os }})'
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: tools/eventlist/go.mod
check-latest: true
- name: Create build folder
run: mkdir build
working-directory: ./tools/eventlist
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Run unit test
run: |
go test -v 2>&1 ./... | go-junit-report -set-exit-code > build/evenlistunittest-${{ matrix.os }}.xml
working-directory: ./tools/eventlist
- name: Archive unit test results
uses: actions/upload-artifact@v3
with:
name: unit-test-result-${{ matrix.os }}
path: ./tools/eventlist/build/evenlistunittest-*.xml
if-no-files-found: error
publish-test-results:
if: github.event_name != 'release'
name: "Publish Tests Results"
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Download unit test report windows
uses: actions/download-artifact@v3
with:
name: unit-test-result-windows-latest
path: testreports/
- name: Download unit test report linux
uses: actions/download-artifact@v3
with:
name: unit-test-result-ubuntu-latest
path: testreports/
- name: Download unit test report macos
uses: actions/download-artifact@v3
with:
name: unit-test-result-macos-latest
path: testreports/
- name: publish test results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
report_individual_runs: true
junit_files: "testreports/*.xml"
coverage:
if: |
github.event_name != 'release' ||
startsWith(github.ref, 'refs/tags/tools/eventlist/')
needs: [ build ]
name: 'Coverage check'
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version-file: tools/eventlist/go.mod
check-latest: true
- name: Create build folder
run: mkdir build
working-directory: ./tools/eventlist
- name: Check coverage
run: |
go test ./... -race -coverprofile=build/cover.out -covermode=atomic
test `go tool cover -func build/cover.out | tail -1 | awk '{print ($3 + 0)*10}'` -gt 950
working-directory: ./tools/eventlist
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./tools/eventlist/build/cover.out
fail_ci_if_error: true
verbose: true
release:
needs: [ build, test, coverage ]
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/eventlist/')
runs-on: ubuntu-latest
steps:
- name: Checkout devtools
uses: actions/checkout@v3
- name: Create distribution folders
run: |
mkdir -p release/eventlist-linux-amd64/docs
mkdir -p release/eventlist-linux-arm64/docs
mkdir -p release/eventlist-darwin-amd64/docs
mkdir -p release/eventlist-darwin-arm64/docs
mkdir -p release/eventlist-windows-amd64/docs
mkdir -p release/eventlist-windows-arm64/docs
cp LICENSE release/eventlist-linux-amd64/
cp LICENSE release/eventlist-linux-arm64/
cp LICENSE release/eventlist-darwin-amd64/
cp LICENSE release/eventlist-darwin-arm64/
cp LICENSE release/eventlist-windows-amd64/
cp LICENSE release/eventlist-windows-arm64/
cp tools/eventlist/docs/* release/eventlist-linux-amd64/docs/
cp tools/eventlist/docs/* release/eventlist-linux-arm64/docs/
cp tools/eventlist/docs/* release/eventlist-darwin-amd64/docs/
cp tools/eventlist/docs/* release/eventlist-darwin-arm64/docs/
cp tools/eventlist/docs/* release/eventlist-windows-amd64/docs/
cp tools/eventlist/docs/* release/eventlist-windows-arm64/docs/
cp tools/eventlist/third_party_licenses.md release/eventlist-linux-amd64/
cp tools/eventlist/third_party_licenses.md release/eventlist-linux-arm64/
cp tools/eventlist/third_party_licenses.md release/eventlist-darwin-amd64/
cp tools/eventlist/third_party_licenses.md release/eventlist-darwin-arm64/
cp tools/eventlist/third_party_licenses.md release/eventlist-windows-amd64/
cp tools/eventlist/third_party_licenses.md release/eventlist-windows-arm64/
- name: Download eventlist linux
uses: actions/download-artifact@v3
with:
name: eventlist-linux-amd64
path: release/eventlist-linux-amd64/
- name: Download eventlist linux
uses: actions/download-artifact@v3
with:
name: eventlist-linux-arm64
path: release/eventlist-linux-arm64/
- name: Download eventlist macos
uses: actions/download-artifact@v3
with:
name: eventlist-darwin-amd64
path: release/eventlist-darwin-amd64/
- name: Download eventlist macos
uses: actions/download-artifact@v3
with:
name: eventlist-darwin-arm64
path: release/eventlist-darwin-arm64/
- name: Download eventlist windows
uses: actions/download-artifact@v2
with:
name: eventlist-windows-amd64
path: release/eventlist-windows-amd64/
- name: Download eventlist windows
uses: actions/download-artifact@v2
with:
name: eventlist-windows-arm64
path: release/eventlist-windows-arm64/
- name: Zip folders
run: |
# Ensure executable eventlist due to this limitation
# https://github.com/actions/upload-artifact#permission-loss
chmod +x */eventlist*
zip -r eventlist-windows-amd64.zip eventlist-windows-amd64/eventlist.exe eventlist-windows-amd64/docs eventlist-windows-amd64/LICENSE eventlist-windows-amd64/third_party_licenses.md
zip -r eventlist-windows-arm64.zip eventlist-windows-arm64/eventlist.exe eventlist-windows-arm64/docs eventlist-windows-arm64/LICENSE eventlist-windows-arm64/third_party_licenses.md
tar -czvf eventlist-linux-amd64.tar.gz eventlist-linux-amd64/eventlist eventlist-linux-amd64/docs eventlist-linux-amd64/LICENSE eventlist-linux-amd64/third_party_licenses.md
tar -czvf eventlist-linux-arm64.tar.gz eventlist-linux-arm64/eventlist eventlist-linux-arm64/docs eventlist-linux-arm64/LICENSE eventlist-linux-arm64/third_party_licenses.md
tar -czvf eventlist-darwin-amd64.tar.gz eventlist-darwin-amd64/eventlist eventlist-darwin-amd64/docs eventlist-darwin-amd64/LICENSE eventlist-darwin-amd64/third_party_licenses.md
tar -czvf eventlist-darwin-arm64.tar.gz eventlist-darwin-arm64/eventlist eventlist-darwin-arm64/docs eventlist-darwin-arm64/LICENSE eventlist-darwin-arm64/third_party_licenses.md
working-directory: release
- name: Calculate checksums
run: |
sha256sum eventlist-windows-amd64.zip --text > eventlist-checksums.txt
sha256sum eventlist-windows-arm64.zip --text >> eventlist-checksums.txt
sha256sum eventlist-linux-amd64.tar.gz --text >> eventlist-checksums.txt
sha256sum eventlist-linux-arm64.tar.gz --text >> eventlist-checksums.txt
sha256sum eventlist-darwin-amd64.tar.gz --text >> eventlist-checksums.txt
sha256sum eventlist-darwin-arm64.tar.gz --text >> eventlist-checksums.txt
working-directory: release
- name: Attach installer to release assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/eventlist-*
tag: ${{ github.ref }}
overwrite: true
file_glob: true