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
+
6
+ # Main entrypoint for processing data online using the Build Scan summary tool.
7
+ # All scripts should call this function to fetch Build Scan data used in the
8
+ # experiment summary.
9
+ #
10
+ # USAGE: fetch_build_scans_and_build_time_metrics <logging_level> <query>
11
+ #
12
+ # <logging_level> should be set using either LOGGING_BRIEF or LOGGING_VERBOSE
13
+ # constant, e.g., "$LOGGING_BRIEF"
14
+ # <query> should be set using either query_none or query_run_id function, e.g.,
15
+ # "$(query_none)"
6
16
process_build_scan_data_online () {
17
+ local logging_level=" $1 "
18
+ local query=" $2 "
19
+
20
+ # Always call since it will only read if the metadata file exists
7
21
read_build_scan_metadata
8
- fetch_build_scans_and_build_time_metrics ' brief_logging' " ${build_scan_urls[@]} "
22
+
23
+ fetch_build_scans_and_build_time_metrics " $logging_level " " $query "
24
+ }
25
+
26
+ query_none () {
27
+ # Intentionally no-op so query definitions can appear consistent
28
+ true
29
+ }
30
+
31
+ query_run_id () {
32
+ echo " value:\" Experiment run id=$RUN_ID \" "
9
33
}
10
34
11
35
read_build_scan_metadata () {
@@ -46,38 +70,36 @@ is_build_scan_metadata_missing() {
46
70
return 0
47
71
}
48
72
73
+ # Used by CI / Local experiments to fetch data for the first CI build.
49
74
fetch_single_build_scan () {
50
75
local build_scan_url=" $1 "
51
76
52
77
local build_scan_data
53
- build_scan_data=" $( fetch_build_scan_data ' verbose_logging' " ${build_scan_url} " ) "
78
+ build_scan_data=" $( fetch_build_scan_data ' verbose_logging' " $( query_none ) " " $ {build_scan_url}" ) "
54
79
55
80
parse_single_build_scan " ${build_scan_data} "
56
81
}
57
82
58
83
# The value of logging_level should be either 'brief_logging' or
59
- # 'verbose_logging'
84
+ # 'verbose_logging'.
85
+ #
86
+ # WARNING: Experiment scripts should not call this function directly and instead
87
+ # use one of the 'process_X' functions.
60
88
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
89
local build_scan_data
70
- build_scan_data=" $( fetch_build_scan_data " ${logging_level} " " ${build_scan_urls[@]} " ) "
71
90
91
+ build_scan_data=" $( fetch_build_scan_data " ${@ } " ) "
72
92
parse_build_scans_and_build_time_metrics " ${build_scan_data} "
73
93
}
74
94
75
- # Note: Callers of this function require stdout to be clean. No logging can be
76
- # done inside this function.
95
+ # WARNING: Experiment scripts should not call this function directly and instead
96
+ # use one of the 'process_X' functions.
97
+ #
98
+ # WARNING: Callers of this function require stdout to be clean. No logging can
99
+ # be done inside this function.
77
100
fetch_build_scan_data () {
78
101
local logging_level=" $1 "
79
- shift
80
- local build_scan_urls=(" $@ " )
102
+ local query=" $2 "
81
103
82
104
if [[ " ${debug_mode} " == " on" ]]; then
83
105
args+=(" --debug" )
@@ -99,6 +121,10 @@ fetch_build_scan_data() {
99
121
args+=(" --build-scan-availability-wait-timeout" " 60" )
100
122
fi
101
123
124
+ if [[ -n " ${query} " ]]; then
125
+ args+=(" --query" " $query " )
126
+ fi
127
+
102
128
for run_num in " ${! build_scan_urls[@]} " ; do
103
129
args+=( " ${run_num} ,${build_scan_urls[run_num]} " )
104
130
done
0 commit comments