Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified: src/automerge.py #5

Merged
merged 11 commits into from
Dec 4, 2024
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
org: 'runtimeverification'
repo: ${{ matrix.value }}
token: ${{ secrets.JENKINS_GITHUB_PAT }}
token: ${{ secrets.AUTOMERGE_TOKEN }}
debug: --dry-run

- name: 'Automerge runtimeverification/${{ matrix.value }}'
Expand All @@ -46,7 +46,7 @@ jobs:
with:
org: 'runtimeverification'
repo: ${{ matrix.value }}
token: ${{ secrets.JENKINS_GITHUB_PAT }}
token: ${{ secrets.AUTOMERGE_TOKEN }}
debug: --dry-run
comment: 'true'

22 changes: 7 additions & 15 deletions src/automerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,13 @@ def run_git_command(command_args: str) -> subprocess.CompletedProcess:
for pr in automerge_prs:
base_branch = repo.get_branch(pr.base.ref)
if base_branch.protected:
required_status_checks = base_branch.get_required_status_checks()
latest_commit = pr.get_commits().reversed[0]
latest_commit_checks = {check_run.name: check_run for check_run in latest_commit.get_check_runs()}
all_checks_passed = True
for required_check in required_status_checks.contexts:
if required_check not in latest_commit_checks:
print(f"Required check {required_check} is missing in the latest commit.")
all_checks_passed = False
else:
check_run = latest_commit_checks[required_check]
if check_run.conclusion == 'success':
print(f"Required check {required_check} passed on PR#{pr.number}")
else:
print(f"Required check {required_check} failed or is pending on PR#{pr.number}")
all_checks_passed = False
commit = pr.get_commits().reversed[0]
statuses = commit.get_statuses()
all_checks_passed = all(print(status) for status in statuses)
tothtamas28 marked this conversation as resolved.
Show resolved Hide resolved
list_statuses = [status.state for status in statuses]

if not all_checks_passed:
_LOGGER.info(f"Checks are not passing ({list_statuses[-1]}) on PR#{pr.number}")
commit = [c for c in pr.get_commits() if c.sha == pr.head.sha][0]
combined_status = commit.get_combined_status().state
if pr.mergeable_state == 'clean' and all_checks_passed:
Expand Down