1
1
import re
2
2
3
3
import gidgethub
4
-
5
4
from gidgethub import routing
6
5
7
6
from . import util
@@ -94,12 +93,22 @@ async def check_ci_status_and_approval(
94
93
95
94
result = await gh .getitem (f"/repos/python/cpython/commits/{ sha } /status" )
96
95
all_ci_status = [status ["state" ] for status in result ["statuses" ]]
97
- all_ci_context = [status ["context" ] for status in result ["statuses" ]]
96
+
97
+ check_runs = await util .get_check_runs_for_sha (gh , sha )
98
+
99
+ all_check_run_status = [
100
+ check_run ["status" ] for check_run in check_runs ["check_runs" ]
101
+ ]
102
+ all_check_run_conclusions = [
103
+ check_run ["conclusion" ] for check_run in check_runs ["check_runs" ]
104
+ ]
98
105
99
106
if (
100
107
"pending" not in all_ci_status
101
- and "continuous-integration/travis-ci/pr" in all_ci_context
102
- ):
108
+ and "in_progress" not in all_check_run_status
109
+ and "queued" not in all_check_run_status
110
+ ): # wait until all status and check runs are completed
111
+
103
112
if not pr_for_commit :
104
113
pr_for_commit = await util .get_pr_for_commit (gh , sha )
105
114
if pr_for_commit :
@@ -110,6 +119,10 @@ async def check_ci_status_and_approval(
110
119
111
120
title_match = TITLE_RE .match (normalized_pr_title )
112
121
if title_match or is_automerge :
122
+ success = result ["state" ] == "success" and not any (
123
+ elem in [None , "failure" , "timed_out" ]
124
+ for elem in all_check_run_conclusions
125
+ )
113
126
if leave_comment :
114
127
if is_automerge :
115
128
participants = await util .get_gh_participants (gh , pr_number )
@@ -118,16 +131,16 @@ async def check_ci_status_and_approval(
118
131
participants = await util .get_gh_participants (
119
132
gh , original_pr_number
120
133
)
121
-
122
- emoji = "✅" if result ["state" ] == "success" else "❌"
123
-
134
+ if success :
135
+ emoji = "✅"
136
+ else :
137
+ emoji = "❌"
124
138
await util .leave_comment (
125
139
gh ,
126
140
pr_number = pr_number ,
127
141
message = f"{ participants } : Status check is done, and it's a { result ['state' ]} { emoji } ." ,
128
142
)
129
- if result ["state" ] == "success" :
130
-
143
+ if success :
131
144
if util .pr_is_awaiting_merge (pr_for_commit ["labels" ]):
132
145
await merge_pr (
133
146
gh , pr_for_commit , sha , is_automerge = is_automerge
0 commit comments