Skip to content

Commit da31232

Browse files
committed
refactor variable naming
1 parent 037bfb3 commit da31232

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

tools/ci_changes_per_commit.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
}
4040
"""
4141

42-
QUERY_CHECKRUNS = """
42+
QUERY_CHECK_RUNS = """
4343
query ($checkSuiteID: ID!,
4444
$afterFailedRun: String, $afterIncompleteRun: String,
4545
$includeFailedRuns: Boolean!, $includeIncompleteRuns: Boolean!) {
@@ -92,7 +92,7 @@
9292
}
9393

9494

95-
query_variables_checkruns = {
95+
query_variables_check_runs = {
9696
"checkSuiteID": "",
9797
"afterFailedRun": None,
9898
"afterIncompleteRun": None,
@@ -141,7 +141,7 @@ def set_output(name, value):
141141
print(f"Would set GitHub actions output {name} to '{value}'")
142142

143143

144-
def get_commit_and_checksuite(query_commits):
144+
def get_commit_and_check_suite(query_commits):
145145
commits = query_commits.fetch()["data"]["repository"]["pullRequest"]["commits"]
146146

147147
if commits["totalCount"] > 0:
@@ -150,17 +150,17 @@ def get_commit_and_checksuite(query_commits):
150150
commit_sha = commit["oid"]
151151
if commit_sha == os.environ["EXCLUDE_COMMIT"]:
152152
continue
153-
checksuites = commit["checkSuites"]
154-
if checksuites["totalCount"] > 0:
155-
for checksuite in checksuites["nodes"]:
156-
if checksuite["workflowRun"]["workflow"]["name"] == "Build CI":
153+
check_suites = commit["checkSuites"]
154+
if check_suites["totalCount"] > 0:
155+
for check_suite in check_suites["nodes"]:
156+
if check_suite["workflowRun"]["workflow"]["name"] == "Build CI":
157157
return [
158158
commit_sha,
159-
checksuite["id"] if checksuite["conclusion"] != "SUCCESS" else None,
159+
check_suite["id"] if check_suite["conclusion"] != "SUCCESS" else None,
160160
]
161161
else:
162162
if query_commits.paginate(commits["pageInfo"], "beforeCommit"):
163-
return get_commit_and_checksuite(query_commits)
163+
return get_commit_and_check_suite(query_commits)
164164

165165
return [None, None]
166166

@@ -180,22 +180,22 @@ def append_runs_to_list(runs, bad_runs_by_matrix):
180180
bad_runs_by_matrix[matrix].append(res_board.group()[1:-1])
181181

182182

183-
def get_bad_checkruns(query_checkruns):
183+
def get_bad_check_runs(query_check_runs):
184184
more_pages = True
185185
bad_runs_by_matrix = {}
186186
while more_pages:
187-
checkruns = query_checkruns.fetch()["data"]["node"]
187+
check_runs = query_check_runs.fetch()["data"]["node"]
188188
run_types = ["failed", "incomplete"]
189189
more_pages = False
190190

191191
for run_type in run_types:
192192
run_type_camel = run_type.capitalize() + "Run"
193193
run_type = run_type + "Runs"
194194

195-
append_runs_to_list(checkruns[run_type], bad_runs_by_matrix)
195+
append_runs_to_list(check_runs[run_type], bad_runs_by_matrix)
196196

197-
if query_checkruns.paginate(checkruns[run_type]["pageInfo"], "after" + run_type_camel):
198-
query_checkruns.variables["include" + run_type_camel] = True
197+
if query_check_runs.paginate(check_runs[run_type]["pageInfo"], "after" + run_type_camel):
198+
query_check_runs.variables["include" + run_type_camel] = True
199199
more_pages = True
200200

201201
return bad_runs_by_matrix
@@ -207,26 +207,26 @@ def main():
207207
"/"
208208
)
209209

210-
commit, checksuite = get_commit_and_checksuite(query_commits)
210+
commit, check_suite = get_commit_and_check_suite(query_commits)
211211

212-
if checksuite is None:
212+
if check_suite is None:
213213
if commit is None:
214-
print("No checkSuites found -> Abort")
214+
print("Abort: No check suite found")
215215
else:
216216
set_output("commit", commit)
217217
quit()
218218

219-
query_checkruns = Query(QUERY_CHECKRUNS, query_variables_checkruns, headers)
220-
query_checkruns.variables["checkSuiteID"] = checksuite
219+
query_check_runs = Query(QUERY_CHECK_RUNS, query_variables_check_runs, headers)
220+
query_check_runs.variables["checkSuiteID"] = check_suite
221221

222-
checkruns = get_bad_checkruns(query_checkruns)
222+
check_runs = get_bad_check_runs(query_check_runs)
223223

224-
if len(checkruns) == 0:
225-
print("No checkRuns found -> Abort")
224+
if len(check_runs) == 0:
225+
print("Abort: No check runs found")
226226
quit()
227227

228228
set_output("commit", commit)
229-
set_output("checkruns", json.dumps(checkruns))
229+
set_output("check_runs", json.dumps(check_runs))
230230

231231

232232
if __name__ == "__main__":

0 commit comments

Comments
 (0)