Skip to content

[Github] Make prune-unused-branches only delete branches after 7 days#205438

Merged
boomanaiden154 merged 2 commits into
mainfrom
users/boomanaiden154/github-make-prune-unused-branches-only-delete-branches-after-7-days
Jun 23, 2026
Merged

[Github] Make prune-unused-branches only delete branches after 7 days#205438
boomanaiden154 merged 2 commits into
mainfrom
users/boomanaiden154/github-make-prune-unused-branches-only-delete-branches-after-7-days

Conversation

@boomanaiden154

Copy link
Copy Markdown
Contributor

To hopefully prevent the last failure mode that led to the job being
disabled where the GitHub API failed to return results for >24 hours.

Created using spr 1.3.7
Created using spr 1.3.7
@boomanaiden154 boomanaiden154 marked this pull request as ready for review June 23, 2026 21:51
@boomanaiden154 boomanaiden154 requested a review from cmtice June 23, 2026 21:51
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-github-workflow

Author: Aiden Grossman (boomanaiden154)

Changes

To hopefully prevent the last failure mode that led to the job being
disabled where the GitHub API failed to return results for >24 hours.


Full diff: https://github.com/llvm/llvm-project/pull/205438.diff

1 Files Affected:

  • (modified) .github/workflows/prune-unused-branches.py (+9-2)
diff --git a/.github/workflows/prune-unused-branches.py b/.github/workflows/prune-unused-branches.py
index 3115b4424fb57..25b3146936b46 100644
--- a/.github/workflows/prune-unused-branches.py
+++ b/.github/workflows/prune-unused-branches.py
@@ -1,3 +1,4 @@
+import datetime
 import subprocess
 import sys
 import os
@@ -165,8 +166,14 @@ def get_branches_found_in_previous_run(github_token: str) -> list[str]:
     for workflow_run in iter(
         repo.get_workflow("prune-branches.yml").get_runs(branch="main")
     ):
-        if workflow_run.status == "completed":
-            break
+        if not workflow_run.status == "completed":
+            continue
+        cutoff = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(
+            days=7
+        )
+        if workflow_run.run_started_at > cutoff:
+            continue
+        break
     assert workflow_run
     workflow_artifact = None
     for workflow_artifact in iter(workflow_run.get_artifacts()):

)
if workflow_run.run_started_at > cutoff:
continue
break

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'break' is unconditional now; was that intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We now early exit for all the conditions where we want to continue.

@boomanaiden154 boomanaiden154 requested a review from cmtice June 23, 2026 22:16
@boomanaiden154 boomanaiden154 merged commit bdc00c2 into main Jun 23, 2026
19 checks passed
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/github-make-prune-unused-branches-only-delete-branches-after-7-days branch June 23, 2026 23:50
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jun 24, 2026
…fter 7 days

To hopefully prevent the last failure mode that led to the job being
disabled where the GitHub API failed to return results for >24 hours.

Reviewers: cmtice

Pull Request: llvm/llvm-project#205438
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 24, 2026
…fter 7 days

To hopefully prevent the last failure mode that led to the job being
disabled where the GitHub API failed to return results for >24 hours.

Reviewers: cmtice

Pull Request: llvm/llvm-project#205438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants