[llvm] [Github] Make prune-unused-branches workflow save branch list (PR #181194)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 09:54:51 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-github-workflow
Author: Aiden Grossman (boomanaiden154)
<details>
<summary>Changes</summary>
So that we can retrieve it later to only download branches that are more than a day old. This prevents unlikely but potential race conditions for tools like spr and graphite, but more importantly for people manually creating user branches where there branch getting deleted by the workflow would be surprising.
---
Full diff: https://github.com/llvm/llvm-project/pull/181194.diff
2 Files Affected:
- (modified) .github/workflows/prune-branches.yml (+7-1)
- (modified) .github/workflows/prune-unused-branches.py (+5-2)
``````````diff
diff --git a/.github/workflows/prune-branches.yml b/.github/workflows/prune-branches.yml
index 73a1e6a97bee8..a96da966ed7d2 100644
--- a/.github/workflows/prune-branches.yml
+++ b/.github/workflows/prune-branches.yml
@@ -30,10 +30,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir patches
- python3 .github/workflows/prune-unused-branches.py patches/
+ python3 .github/workflows/prune-unused-branches.py .
- name: Upload Patches
uses: actions/upload-artifact at b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: BranchDiffs
retention-days: 90
path: patches/*.patch
+ - name: Upload Branch List
+ uses: actions/upload-artifact at b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
+ with:
+ name: BranchDiffs
+ retention-days: 90
+ path: branches.txt
diff --git a/.github/workflows/prune-unused-branches.py b/.github/workflows/prune-unused-branches.py
index ac8d87f4241e0..2ae88b08f9386 100644
--- a/.github/workflows/prune-unused-branches.py
+++ b/.github/workflows/prune-unused-branches.py
@@ -121,11 +121,14 @@ def delete_branches(branches_to_remove: list[str]):
def main(github_token):
if len(sys.argv) != 2:
print(
- "Invalid invocation. Correct usage: python3 prune-unused-branches.py <patch output diectory>"
+ "Invalid invocation. Correct usage: python3 prune-unused-branches.py <output diectory>"
)
sys.exit(1)
user_branches = get_branches()
+ output_dir = sys.argv[1]
+ with open(os.path.join(output_dir, "branches.txt"), "w") as branches_file:
+ branches_file.writelines(user_branches)
user_branches_from_prs = get_branches_from_open_prs(github_token)
print(f"Found {len(user_branches)} user branches in the repository")
print(f"Found {len(user_branches_from_prs)} user branches associated with PRs")
@@ -133,7 +136,7 @@ def main(github_token):
user_branches, user_branches_from_prs
)
print(f"Deleting {len(user_branches_to_remove)} user branches.")
- generate_patches_for_all_branches(user_branches_to_remove, sys.argv[1])
+ generate_patches_for_all_branches(user_branches_to_remove, os.path.join(output_dir, "patches"))
delete_branches(user_branches_to_remove)
``````````
</details>
https://github.com/llvm/llvm-project/pull/181194
More information about the llvm-commits
mailing list