-
-
Notifications
You must be signed in to change notification settings - Fork 0
572 lines (482 loc) · 18.9 KB
/
ci.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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
name: CI
on:
push:
concurrency:
group: ${{ format('{0}-{1}-{2}', github.workflow, github.ref, github.ref == 'refs/heads/main' && github.sha || 'HEAD') }}
cancel-in-progress: true
env:
# -Xallow-any-scripts-in-source-roots: https://youtrack.jetbrains.com/issue/KT-62575
# -Werror: be strict
# -progressive: use latest features
# TODEL https://youtrack.jetbrains.com/issue/KT-68681
# -language-version=1.9: workaround to keep working on GHA without installation of specific Kotlin version.
# TODO turn progressive back on, it was disabled due to to the below workaround.
# warning: '-progressive' is meaningful only for the latest language version (2.0), while this build uses 1.9
# Compiler behavior in such mode is undefined; please, consider moving to the latest stable version or turning off progressive mode.
KOTLINC: kotlinc -Xallow-any-scripts-in-source-roots -Werror -language-version=1.9
jobs:
validate:
name: "🦺 Validation"
uses: TWiStErRob/github-workflows/.github/workflows/validate.yml@1e06403c5d561d70e40109c2701ea3092ca6ded7 # v3
permissions:
contents: read
security-events: write
actions: read
git-merged-branches:
name: "🔨 Build / GIT / Merged Branches"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/git/merged-branches
shell: bash
run: $KOTLINC find-merged-branches.main.kts
github-draft-issues:
name: "🔨 Build / GitHub / Draft Issues"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/github/project-manage-draft-issues
shell: bash
run: $KOTLINC manage-draft-issues.main.kts
github-repository-convention:
name: "🔨 Build / GitHub / Repository Convention"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/github/repository-convention
shell: bash
run: $KOTLINC validate.main.kts
github-user-contribs:
name: "🔨 Build / GitHub / User Contributions"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/github/user-contribs
shell: bash
run: >
$KOTLINC
get.main.kts
summarize.main.kts
google-play-reviews:
name: "🔨 Build / Google / GMail / Google Play Store reviews"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/google/gmail-play-reviews
shell: bash
run: $KOTLINC reviews.main.kts
notion-import-data:
name: "🔨 Build / Notion / Import Data"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/notion/import-data
shell: bash
run: >
$KOTLINC
notion-import-csv.main.kts
notion-import-dev-summit.main.kts
notion-import-droidcon.main.kts
siliconmilkroundabout/companies-attending.main.kts
notion-filter-content:
name: "🔨 Build / Notion / Filter Content"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/notion/database-filter-page-content
shell: bash
run: $KOTLINC filter-content.main.kts
notion-move-to-property:
name: "🔨 Build / Notion / Move to Property"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/notion/page-section-move-to-property
shell: bash
run: $KOTLINC notion-move-to-property.main.kts
lastpass2google:
name: "🔨 Build / Special / LastPass 2 Google migration"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Compile .main.kts."
working-directory: scripts/special/lastpass2google-migration
shell: bash
run: $KOTLINC pass.main.kts
pst-maildir:
name: "🔨 Build & Check / PST to Maildir migration"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Prepare test data."
working-directory: scripts/special/pst-maildir-imap
run: unzip test.zip -d test/
- name: "Build pst2maildir image."
working-directory: scripts/special/pst-maildir-imap
run: docker build --tag pst2maildir .
- name: "Find user."
id: id
run: |
echo "uid=$(id --user)" >> "${GITHUB_OUTPUT}"
echo "gid=$(id --group)" >> "${GITHUB_OUTPUT}"
- name: "Run test migration in container."
uses: addnab/docker-run-action@v3
with:
image: pst2maildir
options: |
--rm
--volume ${{ github.workspace }}/scripts/special/pst-maildir-imap:/workdir
run: |
set -e
cd /workdir
readpst -o test/ test/test.pst
mkdir -p test/Inbox/
perl ./mbox2maildir.pl test/Inbox.mbox test/Inbox/ ${{ steps.id.outputs.uid }} ${{ steps.id.outputs.gid }}
find test/Inbox/ -type f -exec python3 fix_maildir_mail_mtime.py "{}" \;
find test/ -type f -exec chmod +r "{}" \;
- name: "Validate migrated maildir output."
working-directory: scripts/special/pst-maildir-imap/test
run: |
head Inbox.mbox
ls -la Inbox/cur/*.mbox*
find Inbox/cur/ -type f -exec head "{}" \;
- name: "Prepare 'pst2maildir test' artifact."
if: ${{ success() || failure() }}
working-directory: scripts/special/pst-maildir-imap/test
run: |
# Compress Inbox/ because it contains strange characters in the filenames.
# > Error: Artifact path is not valid: /Inbox/cur/1677516690.12.mbox:2,S. Contains the following character: Colon :
# > Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n
# > The following characters are not allowed in files that are uploaded due to limitations with certain file systems such as NTFS.
# > To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.
tar -f pst2maildir-inbox.tar -c Inbox/ --remove-files
- name: "Upload 'pst2maildir test' artifact."
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: 'pst2maildir test'
if-no-files-found: error
path: scripts/special/pst-maildir-imap/test/
svn2git-migration:
name: "🔨 Build & Check / SVN to GIT migration"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Create test repository."
working-directory: scripts/special/svn2git-migration
run: |
mkdir workdir
cd workdir
svnadmin create test-repository
echo "SVN_REPO=$(pwd)/test-repository" >> "${GITHUB_ENV}"
svn co file://$(pwd)/test-repository test-checkout
cd test-checkout
echo "test" > test.txt
svn add test.txt
echo -e "Test Project\n[IMP] Initial import" > commit.message
svn commit --file commit.message test.txt
svn update
svn info
svn log
- name: "Set up migration configuration."
working-directory: scripts/special/svn2git-migration
run: |
echo "$(whoami) = Test User <[email protected]>" > conf/migrate.authors
cat conf/migrate.authors
- name: "Build svn2git image."
working-directory: scripts/special/svn2git-migration
run: |
# TODO use clone with tag and remove checkout when there's a release.
#git clone https://github.com/svn-all-fast-export/svn2git.git -b 1.0.19
git clone https://github.com/svn-all-fast-export/svn2git.git
cd svn2git
git checkout 068dd31d601d81bca5bb4bc44357cda549db3150
docker build --tag svn2git .
- name: "Run test migration in container."
uses: addnab/docker-run-action@v3
with:
image: svn2git
options: |
--rm
--volume ${{ github.workspace }}/scripts/special/svn2git-migration/conf:/tmp/conf
--volume ${{ github.workspace }}/scripts/special/svn2git-migration/workdir:/workdir
--volume ${{ env.SVN_REPO }}:/tmp/svn
run: |
set -e
svn relocate file:///tmp/svn test-checkout
/usr/local/svn2git/svn-all-fast-export \
--identity-map /tmp/conf/migrate.authors \
--rules /tmp/conf/monorepo-all.rules \
--debug-rules \
--stats \
--svn-ignore \
--propcheck \
--empty-dirs \
--add-metadata \
--add-metadata-notes \
--msg-filter 'sed --zero-terminated --regexp-extended --file=/tmp/conf/svn-msg-filter.sed' \
/tmp/svn \
>svn2git.log 2>&1
- name: "Validate migrated git output."
working-directory: scripts/special/svn2git-migration/workdir
run: |
git clone svn.git
cd svn
git log --no-decorate | grep -v -E 'Date:|commit' > actual-git-log.txt
cat > expected-git-log.txt <<- EOF
Author: Test User <[email protected]>
[SVN] r1 Test Project in /
[IMP] Initial import
EOF
diff expected-git-log.txt actual-git-log.txt
- name: "Upload 'svn2git test' artifact."
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: 'svn2git test'
if-no-files-found: error
path: scripts/special/svn2git-migration/workdir/
gradle-init:
name: "🔨 Build / Gradle init scripts"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Setup Gradle."
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: ${{ matrix.gradle }}
cache-disabled: true
add-job-summary: on-failure
- name: "Run Gradle build."
env:
GRADLE_USER_HOME: ${{ github.workspace }}/config/gradle
working-directory: config/gradle/init.d/test
shell: bash
# Explicitly not using the wrapper, want to test different versions.
run: gradle
strategy:
fail-fast: false
matrix:
gradle:
- '5.6.4'
- '6.0.1'
- '6.1.1'
- '6.2.2'
- '7.6.4'
- '8.0.2'
- '8.7'
- '8.8'
detekt:
name: "🔍 Static Checks / Detekt"
timeout-minutes: 5
permissions:
# actions/checkout, gh release download
contents: read
# github/codeql-action/upload-sarif
security-events: write
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Run detekt."
env:
# Use https://github.com/detekt/detekt
DETEKT_VERSION: '1.23.7'
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
gh release download "v${DETEKT_VERSION?}" --repo detekt/detekt --pattern "detekt-cli-*.zip" --output detekt-cli.zip
unzip "detekt-cli.zip"
detekt="./detekt-cli-${DETEKT_VERSION?}/bin/detekt-cli"
"${detekt}" --version
"${detekt}" \
--all-rules \
--max-issues 0 \
--base-path "${GITHUB_WORKSPACE}" \
--report sarif:detekt.sarif \
--report txt:detekt.txt \
--report html:detekt.html \
--report xml:detekt.xml \
--report md:detekt.md \
- name: "Upload 'Detekt Results' artifact."
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: 'Detekt Results'
if-no-files-found: error
path: detekt.*
- name: "Publish 'Code scanning results / detekt'."
uses: github/codeql-action/upload-sarif@v3
if: ${{ success() || failure() }}
with:
sarif_file: ${{ github.workspace }}/detekt.sarif
shellcheck:
name: "🔍 Static Checks / ShellCheck"
timeout-minutes: 5
permissions:
# actions/checkout, gh release download
contents: read
# github/codeql-action/upload-sarif
security-events: write
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Run shellcheck."
env:
# Use https://github.com/koalaman/shellcheck
SHELLCHECK_VERSION: '0.10.0'
GH_TOKEN: ${{ github.token }}
run: |
gh release download "v${SHELLCHECK_VERSION?}" --repo koalaman/shellcheck --pattern "shellcheck-v*.linux.x86_64.tar.xz"
tar --extract --xz --verbose --file shellcheck-v*.linux.x86_64.tar.xz
shellcheck="./shellcheck-v${SHELLCHECK_VERSION?}/shellcheck"
"${shellcheck}" --version
# `shellcheck **.{sh}`, but without globbing.
find "${GITHUB_WORKSPACE}" -type f \( -name '*.sh' \) \
-exec "${shellcheck}" --enable=all --severity=style --shell=sh --check-sourced --external-sources --format=json {} + \
> shellcheck.json
# The previous command will fail if violations are found, careful putting more commands here.
- name: "Convert shellcheck JSON output to SARIF."
if: ${{ success() || failure() }}
env:
# Use https://github.com/psastras/sarif-rs
SHELLCHECK_SARIF_VERSION: '0.6.6'
GH_TOKEN: ${{ github.token }}
run: |
gh release download "shellcheck-sarif-v${SHELLCHECK_SARIF_VERSION?}" --repo psastras/sarif-rs --pattern "shellcheck-sarif-x86_64-unknown-linux-gnu" --output shellcheck-sarif
chmod +x shellcheck-sarif
# Relativize paths in the shellcheck JSON output, so in turn the SARIF output is relative too.
sed --in-place --expression="s#\"file\":\"${GITHUB_WORKSPACE}/#\"file\":\"#g" shellcheck.json
./shellcheck-sarif < shellcheck.json > shellcheck.sarif
- name: "Pretty-print SARIF output."
if: ${{ success() || failure() }}
env:
# Use https://github.com/psastras/sarif-rs
SARIF_FMT_VERSION: '0.6.6'
GH_TOKEN: ${{ github.token }}
run: |
gh release download "sarif-fmt-v${SARIF_FMT_VERSION?}" --repo psastras/sarif-rs --pattern "sarif-fmt-x86_64-unknown-linux-gnu" --output sarif-fmt
chmod +x sarif-fmt
./sarif-fmt < shellcheck.sarif | tee shellcheck.sarif.txt
- name: "Upload 'ShellCheck Results' artifact."
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: 'ShellCheck Results'
if-no-files-found: error
path: shellcheck.*
- name: "Publish 'Code scanning results / shellcheck'."
if: ${{ success() || failure() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ github.workspace }}/shellcheck.sarif
psscriptanalyzer:
name: "🔍 Static Checks / PSScriptAnalyzer"
timeout-minutes: 5
permissions:
# actions/checkout
contents: read
# github/codeql-action/upload-sarif
security-events: write
runs-on: ubuntu-latest
steps:
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v4
- name: "Run PSScriptAnalyzer."
uses: microsoft/[email protected]
with:
path: ${{ github.workspace }}\
recurse: true
output: PSScriptAnalyzer.sarif
# Not a yaml array, used directly inside a PowerShell array @(...) when invoking analyzer.
excludeRule: '"PSAvoidUsingWriteHost"'
- name: "Upload 'PSScriptAnalyzer Results' artifact."
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: 'PSScriptAnalyzer Results'
if-no-files-found: error
path: PSScriptAnalyzer.*
- name: "Publish 'Code scanning results / PSScriptAnalyzer'."
if: ${{ success() || failure() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ github.workspace }}/PSScriptAnalyzer.sarif