fix(main-red-watchdog): close stale issues on pending+success; re-add token scope fix #1367

Closed
core-devops wants to merge 1 commits from fix/main-red-watchdog-close-on-pending into main
2 changed files with 19 additions and 6 deletions
+11 -4
View File
@@ -581,7 +581,14 @@ def run_once(*, dry_run: bool = False) -> int:
# from earlier SHAs only when we're actually green; pending
# means CI hasn't finished and the prior issue might still be
# accurate.
if status.get("state") == "success":
if status.get("state") in ("success", "pending"):
# Close stale main-red issues when main has no failures.
# `pending` is included because Gitea combined-state can stay
# `pending` even when all observable individual statuses are
# successful (some jobs still running). The `is_red()` check
# already confirmed 0 failures — closing on `pending` prevents
# stale issues from persisting across cron ticks while
# long-running jobs finish.
closed = close_open_red_issues_for_other_shas(sha, dry_run=dry_run)
if closed:
emit_loki_event(
@@ -589,10 +596,10 @@ def run_once(*, dry_run: bool = False) -> int:
[],
)
print(f"::notice::main is GREEN at {sha[:10]} on {WATCH_BRANCH} "
f"(closed {closed} stale issue(s))")
f"(closed {closed} stale issue(s), combined={status.get('state')})")
else:
print(f"::notice::main is PENDING at {sha[:10]} on {WATCH_BRANCH} "
f"(combined state={status.get('state')!r}; no action)")
print(f"::notice::main is RED/ERROR at {sha[:10]} on {WATCH_BRANCH} "
f"(combined state={status.get('state')!r})")
return 0
+8 -2
View File
@@ -70,7 +70,10 @@ jobs:
- name: Refire qa-review status
if: steps.classify.outputs.run_qa == 'true'
env:
GITEA_TOKEN: ${{ secrets.RFC_324_TEAM_READ_TOKEN || secrets.GITHUB_TOKEN }}
# RFC_324_TEAM_READ_TOKEN is read-only (team membership read scope only).
# review-refire-status.sh POSTs to /statuses — requires write scope.
# SOP_TIER_CHECK_TOKEN carries write:repository + write:issue + read:organization.
GITEA_TOKEN: ${{ secrets.SOP_TIER_CHECK_TOKEN || secrets.GITHUB_TOKEN }}
GITEA_HOST: git.moleculesai.app
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
@@ -87,7 +90,10 @@ jobs:
- name: Refire security-review status
if: steps.classify.outputs.run_security == 'true'
env:
GITEA_TOKEN: ${{ secrets.RFC_324_TEAM_READ_TOKEN || secrets.GITHUB_TOKEN }}
# RFC_324_TEAM_READ_TOKEN is read-only (team membership read scope only).
# review-refire-status.sh POSTs to /statuses — requires write scope.
# SOP_TIER_CHECK_TOKEN carries write:repository + write:issue + read:organization.
GITEA_TOKEN: ${{ secrets.SOP_TIER_CHECK_TOKEN || secrets.GITHUB_TOKEN }}
GITEA_HOST: git.moleculesai.app
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}