-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
365 lines (343 loc) · 11.2 KB
/
tests.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
name: Tests
on:
push:
branches:
- main
- main-release
pull_request:
merge_group:
workflow_dispatch:
env:
SpringerNatureAPIKey: ${{ secrets.SpringerNatureAPIKey }}
AstrophysicsDataSystemAPIKey: ${{ secrets.AstrophysicsDataSystemAPIKey }}
IEEEAPIKey: ${{ secrets.IEEEAPIKey }}
BiodiversityHeritageApiKey: ${{ secrets.BiodiversityHeritageApiKey}}
GRADLE_OPTS: -Xmx4g
JAVA_OPTS: -Xmx4g
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
permissions:
pull-requests: write
jobs:
checkstyle:
name: Checkstyle
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Run checkstyle reporter
uses: dbelyaev/action-checkstyle@master
with:
reporter: github-pr-review
github_token: ${{ secrets.GITHUB_TOKEN }}
checkstyle_config: 'config/checkstyle/checkstyle_reviewdog.xml'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run checkstyle using gradle
run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh
openrewrite:
name: OpenRewrite
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run OpenRewrite
run: |
./gradlew rewriteDryRun
modernizer:
name: Modernizer
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run modernizer
run: |
# enable failing of this task if modernizer complains
sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle
./gradlew modernizer
markdown:
name: Markdown
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'false'
show-progress: 'false'
- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: |
*.md
docs/**/*.md
changelog:
name: CHANGELOG.md
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'false'
show-progress: 'false'
- name: Lint CHANGELOG.md
run: |
# Install jbang
curl -Ls https://sh.jbang.dev | bash -s - app setup
export PATH=$PATH:$HOME/.jbang/bin
# run heylogs verification
jbang com.github.nbbrd.heylogs:heylogs-cli:0.7.2:bin check CHANGELOG.md > heylogs.txt || true
# improve output
sed -i 's/all-h2-contain-a-version/all-h2-contain-a-version (ignored)/' heylogs.txt
cat heylogs.txt
# exit 1 in case of error
# We have 1 "valid" issue in CHANGELOG.md
grep -q "1 problem" heylogs.txt || exit 1
changelog-unreleased-only:
name: CHANGELOG.md - only unreleased touched
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'false'
show-progress: 'false'
fetch-depth: 0
- name: Install clparse
run: |
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
sudo mv clparse /usr/local/bin/clparse
- name: Check CHANGELOG.md diff
run: |
diff \
<(git show origin/main: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)')
tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run tests
run: xvfb-run --auto-servernum ./gradlew check -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x modernizer
env:
CI: "true"
- name: Prepare format failed test results
if: failure()
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: xml-twig-tools xsltproc
version: 1.0
- name: Format failed test results
if: failure()
run: scripts/after-failure.sh
databasetests:
name: Database tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13-alpine
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: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run tests on PostgreSQL
run: ./gradlew databaseTest --rerun-tasks
env:
CI: "true"
DBMS: "postgresql"
- name: Shutdown Ubuntu MySQL
run: sudo service mysql stop # Shutdown the Default MySQL, "sudo" is necessary, please not remove it
- name: Start custom MySQL
uses: mirromutth/mysql-action@v1.1
with:
host port: 3800
container port: 3307
character set server: 'utf8'
collation server: 'utf8_general_ci'
mysql version: '8.0'
mysql database: 'jabref'
mysql root password: 'root'
- name: Run tests on MySQL
run: ./gradlew databaseTest --rerun-tasks
env:
CI: "true"
DBMS: "mysql"
guitests:
name: GUI tests
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Run GUI tests
run: xvfb-run --auto-servernum ./gradlew guiTest
env:
CI: "true"
codecoverage:
name: Code coverage
runs-on: ubuntu-latest
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
if: github.ref == 'refs/heads/main'
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
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
with:
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
if: github.ref == 'refs/heads/main'
uses: actions/setup-java@v4
with:
java-version: 21.0.2
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true
- name: Update test coverage metrics
if: (github.ref == 'refs/heads/main') && (steps.checksecrets.outputs.secretspresent == 'YES')
run: xvfb-run --auto-servernum ./gradlew jacocoTestReport
env:
CI: "true"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DBMS: "postgresql"
- uses: codecov/codecov-action@v4
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 }}
# 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-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: 'false'
- uses: gradle/actions/wrapper-validation@v4
# This ensures that no git merge conflict markers (<<<, ...) are contained
merge_conflict_job:
name: Find merge conflicts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: 'false'
- name: Merge Conflict finder
uses: olivernybroe/action-conflict-finder@v4.0
other_than_main:
name: Source branch is other than "main"
runs-on: ubuntu-latest
steps:
- if: github.head_ref == 'main'
uses: actions/github-script@v7
with:
script: |
core.setFailed('Pull requests should come from a branch other than "main"\n\n👉 Please read https://devdocs.jabref.org/contributing again carefully. 👈')