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
15
+ # function, e.g., "$(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
+ local build_scan_data
24
+ build_scan_data=" $( fetch_build_scan_data " ${@ } " ) "
25
+ parse_build_scans_and_build_time_metrics " ${build_scan_data} "
26
+ }
27
+
28
+ query_none () {
29
+ # Intentionally no-op so query definitions can appear consistent
30
+ true
31
+ }
32
+
33
+ query_run_id () {
34
+ echo " value:\" Experiment run id=$RUN_ID \" "
9
35
}
10
36
11
37
read_build_scan_metadata () {
@@ -46,38 +72,25 @@ is_build_scan_metadata_missing() {
46
72
return 0
47
73
}
48
74
75
+ # Used by CI / Local experiments to fetch data for the first CI build.
49
76
fetch_single_build_scan () {
50
77
local build_scan_url=" $1 "
51
78
52
79
local build_scan_data
53
- build_scan_data=" $( fetch_build_scan_data ' verbose_logging ' " ${build_scan_url} " ) "
80
+ build_scan_data=" $( fetch_build_scan_data " $LOGGING_VERBOSE " " $( query_none ) " ) "
54
81
55
82
parse_single_build_scan " ${build_scan_data} "
56
83
}
57
84
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.
85
+ # WARNING: Experiment scripts should not call this function directly and instead
86
+ # use the process_build_scan_data_online or fetch_single_build_scan
87
+ # function.
88
+ #
89
+ # WARNING: Callers of this function require stdout to be clean. No logging can
90
+ # be done inside this function.
77
91
fetch_build_scan_data () {
78
92
local logging_level=" $1 "
79
- shift
80
- local build_scan_urls=(" $@ " )
93
+ local query=" $2 "
81
94
82
95
if [[ " ${debug_mode} " == " on" ]]; then
83
96
args+=(" --debug" )
@@ -99,6 +112,10 @@ fetch_build_scan_data() {
99
112
args+=(" --build-scan-availability-wait-timeout" " 60" )
100
113
fi
101
114
115
+ if [[ -n " ${query} " ]]; then
116
+ args+=(" --query" " $query " )
117
+ fi
118
+
102
119
for run_num in " ${! build_scan_urls[@]} " ; do
103
120
args+=( " ${run_num} ,${build_scan_urls[run_num]} " )
104
121
done
0 commit comments