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

Apply branch protection to our repos #198

Closed
maxime-rainville opened this issue Feb 18, 2024 · 16 comments
Closed

Apply branch protection to our repos #198

maxime-rainville opened this issue Feb 18, 2024 · 16 comments
Assignees

Comments

@maxime-rainville
Copy link
Contributor

maxime-rainville commented Feb 18, 2024

Acceptance criteria

  • Branch protections are applied to patch release branch, minor release branches and major release branches.
  • Ability to manually tag releases is restricted.
  • Ability for CI to auto-merge up and auto-tag patch releases is retained.
  • Ability for COW to tag releases is retained and release process is updated accordingly.
  • Module standardiser is updated so it can set up branch protection.
  • Documentation about repository management is updated to reflect these changes

Notes (already decided)

  • Who should have manual tagging access?
    • People doing releases (aka Guy and Steve)
  • Which rules are included in "branch protections"?
    • See screenshot below

Related card

PRs

@GuySartorelli GuySartorelli changed the title Apply branch rotectiong Apply branch protection to our repos Feb 18, 2024
@maxime-rainville
Copy link
Contributor Author

Still need to identify exactly what branch protection we need and to which groups they should apply.

@maxime-rainville
Copy link
Contributor Author

We concluded those are the branch and tag protection that should be enabled on all our supported repos.

Branch protection

image

Tag protection

image

@emteknetnz
Copy link
Member

github-actions seems to be pretty easy to handle, it seems like have the "Organisation admin" role meaning we can use that (or the lower "Repository admin", "Maintain", or "Write" roles) as a bypass for any rulesets

I tested this by using the gha-tag-release action on a test repo on my personal account that has a tag ruleset applied to it. Without the bypass I got a 422, though with the "Organisation admin" role as a bypass the github-actions user was able to do its thing

@emteknetnz
Copy link
Member

emteknetnz commented May 22, 2024

I've created a PR to update module standardiser to update the rulesets, though I haven't run it yet since we probably need to update all the users first

Once we run the new module-standardariser ruleset command, PRs will now requires to 2 approvers to merge unless your role has enough permissions to bypass

I've put this into peer review with the assumption that there are too many ACs on this card, which I've now split into 3 categories, and we should later move this card back into refinement.

@emteknetnz emteknetnz removed their assignment May 22, 2024
@GuySartorelli
Copy link
Member

Looks like @maxime-rainville probably needs to take a look and decide whether the core committer stuff should be removed from this card (probably handle it in silverstripeltd/product-issues#842 instead).

We don't want to do part of a card, and then move the card into refinement.

@maxime-rainville
Copy link
Contributor Author

maxime-rainville commented May 28, 2024

Can core commiter still approved and merge things with branch protection on? Do they need to a second approver?

I would like to remove ownership from external core committers, but at the same time I want to make sure we don't end up just treating them as regular reviewers.

If that's the case, I'm fine with closing this card and carrying the conversation on the next one.

@GuySartorelli
Copy link
Member

GuySartorelli commented May 28, 2024

Right now core committers are owners, so they can do whatever the heck they want. 😅

There are at least two separate cards talking about changing what core committers can do. I reocmmend we deal with changing their access separately from introducing these branch protection rules.

@maxime-rainville
Copy link
Contributor Author

Me satisfied.

@maxime-rainville
Copy link
Contributor Author

Actually lets apply branch protection first.

@emteknetnz
Copy link
Member

Having a second look, there's also the "regular branch protection" that's already on all the supported repos - e.g. https://github.com/silverstripe/silverstripe-admin/settings/branches

I think this should remain as is with the the existing pattern match to prevent accidental deletion of existing 2 / 2.1 style branches. If we don't keep it then admins can accidentally delete the branches despite the new branch rulesset that restricts deletion because admins will have bypass permissions.

Even without the checking the tickbox "Do not allow bypassing the above settings - The above settings will apply to administrators and custom roles with the "bypass branch protections" permission.", I was unable to delete a 1 branch on a test repo that I setup on my personal account where I would have been an admin. On that repo I had a new branch ruleset that restricted deletions though it had a bypass for "Repository admin"

@GuySartorelli
Copy link
Member

Yup, I think the implication is that this card is just to add additional branch protection on top of whatever is already there.

@emteknetnz
Copy link
Member

emteknetnz commented May 28, 2024

Annoyingly there isn't a REST api endpoint available to update the old fashioned branch protection using an fnmatch pattern, you can only update it for existing branches.

I've gone and manually checked and updated branch protection for the list of supported modules in repositories.json (all 138 of them) and ensured there is branch protection. I added branch protection for a couple of dozen for the newer or peripheral modules that did not have it

However I was unable to access the repo settings to do this for all o f the non-silverstripe account repos such as symbiote, so presumably we probably also won't be able to add the branch/tag rulesets for them via the API either

@emteknetnz emteknetnz removed their assignment May 28, 2024
@GuySartorelli
Copy link
Member

@emteknetnz I'm confused about the status of this now - there's a PR but you can't automate it and have already applied the branch protection manually?

Annoyingly there isn't a REST api endpoint available to update the old fashioned branch protection using an fnmatch pattern, you can only update it for existing branches.

Does this mean we can't automate applying branch protection rules at all?

However I was unable to access the repo settings to do this for all o f the non-silverstripe account repos such as symbiote, so presumably we probably also won't be able to add the branch/tag rulesets for them via the API either

So are all of the branch protection rules applied now?

@emteknetnz
Copy link
Member

There are two types of branch protection

  1. Regular branch protection, which is what we have now e.g. https://github.com/silverstripe/silverstripe-framework/settings/branches - these are what I just manually updated
  2. Branch protection rulesets - which is what module-standardiser will update via the REST API - it's what the PR is for - it will add the rulesets for branches and tags here https://github.com/silverstripe/silverstripe-framework/settings/rules

@GuySartorelli
Copy link
Member

GuySartorelli commented May 29, 2024

PRs merged. Reassigning to Steve to run the new command in standardiser

@emteknetnz
Copy link
Member

Have run module-standariser, went smoothly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants