Skip to content

Commit 04d0b03

Browse files
committed
add mock for statuses
1 parent 9604f39 commit 04d0b03

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/bots_automerge.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
def is_ci_bot(api: github.GitHub, pr: int) -> bool:
3838
author = api.get_author(pr)
39+
print(author)
3940
login = get_str(author, 'login')
4041
login_id = get_int(author, 'id')
4142

@@ -45,16 +46,17 @@ def is_ci_bot(api: github.GitHub, pr: int) -> bool:
4546

4647
def all_checks_pass(api: github.GitHub, commit_hash: str) -> bool:
4748
statuses = api.statuses(commit_hash)
49+
print(f"STATUSES: {statuses}")
4850

49-
logger.info("Checking statuses:")
51+
print("Checking statuses:")
5052
if len(statuses) == 0:
51-
logger.info("No statuses found for commit %s", commit_hash)
53+
print("No statuses found for commit %s", commit_hash)
5254
return False
5355

5456
for context in statuses:
5557
status = statuses[context]
5658
status_state = get_str(status, 'state')
57-
logger.info("Status for context '%s': %s", context, status_state)
59+
print("Status for context '%s': %s", context, status_state)
5860
if status_state != 'success':
5961
return False
6062

@@ -71,9 +73,10 @@ def auto_merge_bots_pr(repo: str, pr: int, sha: str) -> None:
7173
# return
7274

7375
# check that all checks are green
74-
print(f"all_checks_pass: {all_checks_pass(api, sha)}")
75-
if not all_checks_pass(api, sha):
76-
logger.info("Not every check has passed, skipping automerge")
76+
all_pass = all_checks_pass(api, sha)
77+
print(f"all_checks_pass: {all_pass}")
78+
if not all_pass:
79+
print("Not every check has passed, skipping automerge")
7780
return
7881

7982
logger.info("All checks green, can automerge")

task/github.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def statuses(self, revision: str) -> Mapping[str, JsonObject]:
336336
data = self.get_obj(f"commits/{revision}/status?page={page}&per_page={count}")
337337
count = 0
338338
page += 1
339+
print(f"DATA: {data}")
339340
for status in get_dictv(data, "statuses", ()):
340341
context = get_str(status, "context")
341342
if is_valid_context(context, self.repo) and context not in result:
@@ -422,6 +423,7 @@ def get_head(self, pr: int) -> str | None:
422423

423424
def get_author(self, pr: int) -> JsonObject:
424425
pull = self.get_pr_info(pr)
426+
print(f"PR INFO: {pull}")
425427
return get_dict(pull, "user", {})
426428

427429
def approve_pr(self, pr: int, sha: str) -> None:

0 commit comments

Comments
 (0)