-
Notifications
You must be signed in to change notification settings - Fork 10
289 lines (249 loc) · 8.17 KB
/
build.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
name: Build
on:
pull_request:
branches:
- '**'
types:
- opened
- synchronize
push:
branches:
- main
workflow_call: {}
workflow_dispatch: {}
jobs:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Initialize Java
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 17
cache: 'maven'
- name: Run Maven checks
shell: bash
run: >-
./mvnw -B -U
-DskipTests=true
-Dmaven.main.skip
-Dmaven.jar.skip
-Dmaven.resources.skip
-Dmaven.test.skip
verify
- name: Run ShellCheck
uses: ludeeus/[email protected]
with:
check_together: 'yes'
scandir: './scripts'
- name: Validate codecov.yml
continue-on-error: false
if: always()
shell: bash
run: curl --fail -vv --data-binary @codecov.yml https://codecov.io/validate
build:
name: Build on JDK ${{ matrix.java-version }} (${{ matrix.os-name }})
runs-on: ${{ matrix.os-name }}
needs:
- linting
strategy:
fail-fast: false
matrix:
os-name: [ubuntu-latest]
java-version: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21-ea]
include:
# MacOS builds (only check Java 17).
- os-name: macos-13
java-version: 17
# Windows builds (only check 17).
- os-name: windows-2022
java-version: 17
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Initialize JDK
uses: actions/[email protected]
with:
cache: maven
check-latest: true
distribution: zulu
java-version: ${{ matrix.java-version }}
- name: Install dependencies
shell: bash
run: |-
source "./scripts/common.sh"
# Ensure consistent versions of tools we use. MacOS uses an outdated version of bash, for
# example.
case "${OSTYPE}" in
win*|msys*)
run <<< "choco install xsltproc"
;;
darwin*)
run <<< "brew install bash libxslt"
;;
linux*)
run <<< "sudo apt-get update -q"
run <<< "sudo apt-get install xsltproc -qy"
;;
*)
warn "Unknown OS type '${OSTYPE}'. Update build.yaml with a new case."
;;
esac
- name: Dump system and JDK info
shell: bash
run: |-
source "./scripts/common.sh"
function report() {
info "${1}:"
run <<< "${2}"
echo
}
report "System" "uname -a"
report "JRE/JVM" "java -version"
report "JDK" "javac -version"
report "Maven" "./mvnw -v"
- name: Compile and run tests
shell: bash
run: ./mvnw -B -U -Dcheckstyle.skip=true -Dlicense.skip=true clean verify
- name: Annotate test reports with build environment info
if: always()
shell: bash
run: >-
scripts/prepare-test-outputs-for-merge.sh
-j "${{ matrix.java-version }}"
-o "${{ matrix.os-name }}"
# Compress first so that the collection job later takes far less time (order of a few minutes
# or so). GitHub does not compress these until after the workflow finishes, meaning when
# we unstash them to produce the coverage reports, it will make an HTTP call for every single
# file. This can take several minutes and is somewhat painful to have to wait for.
- name: Compress test and coverage reports into tarball
if: always()
shell: bash
run: |-
set -x
# Allow globs to not match anything without causing errors.
shopt -s nullglob
# XZ with max compression, more efficient than using GZip.
XZ_OPT=-9 tar -Jcvf reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz \
$(find . -name surefire-reports -o -name failsafe-reports) \
$(find . -name 'jacoco.xml')
- name: Stash reports tarball
uses: actions/[email protected]
if: always()
with:
name: reports-${{ matrix.java-version }}-${{ matrix.os-name }}
if-no-files-found: error
path: reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz
retention-days: 30
publish-test-reports:
name: Publish test reports
runs-on: ubuntu-latest
if: always()
needs:
- build
- linting
permissions:
checks: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
# Needed to keep actions working correctly.
fetch-depth: 2
- name: Download stashed tarballs
uses: actions/[email protected]
with:
path: 'artifacts/reports-*.tar.xz'
- name: Decompress stashed report tarballs
shell: bash
run: |-
find artifacts/ -name "reports-*.tar.xz" -exec tar -Jxvf {} \;
find artifacts/ -name "reports-*.tar.xz" -exec rm -v {} \;
- name: Publish test results
continue-on-error: true
uses: EnricoMi/[email protected]
if: always()
with:
action_fail: false
check_run_annotations: "skipped tests"
deduplicate_classes_by_file_name: true
json_test_case_results: true
json_thousands_separator: ","
junit_files: "**/TEST-*.xml"
report_individual_runs: false
test_changes_limit: 500
time_unit: "milliseconds"
- name: Publish to codecov
continue-on-error: true
if: always()
shell: bash
run: |-
curl --fail https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring \
--keyring trustedkeys.gpg --import
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod -v +x codecov
./codecov -v
generate-documentation:
name: Generate documentation
runs-on: ubuntu-latest
needs:
- linting
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Initialize Java
uses: actions/[email protected]
with:
distribution: 'zulu'
# Must use >= JDK 17 for JavaDocs to generate correctly.
java-version: 17
cache: 'maven'
- name: Generate JavaDocs
shell: bash
run: >-
./mvnw -B -U -am -pl java-compiler-testing
-Dmaven.test.skip=true
-Dcheckstyle.skip=true
-Dlicense.skip=true
clean compile javadoc:jar
- name: Upload JavaDocs as a build artifact
uses: actions/upload-pages-artifact@v2
with:
path: java-compiler-testing/target/apidocs
publish-documentation:
name: Publish documentation
# Do not run multiple builds at once, as it can fail.
concurrency:
cancel-in-progress: true
group: snapshot-javadocs
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
permissions:
pages: write
id-token: write
needs:
- generate-documentation
- build
steps:
- name: Deploy JavaDocs build artifact to GitHub Pages
id: snapshot-javadocs
uses: actions/[email protected]
- name: Delete temporary artifacts
uses: geekyeggo/[email protected]
with:
name: github-pages
failOnError: false