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

feat(ci): add stale branch workflow #12858

Merged
merged 5 commits into from
Feb 4, 2025
Merged

Conversation

rjan90
Copy link
Contributor

@rjan90 rjan90 commented Jan 29, 2025

Proposed Changes

Add a workflow that marks stale branches and deletes stale branches:

  • Branches are marked as stale after 180 days without no commits.
  • Branch that have been inactive for 360 days is deleted.
  • Has no protection rules.
  • Exclude any branch that starts with 'release/miner' as these have no branch protection rules (ref)
  • Is not the default branch

Checklist

Before you mark the PR ready for review, please make sure that:

ci: add stale branch workflow
@rjan90 rjan90 added the skip/changelog This change does not require CHANGELOG.md update label Jan 29, 2025
Copy link
Member

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

I'm good to merge, but a couple of questions coming to mind:

  1. What does denoting a branch as "stale" do?
  2. What kind of communication is there that a branch is about to be deleted?

.github/workflows/stale-branches Outdated Show resolved Hide resolved
rjan90 and others added 2 commits January 30, 2025 07:47
chore: update regex-filter
@rvagg
Copy link
Member

rvagg commented Jan 30, 2025

let's land it with dry-run and observe the output the first time it runs and see if there are any surprises

@rjan90
Copy link
Contributor Author

rjan90 commented Jan 30, 2025

Agree on landing it with dry-run initially so that we can inspect the logs of the workflow firs. After diving deeper into the workflow today to answer some of Steve's questions, it also seems like an initial manual cleanup of the branches would be the best approach before landing this workflow, as well as some additional parameter tweaks:

  • The difference between GitHub's definition of a stale branch and this workflows definition of a stale branch, is that once a branch is defined as stale by this bot (the days-before-stale param):
    • It creates a GH issue in the repo and tags the author saying that their branch is stale, and that it will be closed in (days-before-stale - days-before-delete)
    • If the author deletes, or add branch protection, their stale branch on their own, the issue will be closed automatically. If the author does not delete their stale branch, their branch will be deleted after the XY-amount of days from issue creation to deletion.

Given that we have 600+ branches, and most of these branches already are stale, it could quickly get a bit spammy without a initial cleanup, although the max amount of of stale branch issues that can exist at the same time is 20.

I will start with the manual cleanup, and then tweak the parameters.

@BigLep
Copy link
Member

BigLep commented Jan 30, 2025

All sounds good @rjan90 . Also, I think it probably makes sense to document what some of the default are in the workflow (e.g., protoected branches excluded) or just add the value explicitly in so it's self documenting.

chore: document values in workflow
@rjan90
Copy link
Contributor Author

rjan90 commented Feb 3, 2025

I have updated the workflow with comments and explicitly set defaults to make it more self-descriptive. The 'dry-run' option has been set to true, allowing us to observe the behavior first.

Additionally, I have completed an initial cleanup of old branches, reducing the total from 647 to 161.

@rjan90 rjan90 self-assigned this Feb 3, 2025
@rjan90 rjan90 merged commit e4ea131 into master Feb 4, 2025
82 checks passed
@rjan90 rjan90 deleted the phi/stale-branches-workflow branch February 4, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip/changelog This change does not require CHANGELOG.md update
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging this pull request may close these issues.

4 participants