Skip to content

Commit 30af4f9

Browse files
authored
Speed up builds (#267)
- Speed up builds by uploading one bulk report tarball rather than individual files. - Switch out GZIP with XZ and use the maximum compression factor.
1 parent 38069cf commit 30af4f9

File tree

7 files changed

+59
-103
lines changed

7 files changed

+59
-103
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Needed to stop Git Bash in CI accidentally injecting \r into jvm.config and breaking builds.
2+
* text=auto eol=lf
3+
*.cmd text=auto eol=crlf
4+
*.jar -text

.github/workflows/build.yml

+20-89
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,7 @@ jobs:
7979

8080
- name: Compile and run tests
8181
shell: bash
82-
run: >-
83-
./mvnw
84-
-B
85-
-e
86-
-T1C
87-
-U
88-
--no-transfer-progress
89-
-Dcheckstyle.skip=true
90-
-Dlicense.skip=true
91-
-Dstyle.color=always
92-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
93-
${{ inputs.maven-opts }}
94-
clean verify
82+
run: ./mvnw -B -U -Dcheckstyle.skip=true -Dlicense.skip=true clean verify
9583

9684
- name: Annotate test reports with build environment info
9785
if: always()
@@ -113,8 +101,9 @@ jobs:
113101
set +f -x
114102
# Allow globs to not match anything without causing errors.
115103
shopt -s nullglob
116-
117-
tar -czvf reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tgz \
104+
105+
# XZ with max compression, more efficient than using GZip.
106+
XZ_OPT=-9 tar -Jcvf reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz \
118107
**/target/failsafe-reports/** \
119108
**/target/surefire-reports/** \
120109
**/target/site/jacoco/unit/jacoco*.xml \
@@ -124,10 +113,10 @@ jobs:
124113
uses: actions/upload-artifact@v3
125114
if: always()
126115
with:
127-
name: zzz-reports-${{ matrix.java-version }}-${{ matrix.os-name }}
116+
name: reports-${{ matrix.java-version }}-${{ matrix.os-name }}
128117
if-no-files-found: error
129-
path: reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tgz
130-
retention-days: 1
118+
path: reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz
119+
retention-days: 30
131120

132121
mutation-tests:
133122
name: Run mutation tests
@@ -149,21 +138,7 @@ jobs:
149138
- name: Run mutation tests
150139
shell: bash
151140
# Do not run on multiple threads, the plugin does not support this properly.
152-
run: >-
153-
./mvnw
154-
-B
155-
-e
156-
-T1
157-
-U
158-
--also-make
159-
-pl java-compiler-testing
160-
--no-transfer-progress
161-
-P mutation
162-
-Dstyle.color=always
163-
-Dcheckstyle.skip=true
164-
-Dlicense.skip=true
165-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
166-
test
141+
run: ./mvnw -B -U -am -pl java-compiler-testing -P mutation -Dcheckstyle.skip=true -Dlicense.skip=true test
167142

168143
# Compress first so that the collection job later takes far less time (order of a few minutes
169144
# or so). GitHub does not compress these until after the workflow finishes, meaning when
@@ -177,16 +152,16 @@ jobs:
177152
set +f -x
178153
# Allow globs to not match anything without causing errors.
179154
shopt -s nullglob
180-
181-
tar -czvf reports-mutation-tests.tgz **/target/pit-reports/pit-reports/**
155+
# XZ with max compression, more efficient than using GZip.
156+
XZ_OPT=-9 tar -Jcvf reports-mutation-tests.tar.xz **/target/pit-reports/pit-reports/**
182157
183158
- name: Stash reports tarball
184159
uses: actions/upload-artifact@v3
185160
if: always()
186161
with:
187-
name: zzz-reports-mutation
162+
name: reports-mutation-tests
188163
if-no-files-found: error
189-
path: reports-mutation-tests.tgz
164+
path: reports-mutation-tests.tar.xz
190165
retention-days: 30
191166

192167
publish-test-reports:
@@ -211,19 +186,13 @@ jobs:
211186
- name: Download stashed tarballs
212187
uses: actions/download-artifact@v3
213188
with:
214-
path: 'artifacts/reports-*.tgz'
189+
path: 'artifacts/reports-*.tar.xz'
215190

216191
- name: Decompress stashed report tarballs
217192
shell: bash
218193
run: |-
219-
find artifacts/ -name "reports-*.tgz" -exec tar -xzvf {} \;
220-
find artifacts/ -name "reports-*.tgz" -exec rm -v {} \;
221-
222-
- name: Delete temporary artifacts
223-
uses: geekyeggo/delete-artifact@v2
224-
with:
225-
name: 'zzz-reports-*'
226-
failOnError: false
194+
find artifacts/ -name "reports-*.tar.xz" -exec tar -Jxvf {} \;
195+
find artifacts/ -name "reports-*.tar.xz" -exec rm -v {} \;
227196
228197
- name: Publish test results
229198
continue-on-error: true
@@ -261,25 +230,10 @@ jobs:
261230
chmod -v +x codecov
262231
./codecov -v
263232
# TODO: upload unit test and integration test reports separately so that
264-
# codecov processes it correctly. Need to hardwire the paths in here somehow.
233+
# codecov processes it correctly. Need to hard-wire the paths in here somehow.
265234
#./codecov -c -F unit -v
266235
#./codecov -c -F integration -v
267236
268-
# Now we are finishing, GitHub will compress this properly.
269-
- name: Upload all reports in one archive
270-
uses: actions/upload-artifact@v3
271-
if: always()
272-
with:
273-
name: test-reports
274-
if-no-files-found: error
275-
path: |-
276-
**/target/pit-reports/pit-reports/**
277-
**/target/failsafe-reports/**
278-
**/target/surefire-reports/**
279-
**/target/site/jacoco/unit/jacoco*.xml
280-
**/target/site/jacoco/int/jacoco*.xml
281-
retention-days: 30
282-
283237
formatting:
284238
name: Check formatting and licenses
285239
runs-on: ubuntu-22.04
@@ -300,19 +254,12 @@ jobs:
300254
- name: Run checks
301255
shell: bash
302256
run: >-
303-
./mvnw
304-
-B
305-
-e
306-
-T1C
307-
-U
308-
--no-transfer-progress
257+
./mvnw -B -U
309258
-DskipTests=true
310-
-Dstyle.color=always
311259
-Dmaven.main.skip
312260
-Dmaven.jar.skip
313261
-Dmaven.resources.skip
314262
-Dmaven.test.skip
315-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
316263
verify
317264
318265
dependency-check:
@@ -336,21 +283,15 @@ jobs:
336283
shell: bash
337284
run: >-
338285
./mvnw
339-
-B
340-
-e
341-
-T1C
342-
-U
343-
-Pdependency-check
344-
--no-transfer-progress
286+
-B -U
287+
-P dependency-check
345288
-DskipTests=true
346-
-Dstyle.color=always
347289
-Dcheckstyle.skip=true
348290
-Dlicense.skip=true
349291
-Dmaven.main.skip
350292
-Dmaven.jar.skip
351293
-Dmaven.resources.skip
352294
-Dmaven.test.skip
353-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
354295
verify
355296
356297
- name: Archive Dependency Scan reports
@@ -382,19 +323,10 @@ jobs:
382323
- name: Generate JavaDocs
383324
shell: bash
384325
run: >-
385-
./mvnw
386-
-B
387-
-e
388-
-T1C
389-
-U
390-
-pl java-compiler-testing
391-
--also-make
392-
--no-transfer-progress
326+
./mvnw -B -U -am -pl java-compiler-testing
393327
-Dmaven.test.skip=true
394328
-Dcheckstyle.skip=true
395329
-Dlicense.skip=true
396-
-Dstyle.color=always
397-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
398330
clean compile javadoc:jar
399331
400332
- name: Upload JavaDocs as a build artifact
@@ -424,4 +356,3 @@ jobs:
424356
with:
425357
name: github-pages
426358
failOnError: false
427-

.github/workflows/deploy.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
6363
info "Determining release version to use (this may take a moment)..."
6464
if [[ '${{ inputs.version }}' == "" ]]; then
65-
release_version="$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')"
65+
release_version="$(./mvnw -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')"
6666
else
6767
release_version='${{ inputs.version }}'
6868
fi
@@ -83,14 +83,11 @@ jobs:
8383
run <<-SCRIPT
8484
./mvnw -B -e \
8585
-Preleases \
86-
--no-transfer-progress \
8786
-Darguments='${build_args[@]}' \
8887
-DdryRun='${{ inputs.dry-run }}' \
89-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \
9088
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \
9189
-DreleaseVersion='${release_version}' \
9290
-DsignTag=false \
93-
-Dstyle.color=always \
9491
-Dtag='v${release_version}' \
9592
release:prepare release:perform
9693
SCRIPT

.mvn/jvm.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-XX:+TieredCompilation -XX:TieredStopAtLevel=1

.mvn/maven.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-e -T1C -Dstyle.color=always -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress

mvnw

+2
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ export MAVEN_CMD_LINE_ARGS
307307

308308
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309309

310+
set -x
311+
310312
exec "$JAVACMD" \
311313
$MAVEN_OPTS \
312314
$MAVEN_DEBUG_OPTS \

scripts/prepare-test-outputs-for-merge.sh

+30-10
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ info "Generated XSLT script at ${surefire_prefix_xslt}"
8989

9090
function find-all-surefire-reports {
9191
info "Discovering Surefire test reports"
92-
find . -wholename '**/target/surefire-reports/TEST-*Test.xml' -print0 | xargs -0
92+
find . -wholename '**/target/surefire-reports/TEST-*Test.xml' -print
9393
}
9494

9595
function find-all-failsafe-reports {
9696
info "Discovering Failsafe test reports"
97-
find . -wholename '**/target/failsafe-reports/TEST-*Test.xml' -print0 | xargs -0
97+
find . -wholename '**/target/failsafe-reports/TEST-*Test.xml' -print
9898
}
9999

100100
function find-all-jacoco-reports {
@@ -109,19 +109,39 @@ function find-all-jacoco-reports {
109109
fi
110110
}
111111

112+
function xsltproc-surefire-report {
113+
local prefix="${1}"
114+
local xslt="${2}"
115+
local input_report="${3}"
116+
local output_report="${4}"
117+
118+
if ! run <<< "xsltproc --stringparam prefix '${prefix}' '${xslt}' '${input_report}' > '${output_report}'"; then
119+
err "Error invoking xsltproc! Erroneous report was:"
120+
dump "${input_report}"
121+
return 2
122+
fi
123+
124+
rm "${input_report}"
125+
}
126+
112127
info "Updating test reports..."
113128
report_count=0
114-
for report in $(find-all-surefire-reports) $(find-all-failsafe-reports); do
129+
prefix="[Java-${ci_java_version}-${ci_os}]"
130+
concurrency="$(($(nproc) * 4))"
131+
132+
while read -r report; do
115133
report_count="$((report_count+1))"
116134
new_report="${report/.xml/-java-${ci_java_version}-${ci_os}.xml}"
117-
prefix="[Java-${ci_java_version}-${ci_os}]"
118-
if ! run <<< "xsltproc --stringparam prefix '${prefix}' '${surefire_prefix_xslt}' '${report}' > '${new_report}'"; then
119-
err "Error invoking xsltproc! Erroneous report was:"
120-
dump "${report}"
121-
exit 2
135+
xsltproc-surefire-report "${prefix}" "${surefire_prefix_xslt}" "${report}" "${new_report}" &
136+
137+
# Wait if we have the max number of jobs in the window running (cpu-count * 4)
138+
if [ "$((report_count % concurrency))" -eq 0 ]; then
139+
wait < <(jobs -p)
140+
info "Waited for up to ${concurrency} jobs to complete, will now continue..."
122141
fi
123-
run <<< "rm '${report}'"
124-
done
142+
done < <(find-all-surefire-reports; find-all-failsafe-reports)
143+
wait < <(jobs -p)
144+
125145
success "Updated ${report_count} test reports"
126146

127147
info "Updating coverage reports..."

0 commit comments

Comments
 (0)