Skip to content

Commit c73ae9f

Browse files
committed
Merge remote-tracking branch 'origin/erichaagdev/maven-exp2-scan-dump' into dev
* origin/erichaagdev/maven-exp2-scan-dump: Fail when scans-support-tools not found Adjust interactive text accordingly Use Build Scan dumps for maven-exp2 Extract common components to new lib
2 parents eb5bad9 + 0270b66 commit c73ae9f

File tree

6 files changed

+130
-53
lines changed

6 files changed

+130
-53
lines changed

components/scripts/gradle/03-validate-local-build-caching-different-locations.sh

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ readonly SCRIPT_NAME
1919
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo .)")"; pwd)"
2020
readonly SCRIPT_DIR
2121
readonly LIB_DIR="${SCRIPT_DIR}/lib"
22-
readonly SCANS_SUPPORT_TOOLS_JAR="${SCRIPT_DIR}/scans-support-tools.jar"
2322

2423
# Include and parse the command line arguments
2524
# shellcheck source=lib/03-cli-parser.sh
@@ -38,9 +37,6 @@ enable_ge=''
3837
ge_server=''
3938
interactive_mode=''
4039

41-
# Used when Build Scan publishing is disabled
42-
build_scan_dumps=()
43-
4440
main() {
4541
if [[ "$build_scan_publishing_mode" == "off" ]]; then
4642
verify_scans_support_tools
@@ -55,12 +51,6 @@ main() {
5551
exit_with_return_code
5652
}
5753

58-
verify_scans_support_tools() {
59-
if [ ! -f "$SCANS_SUPPORT_TOOLS_JAR" ]; then
60-
die "ERROR: scans-support-tools.jar is required when running with --disable-build-scan-publishing."
61-
fi
62-
}
63-
6454
execute() {
6555
print_bl
6656
validate_required_config
@@ -184,34 +174,10 @@ fetch_build_cache_metrics() {
184174
read_build_scan_metadata
185175
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
186176
else
187-
find_build_scan_dumps
188-
read_build_scan_dumps
177+
find_and_read_build_scan_dumps
189178
fi
190179
}
191180

192-
find_build_scan_dumps() {
193-
find_build_scan_dump "first"
194-
find_build_scan_dump "second"
195-
}
196-
197-
find_build_scan_dump() {
198-
local build_name="$1"
199-
local build_dir="${EXP_DIR}/$build_name-build_${project_name}"
200-
build_scan_dump="$(find "$build_dir" -maxdepth 1 -type f -regex '^.*build-scan-.*-.*-.*-.*\.scan' | sort | tail -n 1)"
201-
if [ -z "$build_scan_dump" ]; then
202-
die "ERROR: No Build Scan dump found for the $build_name build"
203-
fi
204-
build_scan_dumps+=("${build_scan_dump}")
205-
}
206-
207-
read_build_scan_dumps() {
208-
local build_scan_csv
209-
echo -n "Extracting build scan data"
210-
build_scan_csv="$(invoke_java "$SCANS_SUPPORT_TOOLS_JAR" extract "${build_scan_dumps[0]}" "${build_scan_dumps[1]}")"
211-
parse_build_scan_csv "$build_scan_csv"
212-
echo ", done."
213-
}
214-
215181
# Overrides info.sh#print_performance_metrics
216182
print_performance_metrics() {
217183
print_build_caching_leverage_metrics
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
readonly SCANS_SUPPORT_TOOLS_JAR="${SCRIPT_DIR}/scans-support-tools.jar"
4+
5+
build_scan_dumps=()
6+
7+
verify_scans_support_tools() {
8+
if [ ! -f "$SCANS_SUPPORT_TOOLS_JAR" ]; then
9+
die "ERROR: scans-support-tools.jar is required when running with --disable-build-scan-publishing."
10+
fi
11+
}
12+
13+
find_and_read_build_scan_dumps() {
14+
find_build_scan_dumps
15+
read_build_scan_dumps
16+
}
17+
18+
find_build_scan_dumps() {
19+
find_build_scan_dump "first"
20+
find_build_scan_dump "second"
21+
}
22+
23+
find_build_scan_dump() {
24+
local build_name="$1"
25+
local build_dir="${EXP_DIR}/$build_name-build_${project_name}"
26+
build_scan_dump="$(find "$build_dir" -maxdepth 1 -type f -regex '^.*build-scan-.*-.*-.*-.*\.scan' | sort | tail -n 1)"
27+
if [ -z "$build_scan_dump" ]; then
28+
die "ERROR: No Build Scan dump found for the $build_name build"
29+
fi
30+
build_scan_dumps+=("${build_scan_dump}")
31+
}
32+
33+
read_build_scan_dumps() {
34+
local build_scan_csv
35+
echo -n "Extracting build scan data"
36+
build_scan_csv="$(invoke_java "$SCANS_SUPPORT_TOOLS_JAR" extract "${build_scan_dumps[0]}" "${build_scan_dumps[1]}")"
37+
parse_build_scan_csv "$build_scan_csv"
38+
echo ", done."
39+
}

components/scripts/lib/cli-parsers/maven/02-cli-parser.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
# shellcheck disable=SC2034 # It is common for variables in this auto-generated file to go unused
33
# Created by argbash-init v2.10.0
4+
# ARG_OPTIONAL_BOOLEAN([disable-build-scan-publishing],[x],[])
45
# ARG_HELP([This function is overridden later on.])
56
# ARG_VERSION([print_version],[v],[version],[])
67
# ARGBASH_WRAP([common])
@@ -26,6 +27,7 @@ function print_help() {
2627
print_option_usage -a
2728
print_option_usage -s
2829
print_option_usage -e
30+
print_option_usage -x
2931
print_option_usage -f
3032
print_option_usage -v
3133
print_option_usage -h

components/scripts/lib/libs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ failed_to_load_lib() {
1212
exit "${_UNEXPECTED_ERROR}"
1313
}
1414

15+
# shellcheck source=lib/build-scan-dump.sh
16+
source "${LIB_DIR}/build-scan-dump.sh" || failed_to_load_lib build-scan-dump.sh
17+
18+
# shellcheck source=lib/build-scan-parse.sh
19+
source "${LIB_DIR}/build-scan-parse.sh" || failed_to_load_lib build-scan-parse.sh
20+
1521
# shellcheck source=lib/build_scan.sh
1622
source "${LIB_DIR}/build_scan.sh" || failed_to_load_lib build_scan.sh
1723

@@ -45,9 +51,6 @@ source "${LIB_DIR}/java.sh" || failed_to_load_lib java.sh
4551
# shellcheck source=lib/maven.sh
4652
source "${LIB_DIR}/maven.sh" || failed_to_load_lib maven.sh
4753

48-
# shellcheck source=lib/build-scan-parse.sh
49-
source "${LIB_DIR}/build-scan-parse.sh" || failed_to_load_lib build-scan-parse.sh
50-
5154
# shellcheck source=lib/paths.sh
5255
source "${LIB_DIR}/paths.sh" || failed_to_load_lib paths.sh
5356

components/scripts/lib/maven.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ invoke_maven() {
4040
done
4141
fi
4242

43+
if [ "$build_scan_publishing_mode" == "off" ]; then
44+
args+=("-Dscan.dump")
45+
else
46+
args+=("-Dscan")
47+
fi
48+
4349
args+=(
44-
-Dscan
4550
-Dmaven.ext.class.path="${extension_classpath}"
4651
-Dcom.gradle.enterprise.build_validation.experimentDir="${EXP_DIR}"
4752
-Dcom.gradle.enterprise.build_validation.expId="${EXP_SCAN_TAG}"

components/scripts/maven/02-validate-local-build-caching-different-locations.sh

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ ge_server=''
3838
interactive_mode=''
3939

4040
main() {
41+
if [[ "$build_scan_publishing_mode" == "off" ]]; then
42+
verify_scans_support_tools
43+
fi
44+
4145
if [ "${interactive_mode}" == "on" ]; then
4246
wizard_execute
4347
else
@@ -74,11 +78,15 @@ wizard_execute() {
7478
print_bl
7579
print_introduction
7680

77-
print_bl
78-
explain_prerequisites_ccud_maven_extension "I."
79-
80-
print_bl
81-
explain_prerequisites_api_access "II."
81+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
82+
print_bl
83+
explain_prerequisites_ccud_maven_extension "I."
84+
print_bl
85+
explain_prerequisites_api_access "II."
86+
else
87+
print_bl
88+
explain_prerequisites_ccud_maven_extension
89+
fi
8290

8391
print_bl
8492
explain_collect_git_details
@@ -122,7 +130,7 @@ wizard_execute() {
122130

123131
execute_first_build() {
124132
info "Running first build:"
125-
info "./mvnw -Dscan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} clean ${tasks}$(print_extra_args)"
133+
print_maven_command
126134

127135
# shellcheck disable=SC2086 # we want tasks to expand with word splitting in this case
128136
invoke_maven \
@@ -134,7 +142,7 @@ execute_first_build() {
134142

135143
execute_second_build() {
136144
info "Running second build:"
137-
info "./mvnw -Dscan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} clean ${tasks}$(print_extra_args)"
145+
print_maven_command
138146

139147
cd "${EXP_DIR}/second-build_${project_name}" || die "Unable to cd to ${EXP_DIR}/second-build_${project_name}"
140148

@@ -146,9 +154,21 @@ execute_second_build() {
146154
clean ${tasks}
147155
}
148156

157+
print_maven_command() {
158+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
159+
info "./mvnw -Dscan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} clean ${tasks}$(print_extra_args)"
160+
else
161+
info "./mvnw -Dscan.dump -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} clean ${tasks}$(print_extra_args)"
162+
fi
163+
}
164+
149165
fetch_build_cache_metrics() {
150-
read_build_scan_metadata
151-
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
166+
if [ "$build_scan_publishing_mode" == "on" ]; then
167+
read_build_scan_metadata
168+
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
169+
else
170+
find_and_read_build_scan_dumps
171+
fi
152172
}
153173

154174
# Overrides info.sh#print_performance_metrics
@@ -288,7 +308,8 @@ EOF
288308

289309
explain_measure_build_results() {
290310
local text
291-
IFS='' read -r -d '' text <<EOF
311+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
312+
IFS='' read -r -d '' text <<EOF
292313
$(print_separator)
293314
${HEADER_COLOR}Measure build results${RESTORE}
294315
@@ -301,22 +322,36 @@ two builds to assist you in your investigation.
301322
302323
${USER_ACTION_COLOR}Press <Enter> to measure the build results.${RESTORE}
303324
EOF
325+
else
326+
IFS='' read -r -d '' text <<EOF
327+
$(print_separator)
328+
${HEADER_COLOR}Measure build results${RESTORE}
329+
330+
Now that the second build has finished successfully, you are ready to measure in
331+
Gradle Enterprise how well your build leverages the local build cache for
332+
the invoked set of Maven goals.
333+
334+
Some of the build scan data will be extracted from the locally stored, intermediate
335+
build data produced by the two builds to assist you in your investigation.
336+
337+
${USER_ACTION_COLOR}Press <Enter> to measure the build results.${RESTORE}
338+
EOF
339+
fi
304340
print_wizard_text "${text}"
305341
wait_for_enter
306342
}
307343

308344
explain_and_print_summary() {
309345
read_build_scan_metadata
310346
local text
311-
IFS='' read -r -d '' text <<EOF
347+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
348+
IFS='' read -r -d '' text <<EOF
312349
The ‘Summary’ section below captures the configuration of the experiment and the
313350
two build scans that were published as part of running the experiment. The build
314351
scan of the second build is particularly interesting since this is where you can
315352
inspect what goals were not leveraging the local build cache.
316353
317-
The ‘Build Caching Leverage’ section below reveals the realized and potential
318-
savings from build caching. All cacheable goals' outputs need to be taken from
319-
the build cache in the second build for the build to be fully cacheable.
354+
$(explain_build_cache_leverage)
320355
321356
The ‘Investigation Quick Links’ section below allows quick navigation to the
322357
most relevant views in build scans to investigate what goals were avoided due to
@@ -332,8 +367,35 @@ $(print_command_to_repeat_experiment)
332367
333368
$(explain_when_to_rerun_experiment)
334369
EOF
370+
else
371+
IFS='' read -r -d '' text <<EOF
372+
The ‘Summary’ section below captures the configuration of the experiment. No
373+
build scans are available for inspection since publishing was disabled for the
374+
experiment.
375+
376+
$(explain_build_cache_leverage)
377+
378+
$(explain_command_to_repeat_experiment)
379+
380+
$(print_summary)
381+
382+
$(print_command_to_repeat_experiment)
383+
384+
$(explain_when_to_rerun_experiment)
385+
EOF
386+
fi
335387
print_wizard_text "${text}"
336388
}
337389

390+
explain_build_cache_leverage() {
391+
local text
392+
IFS='' read -r -d '' text <<EOF
393+
The ‘Build Caching Leverage’ section below reveals the realized and potential
394+
savings from build caching. All cacheable goals' outputs need to be taken from
395+
the build cache in the second build for the build to be fully cacheable.
396+
EOF
397+
echo -n "${text}"
398+
}
399+
338400
process_arguments "$@"
339401
main

0 commit comments

Comments
 (0)