-
Notifications
You must be signed in to change notification settings - Fork 1
350 lines (312 loc) · 12.8 KB
/
Copy pathmaven.yml
File metadata and controls
350 lines (312 loc) · 12.8 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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
name: Java CI with Maven
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
schedule:
- cron: "0 14 * * 0"
workflow_dispatch:
permissions: {}
concurrency:
group: maven-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# The mandatory gate. Everything else waits on it, so a broken build costs one job
# rather than four.
build:
name: Build
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Spotless Check
run: mvn spotless:check
- name: Build
run: mvn clean package -DskipTests
static-analysis:
name: Static Code Analysis
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
# SpotBugs reads class files, so the sources have to be compiled first.
- name: Compile
run: mvn -DskipTests compile
# Each check runs even when an earlier one failed, so that one run reports every tool
# rather than only the first to complain. The job still fails if any step failed.
- name: Spotless
if: ${{ !cancelled() }}
run: mvn spotless:check
- name: Checkstyle
if: ${{ !cancelled() }}
run: mvn checkstyle:check
- name: PMD
if: ${{ !cancelled() }}
run: mvn pmd:check
- name: SpotBugs
if: ${{ !cancelled() }}
run: mvn spotbugs:check
- name: Upload analysis reports
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: static-analysis-reports
path: |
target/checkstyle-result.xml
target/pmd.xml
target/spotbugsXml.xml
if-no-files-found: warn
unit-tests:
name: Unit Tests
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 45
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Unit tests
run: mvn test -Punit-core-tests,coverage -f pom.xml
# Architecture unit tests exercise the same execution-scoped WALA lifecycle
# used by the integration matrices.
- name: Architecture unit tests
run: mvn test -Punit-architecture-tests,coverage -f pom.xml
# Both steps append into the same execution-data file. Uploaded even when a test
# step failed, so the aggregate still reflects everything that did run.
- name: Upload coverage execution data
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: jacoco-exec-unit-tests
path: target/jacoco.exec
if-no-files-found: warn
tests:
name: Integration Tests (${{ matrix.name }})
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
# `slug` names the coverage artefact: `name` contains spaces and a plus sign,
# which make for awkward artefact names and awkward download patterns.
- name: ArchUnit + AspectJ
slug: archunit-aspectj
method-suffixes: '*MavenArchunitAspectJ+*_archunit_aspectj'
architecture-method-suffixes: '*MavenArchunitAspectJ_test'
reuse-forks: 'true'
- name: ArchUnit + instrumentation
slug: archunit-instrumentation
method-suffixes: '*MavenArchunitInstrumentation+*_archunit_instrumentation'
architecture-method-suffixes: '*MavenArchunitInstrumentation_test'
reuse-forks: 'true'
- name: WALA + AspectJ
slug: wala-aspectj
method-suffixes: '*MavenWalaAspectJ+*_wala_aspectj'
architecture-method-suffixes: '*MavenWalaAspectJ_test'
reuse-forks: 'true'
- name: WALA + instrumentation
slug: wala-instrumentation
method-suffixes: '*MavenWalaInstrumentation+*_wala_instrumentation'
architecture-method-suffixes: '*MavenWalaInstrumentation_test'
reuse-forks: 'true'
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
# Method-level selection starts only the classes belonging to this mode. All
# mode combinations reuse one fork; WALA state remains policy-scoped.
# The `coverage` profile also lowers `surefire-reuse-forks`, but the command-line
# property below outranks a profile property, so fork reuse stays as the matrix
# declares it and coverage does not change how these tests are isolated.
- name: Test mode combination
run: >-
mvn test -f pom.xml -Pcoverage
-Dtest='de.tum.cit.ase.ares.integration.aop.allowed.*Test#${{ matrix.method-suffixes }},de.tum.cit.ase.ares.integration.aop.allowed.FileSystemAccessTest$*#${{ matrix.method-suffixes }},de.tum.cit.ase.ares.integration.aop.forbidden.*Test#${{ matrix.method-suffixes }},de.tum.cit.ase.ares.integration.architecture.forbidden.*Test#${{ matrix.architecture-method-suffixes }}'
-Dsurefire-reuse-forks=${{ matrix.reuse-forks }}
- name: Upload coverage execution data
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: jacoco-exec-${{ matrix.slug }}
path: target/jacoco.exec
if-no-files-found: warn
core-integration-tests:
name: Core Integration Tests
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 45
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Core integration tests
run: mvn test -Pintegration-core-tests,coverage -f pom.xml
- name: jqwik integration tests
run: mvn test -f pom.xml -Pcoverage -Dtest=de.tum.cit.ase.ares.integration.JqwickTest
- name: Upload coverage execution data
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: jacoco-exec-core-integration-tests
path: target/jacoco.exec
if-no-files-found: warn
# Each test job covers a disjoint slice of the suite, so no single one of them can be
# judged against the BUNDLE-level rule in pom.xml; only their merged execution data can.
#
# Advisory on purpose: the rule has never been measured against a complete run, so the
# check reports instead of failing (`-Djacoco.haltOnFailure=false`). Once the real
# figures are known, the minima in pom.xml are set to match and dropping that one flag
# makes the gate binding.
coverage-report:
name: Coverage Report
needs: [ unit-tests, tests, core-integration-tests ]
# A failed slice still produced usable execution data, and the report is more useful in
# that case, not less, so this waits for the test jobs rather than requiring them to pass.
# `cancelled()` is a status check function, so naming it already suppresses the implicit
# `success()` on `needs`, and the job still runs after a failed slice. `always()` would
# be redundant here and GitHub discourages it.
if: ${{ !cancelled() }}
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
# Every artefact contains a file called jacoco.exec, so they must land in
# subdirectories of their own rather than being flattened onto each other. Left
# strict: if the test jobs ran but produced no execution data at all, that is a
# defect in the coverage wiring and should be visible rather than swallowed.
- name: Download coverage execution data
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: jacoco-exec-*
path: target/jacoco-exec
# The report needs compiled classes, hence a full `verify` rather than a bare goal
# invocation. Tests are skipped: they already ran in the jobs this one depends on.
- name: Merge execution data and evaluate thresholds
shell: bash
run: |
mvn verify -Pcoverage-aggregate -DskipTests -Djacoco.haltOnFailure=false -f pom.xml \
2>&1 | tee "${RUNNER_TEMP}/coverage-aggregate.log"
- name: Write coverage summary
if: ${{ !cancelled() }}
shell: bash
run: |
report="target/site/jacoco/jacoco.csv"
if [ ! -f "${report}" ]; then
echo "No aggregated coverage report was produced." >> "${GITHUB_STEP_SUMMARY}"
exit 1
fi
# Columns are fixed by JaCoCo's CSV format: 4/5 instruction, 6/7 branch,
# 8/9 line, 12/13 method, each as a missed/covered pair.
{
echo "## Aggregated code coverage"
echo
echo "| Counter | Covered | Missed | Ratio |"
echo "| --- | ---: | ---: | ---: |"
awk -F, '
function row(label, covered, missed, total) {
total = covered + missed
printf "| %s | %d | %d | %s |\n", label, covered, missed, \
(total > 0 ? sprintf("%.2f%%", 100 * covered / total) : "n/a")
}
NR > 1 {
im += $4; ic += $5
bm += $6; bc += $7
lm += $8; lc += $9
mm += $12; mc += $13
}
END {
row("Instruction", ic, im)
row("Branch", bc, bm)
row("Line", lc, lm)
row("Method", mc, mm)
}
' "${report}"
} >> "${GITHUB_STEP_SUMMARY}"
# Thresholds live in pom.xml alone; repeating them here would let the two drift.
# JaCoCo already names every breach it found, so the log is the source of truth.
log="${RUNNER_TEMP}/coverage-aggregate.log"
if [ -f "${log}" ] && grep -q "Rule violated" "${log}"; then
{
echo
echo "### Thresholds not met (advisory, does not fail the build)"
echo
echo '```'
grep "Rule violated" "${log}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
fi
- name: Upload coverage report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage-report
path: |
target/site/jacoco/
target/jacoco.exec
if-no-files-found: warn