Repository navigation
751 lines (716 loc) · 29.1 KB
/
Copy pathtests-code.yml
File metadata and controls
751 lines (716 loc) · 29.1 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
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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
name: Source Code Tests
on:
push:
branches:
- main
- main-release
- stable
pull_request:
merge_group:
workflow_dispatch:
env:
AstrophysicsDataSystemAPIKey: ${{ secrets.AstrophysicsDataSystemAPIKey_FOR_TESTS }}
BiodiversityHeritageApiKey: ${{ secrets.BiodiversityHeritageApiKey_FOR_TESTS}}
IEEEAPIKey: ${{ secrets.IEEEAPIKey_FOR_TESTS }}
MedlineAPiKey: ${{ secrets.MedlineApiKey_FOR_TESTS }}
OpenAlexApiKey: ${{ secrets.OpenAlexApiKey_FOR_TESTS }}
SpringerNatureAPIKey: ${{ secrets.SPRINGERNATUREAPIKEY_FOR_TESTS }}
ScholarApiKey: ${{ secrets.SCHOLARAPIKEY_FOR_TESTS }}
CROSSREF_EMAIL: ${{ secrets.CROSSREF_EMAIL_FOR_TESTS }}
GRADLE_OPTS: -Xmx4g
JAVA_OPTS: -Xmx4g
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
permissions:
# required for publish.yml
actions: write
contents: read
pull-requests: write
jobs:
upload-pr-number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-slim
steps:
- name: Create pr_number.txt
run: echo "${{ github.event.number }}" > pr_number.txt
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: pr_number
path: pr_number.txt
changes:
name: Detect relevant source changes
runs-on: ubuntu-slim
outputs:
run-gradle-ci-requirements: ${{ steps.determine.outputs.run-gradle-ci-requirements }}
run-gradle-ci-full: ${{ steps.determine.outputs.run-gradle-ci-full }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
show-progress: 'false'
- id: changed-non-workflow-non-markdown-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files_ignore: |
.github/workflows/**
**/*.md
- id: changed-requirements-docs
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
docs/requirements/**/*.md
- id: changed-tests-code-workflow
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
.github/workflows/tests-code.yml
- id: changed-submodules
if: github.event_name == 'pull_request'
# `.gitmodules` sets `ignore = all`, which hides submodule pointer bumps from `git diff` and thus from
# tj-actions/changed-files. Without this step, a submodule bump skips all tests at PR level and fails
# only in the merge queue.
shell: bash
run: |
submodules=$(git config --file .gitmodules --get-regexp '\.path$' | awk '{print $2}')
if git diff --quiet --ignore-submodules=none "origin/${{ github.base_ref }}" HEAD -- $submodules; then
echo "any_changed=false" >> "$GITHUB_OUTPUT"
else
echo "any_changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Determine whether Gradle jobs should run
id: determine
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "merge_group" ]]; then
echo "run-gradle-ci-requirements=true" >> "$GITHUB_OUTPUT"
echo "run-gradle-ci-full=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ steps.changed-tests-code-workflow.outputs.any_changed }}" == "true" || "${{ steps.changed-non-workflow-non-markdown-files.outputs.any_changed }}" == "true" || "${{ steps.changed-submodules.outputs.any_changed }}" == "true" ]]; then
echo "run-gradle-ci-requirements=true" >> "$GITHUB_OUTPUT"
echo "run-gradle-ci-full=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ steps.changed-requirements-docs.outputs.any_changed }}" == "true" ]]; then
echo "run-gradle-ci-requirements=true" >> "$GITHUB_OUTPUT"
echo "run-gradle-ci-full=false" >> "$GITHUB_OUTPUT"
else
echo "run-gradle-ci-requirements=false" >> "$GITHUB_OUTPUT"
echo "run-gradle-ci-full=false" >> "$GITHUB_OUTPUT"
fi
dependencyscopes:
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
name: Dependency Scopes
# too slow on ubuntu-slim
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Run checkAllModuleInfo using gradle
run: gradle checkAllModuleInfo
format:
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
# ubuntu-slim doesn't offer docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: ./.github/actions/format-java
# job should fail in case there are changes
- uses: ./.github/actions/check-formatting
with:
artifact-name: formatting-fix-patch
format-javadoc:
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
# too slow on ubuntu-slim
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
path: 'jabref'
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
repository: 'rmuller/Convert2MarkdownJavadoc'
path: 'Convert2MarkdownJavadoc'
- name: Setup JDK
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
java-version: '24'
distribution: 'corretto'
check-latest: true
- run: |
cd Convert2MarkdownJavadoc
java Convert2MarkdownJavadoc.java ../jabref
- uses: ./jabref/.github/actions/check-formatting
with:
working-directory: jabref
artifact-name: javadoc-fix-patch
checkstyle:
name: Checkstyle
# too slow on ubuntu-slim
runs-on: ubuntu-latest
needs: [ changes, format ]
if: needs.changes.outputs.run-gradle-ci-full == 'true'
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Run checkstyle using gradle
run: gradle checkstyleMain checkstyleTest checkstyleJmh
openrewrite:
name: OpenRewrite
# too slow on ubuntu-slim
runs-on: ubuntu-latest
needs: [ changes, checkstyle ]
if: needs.changes.outputs.run-gradle-ci-full == 'true'
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Run OpenRewrite
run: |
gradle --no-configuration-cache :rewriteRun
# Reformat code (because OpenRewrite does different indents)
- uses: ./.github/actions/format-java
- name: Fail if working directory is unclean
uses: ./.github/actions/check-formatting
with:
artifact-name: openrewrite-fix-patch
annotation-title: OpenRewrite
annotation-message-prefix: "Uncommitted changes after OpenRewrite; run `gradle :rewriteRun`, reformat, and commit the result for"
modernizer:
name: Modernizer
# too slow on ubuntu-slim
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Run modernizer
run: |
# enable failing of this task if modernizer complains
# sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle.kts
gradle modernizer
markdown:
name: Markdown
runs-on: ubuntu-slim
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@21c1be1b93ad9ed58fa840aacc3f279cde2a72ff # v24
with:
globs: |
*.md
docs/**/*.md
yaml:
name: YAML
runs-on: ubuntu-slim
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: yamllint
run: pipx run yamllint==1.38.0 --strict .
spelling:
name: Spellling
runs-on: ubuntu-slim
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 24
cache: npm
- name: Install textlint
run: npm ci
- name: textlint
run: npm run textlint
- name: typos
run: pipx run typos==1.50.3
madr:
name: MADR ADRs
# JBang needs a JDK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: Generate JBang cache key
id: cache-key
shell: bash
run: |
echo "cache_key=jbang-madrlint-$(date +%Y-%m)" >> $GITHUB_OUTPUT
- name: Cache JBang
# Combined cache action: restores at start and saves ~/.jbang on a
# cache miss in the post-job step. A madrlint-specific key keeps this
# cache separate from the other JBang-using jobs.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.jbang
key: ${{ steps.cache-key.outputs.cache_key }}
restore-keys:
jbang-madrlint-
- name: Resolve //DEPS into the cached directory
# JBang resolves script dependencies into ~/.m2, which is not cached here.
run: echo "JBANG_REPO=$HOME/.jbang/repository" >> "$GITHUB_ENV"
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
distribution: 'corretto'
java-version: '25'
- name: Setup JBang
# Pinned to a commit for deterministic CI; comment tracks the tag.
uses: jbangdev/setup-jbang@2b1b465a7b75f4222b81426f23a01e013aa7b95c # v0.1.1
- name: Trust madrlint source
run: jbang trust add https://github.com/adr/
- name: Lint ADRs
# madrlint is pinned to a commit (not the moving `madrlint@adr/madrlint` alias) so
# upstream changes cannot alter lint results without a deliberate bump here.
# To update: point MADRLINT at a newer https://github.com/adr/madrlint commit.
env:
MADRLINT: https://github.com/adr/madrlint/blob/e37d19b6699e45dd1543bccd858f4f49af350e49/madrlint.java
run: |
report="$(mktemp)"
# Each ADR file is checked against the per-file rules; the docs/decisions directory itself
# is checked against the directory rules (numbering, naming, collisions). Non-ADR files
# (adr-template.md, index.md) are excluded via .madrlintignore.
# -n11 disables the external-link check (MADR11); JabRef verifies external links elsewhere.
for target in docs/decisions/*.md docs/decisions; do
jbang "$MADRLINT" -n11 --quiet --output-format github-actions "$target"
done | tee "$report"
error_count=$(grep -c '^::error' "$report" || true)
if [ "$error_count" -ne 0 ]; then
echo "❌ madrlint reported $error_count MADR violation(s). See the annotations above."
exit 1
fi
echo "✅ No MADR violations."
changelog:
name: CHANGELOG.md
# JBang needs a JDK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: Generate JBang cache key
id: cache-key
shell: bash
run: |
echo "cache_key=jbang-heylogs-$(date +%Y-%m)" >> $GITHUB_OUTPUT
- name: Cache JBang
# Combined cache action: the restore-only variant never wrote the key.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.jbang
key: ${{ steps.cache-key.outputs.cache_key }}
restore-keys:
jbang-heylogs-
- name: Resolve //DEPS into the cached directory
# JBang resolves script dependencies into ~/.m2, which is not cached here.
run: echo "JBANG_REPO=$HOME/.jbang/repository" >> "$GITHUB_ENV"
- name: Setup JBang
uses: jbangdev/setup-jbang@2b1b465a7b75f4222b81426f23a01e013aa7b95c # v0.1.1
- name: Lint CHANGELOG.md
run: |
# the grep is needed to filter out an error about all h2 containing a version, which is not relevant for us, because we have an "Unreleased" section
jbang com.github.nbbrd.heylogs:heylogs-cli:0.19.1:bin check --rule dot-space-link-style:ERROR --format github-actions CHANGELOG.md | grep -v all-h2-contain-a-version | tee heylogs.txt || true
error_count=$(grep -c '^::error' heylogs.txt || true)
if [ "$error_count" -ne 0 ]; then
{
echo "heylogs<<EOF"
cat heylogs.txt
echo "EOF"
} >> "$GITHUB_OUTPUT"
exit 1
fi
changelog-unreleased-only:
if: github.event_name == 'pull_request'
name: CHANGELOG.md - only unreleased touched
runs-on: ubuntu-slim
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
fetch-depth: 0
- name: Cache clparse jar
id: cache-clparse
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: /tmp/clparse
key: clparse-0.9.1
- name: unzip
if: steps.cache-clparse.outputs.cache-hit != 'true'
run: |
cd /tmp
curl -LO https://github.com/marcaddeo/clparse/releases/download/0.9.1/clparse-0.9.1-x86_64-unknown-linux-musl.tar.gz
tar xzvf clparse-0.9.1-x86_64-unknown-linux-musl.tar.gz
- name: Install clparse
run: sudo mv /tmp/clparse /usr/local/bin/clparse
- uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
with:
packages: jq
version: 1.0
- name: Check CHANGELOG.md diff
run: |
diff \
<(git show "origin/${{ github.base_ref }}":CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') \
<(git show HEAD:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)')
javadoc:
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
name: JavaDoc
# Sometimes takes longer than 15 minutes, therefore not ubuntu-slim
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- run: gradle javadoc
tests:
needs: changes
name: "Unit tests – ${{ matrix.module }}"
runs-on: ubuntu-latest
strategy:
matrix:
module: [ jablib, jabkit, jabsrv, jabgui ]
steps:
- name: Skip tests because no source-relevant files changed
if: needs.changes.outputs.run-gradle-ci-full != 'true'
run: echo "Skipping tests because no source-relevant files changed."
- name: Checkout source
if: needs.changes.outputs.run-gradle-ci-full == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
if: needs.changes.outputs.run-gradle-ci-full == 'true'
- name: Run ${{ matrix.module }} tests
if: needs.changes.outputs.run-gradle-ci-full == 'true'
run: xvfb-run --auto-servernum gradle :${{ matrix.module }}:check -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x modernizer
env:
CI: "true"
- name: Run JabKit portable smoke test
if: (needs.changes.outputs.run-gradle-ci-full == 'true') && (matrix.module == 'jabkit')
run: gradle :jabkit:runJabKitPortableSmokeTest
- name: Prepare format failed test results
if: needs.changes.outputs.run-gradle-ci-full == 'true' && failure()
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
with:
packages: xml-twig-tools xsltproc
version: 1.0
- name: Format failed test results
if: needs.changes.outputs.run-gradle-ci-full == 'true' && failure()
run: scripts/after-failure.sh
tests-windows:
needs: changes
name: "Unit tests (Windows)"
if: >
github.repository_owner == 'JabRef' &&
(
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group'
)
runs-on: windows-latest
strategy:
matrix:
module: [ jablib ]
steps:
- name: Skip Windows tests because no source-relevant files changed
if: needs.changes.outputs.run-gradle-ci-full != 'true'
run: echo "Skipping Windows tests because no source-relevant files changed."
- name: Checkout source
if: needs.changes.outputs.run-gradle-ci-full == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
if: needs.changes.outputs.run-gradle-ci-full == 'true'
- name: Run ${{ matrix.module }} tests
if: needs.changes.outputs.run-gradle-ci-full == 'true'
run: gradle :${{ matrix.module }}:check -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x modernizer
env:
CI: "true"
tests-windows-file-based:
needs: changes
if: needs.changes.outputs.run-gradle-ci-full == 'true'
name: "Unit tests (Windows) - file-based"
runs-on: windows-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
submodules: 'true'
show-progress: 'false'
- name: Detect changed windows-related classes
id: changed-windows-related-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
jablib/src/main/java/org/jabref/logic/citationstyle/CSLStyleUtils.java
jablib/src/test/java/org/jabref/logic/citationstyle/CSLStyleUtilsTest.java
jablib/src/main/java/org/jabref/logic/exporter/AcademicPagesExporter.java
jablib/src/test/java/org/jabref/logic/exporter/AcademicPagesExporterTest.java
- uses: ./.github/actions/setup-gradle
if: steps.changed-windows-related-files.outputs.any_changed == 'true'
- name: Run jablib tests
if: steps.changed-windows-related-files.outputs.any_changed == 'true'
run: gradle :jablib:check -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x modernizer
env:
CI: "true"
databasetests:
needs: changes
if: github.repository_owner == 'JabRef' && needs.changes.outputs.run-gradle-ci-full == 'true'
name: Database tests
runs-on: ubuntu-latest
steps:
- name: Shutdown Ubuntu MySQL
run: sudo service mysql stop # Shutdown the Default MySQL to save memory, "sudo" is necessary, please do not remove it
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Run tests on PostgreSQL
run: gradle :jablib:databaseTest --rerun-tasks
env:
CI: "true"
publish:
needs: changes
if: github.ref == 'refs/heads/main' && needs.changes.outputs.run-gradle-ci-full == 'true'
uses: ./.github/workflows/publish.yml
secrets:
KOPPOR_SIGNING_SECRETKEYRINGFILE_BASE64: ${{ secrets.KOPPOR_SIGNING_SECRETKEYRINGFILE_BASE64 }}
KOPPOR_SIGNING_KEYID: ${{ secrets.KOPPOR_SIGNING_KEYID }}
KOPPOR_SIGNING_PASSWORD: ${{ secrets.KOPPOR_SIGNING_PASSWORD }}
KOPPOR_MAVENCENTRALUSERNAME: ${{ secrets.KOPPOR_MAVENCENTRALUSERNAME }}
KOPPOR_MAVENCENTRALPASSWORD: ${{ secrets.KOPPOR_MAVENCENTRALPASSWORD }}
jbang-main:
name: JBang (main)
runs-on: ubuntu-slim
needs: publish
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: Generate JBang cache key
id: cache-key
shell: bash
run: echo "cache_key=jbang-check-$(date +%Y-%m)" >> $GITHUB_OUTPUT
- name: Cache JBang
# Shared by the "JBang (main)" and "JBang (PR)" jobs - both build the same scripts,
# so they resolve the same dependencies. A PR run restores the entry written on main.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.jbang
key: ${{ steps.cache-key.outputs.cache_key }}
restore-keys:
jbang-check-
- name: Setup JBang
uses: jbangdev/setup-jbang@2b1b465a7b75f4222b81426f23a01e013aa7b95c # v0.1.1
- uses: ./.github/actions/setup-gradle
- name: Build JBang scripts and run launchers
uses: ./.github/actions/jbang-check
jbang-pr:
needs: changes
name: JBang (PR)
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main' && needs.changes.outputs.run-gradle-ci-full == 'true'
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- name: Generate JBang cache key
id: cache-key
shell: bash
run: echo "cache_key=jbang-check-$(date +%Y-%m)" >> $GITHUB_OUTPUT
- name: Cache JBang
# Shared by the "JBang (main)" and "JBang (PR)" jobs - both build the same scripts,
# so they resolve the same dependencies. A PR run restores the entry written on main.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.jbang
key: ${{ steps.cache-key.outputs.cache_key }}
restore-keys:
jbang-check-
- name: Setup JBang
uses: jbangdev/setup-jbang@2b1b465a7b75f4222b81426f23a01e013aa7b95c # v0.1.1
- uses: ./.github/actions/setup-gradle
# Publish jablib to the local Maven repository so the JBang scripts pick up
# unreleased changes. -PprojVersion=6.0 makes the artifact 6.0-SNAPSHOT
# (the default would be 0.1.0-SNAPSHOT, which the scripts do not reference).
- name: Publish jablib to the local Maven repository
# -Dmaven.repo.local: the jbang-check action points JBANG_REPO at ~/.jbang/repository,
# so the snapshot has to be published there instead of into ~/.m2.
run: gradle -Dmaven.repo.local="$HOME/.jbang/repository" -PprojVersion=6.0 :jablib:publishToMavenLocal
- name: Build JBang scripts and run launchers
uses: ./.github/actions/jbang-check
maven-examples:
name: Maven examples
runs-on: ubuntu-latest
needs: publish
if: github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
project: [ jablib-examples/maven3/doi-to-bibtex ]
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'false'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6
with:
java-version: 25
distribution: 'corretto'
cache: maven
check-latest: true
- run: |
cd ${{ matrix.project }}
mvn --batch-mode --update-snapshots verify
shell: bash
codecoverage:
if: false
name: Code coverage
runs-on: ubuntu-slim
services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Check secrets presence
id: checksecrets
shell: bash
run: |
if [ "$CODECOV_TOKEN" == "" ]; then
echo "secretspresent=NO" >> $GITHUB_OUTPUT
echo "❌ Secret CODECOV_TOKEN not present"
else
echo "secretspresent=YES" >> $GITHUB_OUTPUT
echo "✔️ Secret CODECOV_TOKEN present"
fi
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: 'true'
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- name: Update test coverage metrics
if: (github.ref == 'refs/heads/main') && (steps.checksecrets.outputs.secretspresent == 'YES')
run: xvfb-run --auto-servernum gradle jacocoTestReport
env:
CI: "true"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DBMS: "postgresql"
- uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7
if: (github.ref == 'refs/heads/main') && (steps.checksecrets.outputs.secretspresent == 'YES')
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload Codacy report
if: (github.ref == 'refs/heads/main') && (steps.checksecrets.outputs.secretspresent == 'YES')
run: bash <(curl -Ls https://coverage.codacy.com/get.sh)
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
requirements_coverage:
needs: changes
if: needs.changes.outputs.run-gradle-ci-requirements == 'true'
name: "Validate requirement coverage"
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
show-progress: 'false'
- uses: ./.github/actions/setup-gradle
- run: gradle traceRequirements
- if: always()
run: cat build/reports/tracing.txt
# This is https://github.com/marketplace/actions/gradle-wrapper-validation
# It ensures that the jar file is from gradle and not by a strange third party.
gradlevalidation:
name: "Validate Gradle Wrapper"
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
show-progress: 'false'
- uses: gradle/actions/wrapper-validation@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
# Guards against a committer (e.g. a dependabot wrapper bump) baking CRLF into
# the committed gradlew.bat blob. .gitattributes stores it as LF and smudges it
# to CRLF on checkout, so we inspect the committed blob, not the working-tree file.
line_endings:
name: "Line endings (gradlew.bat)"
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
show-progress: 'false'
- name: Ensure gradlew.bat blob has no CRLF
run: |
if ! git cat-file -e HEAD:gradlew.bat 2>/dev/null; then
echo "❌ gradlew.bat not found at HEAD. Cannot validate line endings; failing closed."
exit 1
fi
if git show HEAD:gradlew.bat | grep -q $'\r'; then
echo "❌ gradlew.bat is committed with CRLF. The repository blob must be LF;"
echo " .gitattributes (\"*.bat text eol=crlf\") converts it to CRLF on checkout."
echo " Fix: git add --renormalize gradlew.bat && git commit"
exit 1
fi
echo "✅ gradlew.bat blob is LF"