@@ -108,13 +108,19 @@ def handle_github_status_event(bert_e, json_data):
108108 return CommitJob (bert_e = bert_e , commit = event .commit )
109109
110110
111- def handle_github_check_run_event (bert_e , json_data ):
112- event = github .CheckRunEvent (bert_e = bert_e .client , ** json_data )
113- return CommitJob (bert_e = bert_e , commit = event .commit )
111+ def handle_github_check_suite_event (bert_e , json_data ):
112+ event = github .CheckSuiteEvent (client = bert_e .client , ** json_data )
113+ status = event .status
114+ LOG .debug ("New check suite status received on commit {event.commit}" )
115+ cached = BUILD_STATUS_CACHE [status .key ].get (event .commit )
116+
117+ if not cached or cached .state != 'SUCCESSFUL' :
118+ BUILD_STATUS_CACHE [status .key ].set (event .commit , status )
114119
120+ if status .state == "INPROGRESS" :
121+ LOG .debug ("The build just started on %s, ignoring event" , event .commit )
122+ return
115123
116- def handle_github_check_suite_event (bert_e , json_data ):
117- event = github .CheckSuiteEvent (bert_e = bert_e .client , ** json_data )
118124 return CommitJob (bert_e = bert_e , commit = event .commit )
119125
120126
@@ -185,10 +191,8 @@ def parse_github_webhook():
185191 job = handle_github_pr_review_event (current_app .bert_e , json_data )
186192 elif event == 'status' :
187193 job = handle_github_status_event (current_app .bert_e , json_data )
188- elif event == 'check_run' :
189- job = handle_github_check_run_event (current_app .bert_e , json_data )
190194 elif event == 'check_suite' :
191- job = handle_github_check_run_event (current_app .bert_e , json_data )
195+ job = handle_github_check_suite_event (current_app .bert_e , json_data )
192196
193197 if job is None :
194198 LOG .debug ('Ignoring event.' )
0 commit comments