@@ -78,7 +78,7 @@ def sum_inconclusive_results(results):
78
78
79
79
80
80
def cmd_summary (data ):
81
- kci_print ("pass/fail/inconclusive" )
81
+ kci_msg ("pass/fail/inconclusive" )
82
82
83
83
builds = data ["buildsSummary" ]["builds" ]
84
84
print_summary ("builds" , builds ["valid" ], builds ["invalid" ], builds ["null" ])
@@ -100,35 +100,59 @@ def cmd_list_trees(origin):
100
100
trees = fetch_tree_fast (origin )
101
101
for t in trees :
102
102
kci_msg_green_nonl (f"- { t ['tree_name' ]} /{ t ['git_repository_branch' ]} :\n " )
103
- kci_print (f" giturl: { t ['git_repository_url' ]} " )
104
- kci_print (f" latest: { t ['git_commit_hash' ]} ({ t ['git_commit_name' ]} )" )
105
- kci_print (f" latest: { t ['start_time' ]} " )
103
+ kci_msg (f" giturl: { t ['git_repository_url' ]} " )
104
+ kci_msg (f" latest: { t ['git_commit_hash' ]} ({ t ['git_commit_name' ]} )" )
105
+ kci_msg (f" latest: { t ['start_time' ]} " )
106
106
107
107
108
- def cmd_failed_builds (data , download_logs ):
109
- kci_print ("Failed builds:" )
108
+ def cmd_builds (data , commit , download_logs , status ):
109
+ if status == "inconclusive" :
110
+ kci_msg ("No information about inconclusive builds." )
111
+ return
112
+
110
113
for build in data ["builds" ]:
111
- if not build ["valid" ]:
112
- log_path = build ["log_url" ]
113
- if download_logs :
114
- try :
115
- log_gz = requests .get (build ["log_url" ])
116
- log = gzip .decompress (log_gz .content )
117
- log_file = f"{ build ['config_name' ]} -{ build ['architecture' ]} -{ build ['compiler' ]} .log"
118
- with open (log_file , mode = "wb" ) as file :
119
- file .write (log )
120
- log_path = os .path .join (os .getcwd (), log_file )
121
- except :
122
- kci_err (f"Failed to fetch log { log_file } )." )
123
- pass
124
-
125
- kci_print (
126
- f"- config: { build ['config_name' ]} ; arch: { build ['architecture' ]} "
127
- )
128
- kci_print (f" compiler: { build ['compiler' ]} " )
129
- kci_print (f" config_url: { build ['config_url' ]} " )
130
- kci_print (f" log: { log_path } " )
131
- kci_print (f" id: { build ['id' ]} " )
114
+ if build ["valid" ] == None :
115
+ continue
116
+
117
+ if not status == "all" :
118
+ if build ["valid" ] == (status == "fail" ):
119
+ continue
120
+
121
+ if not build ["valid" ] == (status == "pass" ):
122
+ continue
123
+
124
+ log_path = build ["log_url" ]
125
+ if download_logs :
126
+ try :
127
+ log_gz = requests .get (build ["log_url" ])
128
+ log = gzip .decompress (log_gz .content )
129
+ log_file = f"{ build ['config_name' ]} -{ build ['architecture' ]} -{ build ['compiler' ]} -{ commit } .log"
130
+ with open (log_file , mode = "wb" ) as file :
131
+ file .write (log )
132
+ log_path = "file://" + os .path .join (os .getcwd (), log_file )
133
+ except :
134
+ kci_err (f"Failed to fetch log { log_file } )." )
135
+ pass
136
+
137
+ kci_msg_nonl ("- config:" )
138
+ kci_msg_cyan_nonl (build ["config_name" ])
139
+ kci_msg_nonl (" arch: " )
140
+ kci_msg_cyan_nonl (build ["architecture" ])
141
+ kci_msg_nonl (" compiler: " )
142
+ kci_msg_cyan_nonl (build ["compiler" ])
143
+ kci_msg ("" )
144
+
145
+ kci_msg_nonl (" status:" )
146
+ if build ["valid" ]:
147
+ kci_msg_green_nonl ("PASS" )
148
+ else :
149
+ kci_msg_red_nonl ("FAIL" )
150
+ kci_msg ("" )
151
+
152
+ kci_msg (f" config_url: { build ['config_url' ]} " )
153
+ kci_msg (f" log: { log_path } " )
154
+ kci_msg (f" id: { build ['id' ]} " )
155
+ kci_msg ("" )
132
156
133
157
134
158
@click .command (help = " [Experimental] Get results from the dashboard" )
@@ -163,8 +187,13 @@ def cmd_failed_builds(data, download_logs):
163
187
is_flag = True ,
164
188
help = "Select latest results available" ,
165
189
)
190
+ @click .option (
191
+ "--status" ,
192
+ help = "Status of test result: all, pass, fail, inconclusive" ,
193
+ default = "all" ,
194
+ )
166
195
@click .pass_context
167
- def results (ctx , origin , giturl , branch , commit , action , download_logs , latest ):
196
+ def results (ctx , origin , giturl , branch , commit , action , download_logs , latest , status ):
168
197
if action == None or action == "summary" :
169
198
if not giturl or not branch or not ((commit != None ) ^ latest ):
170
199
kci_err ("--giturl AND --branch AND (--commit XOR --latest) are required" )
@@ -175,14 +204,17 @@ def results(ctx, origin, giturl, branch, commit, action, download_logs, latest):
175
204
cmd_summary (data )
176
205
elif action == "trees" :
177
206
cmd_list_trees (origin )
178
- elif action == "failed- builds" :
207
+ elif action == "builds" :
179
208
if not giturl or not branch or not ((commit != None ) ^ latest ):
180
209
kci_err ("--giturl AND --branch AND (--commit XOR --latest) are required" )
181
210
raise click .Abort ()
182
211
if latest :
183
212
commit = get_latest_commit (origin , giturl , branch )
184
213
data = fetch_full_results (origin , giturl , branch , commit )
185
- cmd_failed_builds (data , download_logs )
214
+ cmd_builds (data , commit , download_logs , status )
215
+ else :
216
+ kci_err (f"action '{ action } ' does not exist." )
217
+ raise click .Abort ()
186
218
187
219
188
220
if __name__ == "__main__" :
0 commit comments