1
1
#! /usr/bin/env bash
2
2
3
- # This is a helper function for the common pattern of reading Build Scan metadata
4
- # from the build-scans.csv file, then retrieving build metrics using the
5
- # Develocity API.
3
+ readonly LOGGING_BRIEF=' brief_logging'
4
+ readonly LOGGING_VERBOSE=' verbose_logging'
5
+ readonly RUN_ID_NONE=' '
6
+
7
+ # Main entrypoint for processing data online using the Build Scan summary tool.
8
+ # All scripts should call this function to fetch Build Scan data used in the
9
+ # experiment summary.
10
+ #
11
+ # USAGE: fetch_build_scans_and_build_time_metrics <logging_level> <run_id>
12
+ # EXAMPLE: fetch_build_scans_and_build_time_metrics "$LOGGING_BRIEF" "$RUN_ID"
13
+ #
14
+ # <logging_level> should be set to the constant LOGGING_BRIEF or LOGGING_VERBOSE
15
+ # <run_id> should be set to the constant RUN_ID or RUN_ID_NONE depending
16
+ # on whether the builds being queried for have a common run id,
17
+ # which will only be the case when both builds were produced
18
+ # during script execution
6
19
process_build_scan_data_online () {
20
+ local logging_level=" $1 "
21
+ local run_id=" $2 "
22
+
23
+ # Always call since it will only read if the metadata file exists
7
24
read_build_scan_metadata
8
- fetch_build_scans_and_build_time_metrics ' brief_logging' " ${build_scan_urls[@]} "
25
+
26
+ local build_scan_data
27
+ build_scan_data=" $( fetch_build_scan_data " $logging_level " " $run_id " ) "
28
+ parse_build_scans_and_build_time_metrics " ${build_scan_data} "
9
29
}
10
30
11
31
read_build_scan_metadata () {
@@ -46,38 +66,25 @@ is_build_scan_metadata_missing() {
46
66
return 0
47
67
}
48
68
69
+ # Used by CI / Local experiments to fetch data for the first CI build.
49
70
fetch_single_build_scan () {
50
71
local build_scan_url=" $1 "
51
72
52
73
local build_scan_data
53
- build_scan_data=" $( fetch_build_scan_data ' verbose_logging ' " ${build_scan_url} " ) "
74
+ build_scan_data=" $( fetch_build_scan_data " $LOGGING_VERBOSE " " $RUN_ID_NONE " ) "
54
75
55
76
parse_single_build_scan " ${build_scan_data} "
56
77
}
57
78
58
- # The value of logging_level should be either 'brief_logging' or
59
- # 'verbose_logging'
60
- fetch_build_scans_and_build_time_metrics () {
61
- local logging_level=" $1 "
62
- shift
63
- local build_scan_urls=(" $@ " )
64
-
65
- if [[ " ${logging_level} " == ' verbose_logging' ]]; then
66
- info " Fetching build scan data"
67
- fi
68
-
69
- local build_scan_data
70
- build_scan_data=" $( fetch_build_scan_data " ${logging_level} " " ${build_scan_urls[@]} " ) "
71
-
72
- parse_build_scans_and_build_time_metrics " ${build_scan_data} "
73
- }
74
-
75
- # Note: Callers of this function require stdout to be clean. No logging can be
76
- # done inside this function.
79
+ # WARNING: Experiment scripts should not call this function directly and instead
80
+ # use the process_build_scan_data_online or fetch_single_build_scan
81
+ # function.
82
+ #
83
+ # WARNING: Callers of this function require stdout to be clean. No logging can
84
+ # be done inside this function.
77
85
fetch_build_scan_data () {
78
86
local logging_level=" $1 "
79
- shift
80
- local build_scan_urls=(" $@ " )
87
+ local run_id=" $2 "
81
88
82
89
if [[ " ${debug_mode} " == " on" ]]; then
83
90
args+=(" --debug" )
@@ -91,14 +98,18 @@ fetch_build_scan_data() {
91
98
args+=(" --network-settings-file" " ${SCRIPT_DIR} /network.settings" )
92
99
fi
93
100
94
- if [[ " ${logging_level} " == " brief_logging " ]]; then
101
+ if [[ " ${logging_level} " == " ${LOGGING_BRIEF} " ]]; then
95
102
args+=(" --brief-logging" )
96
103
fi
97
104
98
105
if [[ " ${fail_if_not_fully_cacheable} " == " on" ]]; then
99
106
args+=(" --build-scan-availability-wait-timeout" " 60" )
100
107
fi
101
108
109
+ if [[ -n " ${run_id} " ]]; then
110
+ args+=(" --experiment-run-id" " $run_id " )
111
+ fi
112
+
102
113
for run_num in " ${! build_scan_urls[@]} " ; do
103
114
args+=( " ${run_num} ,${build_scan_urls[run_num]} " )
104
115
done
0 commit comments