Skip to content

Commit b333aad

Browse files
authored
Merge pull request #1218 from cloudfoundry/non-opt-in-branch-protection
Apply RFC0015 branch protection by default
2 parents 47a725a + fc0a818 commit b333aad

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

orgs/org_management.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,17 @@ def generate_teams(self):
192192

193193
def generate_branch_protection(self):
194194
# basis is static config in self.branch_protection which is never overwritten
195-
# generate RFC0015 branch protection rules for every WG+TOC that opted in
195+
# generate RFC0015 branch protection rules for every WG+TOC by default
196196
for org in OrgGenerator._MANAGED_ORGS:
197197
branch_protection_repos = self.branch_protection["branch-protection"]["orgs"][org]["repos"]
198198
wgs = self.working_groups[org]
199199
if org == self.toc["org"]:
200200
wgs.append(self.toc)
201201
for wg in wgs:
202-
if wg.get("config", {}).get("generate_rfc0015_branch_protection_rules", False): # config is optional
203-
repo_rules = self._generate_wg_branch_protection(wg)
204-
for repo in repo_rules:
205-
if repo not in branch_protection_repos:
206-
branch_protection_repos[repo] = repo_rules[repo]
202+
repo_rules = self._generate_wg_branch_protection(wg)
203+
for repo in repo_rules:
204+
if repo not in branch_protection_repos:
205+
branch_protection_repos[repo] = repo_rules[repo]
207206

208207
def write_org_config(self, path: str):
209208
print(f"Writing org configuration to {path}")

orgs/test_org_management.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@
164164
bots:
165165
- github: bot-wg1-a5
166166
name: WG3 Area5 Bot
167-
config:
168-
generate_rfc0015_branch_protection_rules: true
169167
"""
170168

171169
wg4_other_org = """
@@ -206,8 +204,6 @@
206204
- cloudfoundry2/repo3
207205
- cloudfoundry2/repo4
208206
- cloudfoundry/repo5
209-
config:
210-
generate_rfc0015_branch_protection_rules: true
211207
"""
212208

213209
toc = """
@@ -231,7 +227,6 @@
231227
repositories:
232228
- cloudfoundry/community
233229
config:
234-
generate_rfc0015_branch_protection_rules: true
235230
github_project_sync:
236231
mapping:
237232
cloudfoundry: 31
@@ -732,8 +727,8 @@ def test_generate_branch_protection(self):
732727
bp_repos = o.branch_protection["branch-protection"]["orgs"]["cloudfoundry"]["repos"]
733728
# TOC and wg3 opted in, wg1 and wg2 not
734729
# note: repo1..4 are shared between wg1 (opt out) and wg3 (opt in) - wg3 wins
735-
self.assertSetEqual({f"repo{i}" for i in range(1, 6)} | {"community"}, set(bp_repos.keys()))
736-
# repo1 has static config that wins over generated branch protection rules
730+
self.assertSetEqual({f"repo{i}" for i in list(range(1, 6)) + [10, 11]} | {"community"}, set(bp_repos.keys()))
731+
# repo1 has static config that wins over generated branch protection rulesp
737732
self.assertTrue(bp_repos["repo1"]["protect"])
738733
self.assertNotIn("required_pull_request_reviews", bp_repos["repo1"])
739734

@@ -749,7 +744,7 @@ def test_generate_branch_protection_multiple_orgs(self):
749744
bp_repos = o.branch_protection["branch-protection"]["orgs"]["cloudfoundry"]["repos"]
750745
# TOC and wg3 opted in, wg1 and wg2 not
751746
# note: repo1..4 are shared between wg1 (opt out) and wg3 (opt in) - wg3 wins
752-
self.assertSetEqual({f"repo{i}" for i in range(1, 6)} | {"community"}, set(bp_repos.keys()))
747+
self.assertSetEqual({f"repo{i}" for i in list(range(1, 6)) + [10, 11]} | {"community"}, set(bp_repos.keys()))
753748
# repo1 has static config that wins over generated branch protection rules
754749
self.assertTrue(bp_repos["repo1"]["protect"])
755750
self.assertNotIn("required_pull_request_reviews", bp_repos["repo1"])

toc/rfc/rfc-0015-branch-protection.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ With respect to the approval of pull requests, we propose that the number of app
3737
* 1 approval will be required when a working group has 4 or more people in the approver role.
3838

3939
The automation should allow to override the standard branch protection per respository using a configuration file maintained in this community repository. This allows working group leads e.g. to reduce the number of required approvals if several approvers are temporarily not available.
40+
41+
## Amendments
42+
43+
### Protection by Default
44+
45+
To improve the security posture of the foundation, the branch protection rules defined in this RFC are applied by default to all repositories of all Working Groups. The previous opt-in mechanism via a flag in Working Group charters is removed.
46+
47+
Working Groups can request exceptions for specific repositories by creating a pull request against `orgs/branchprotection.yml`. The pull request description MUST contain a justification for the exception.

toc/working-groups/app-runtime-deployments.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,4 @@ areas:
8181
- cloudfoundry/relint-team
8282
- cloudfoundry/runtime-ci
8383
- cloudfoundry/uptimer
84-
config:
85-
generate_rfc0015_branch_protection_rules: true
8684
```

toc/working-groups/app-runtime-interfaces.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,4 @@ areas:
525525
repositories:
526526
- cloudfoundry/stratos
527527
- cloudfoundry/stratos-buildpack
528-
529-
config:
530-
generate_rfc0015_branch_protection_rules: true
531528
```

toc/working-groups/app-runtime-platform.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ bots:
5454
- name: Cryogenics CI bot
5555
github: Cryogenics-CI
5656
config:
57-
generate_rfc0015_branch_protection_rules: true
5857
github_project_sync:
5958
mapping:
6059
cloudfoundry: 41

toc/working-groups/cf-on-k8s.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ technical_leads:
3838
bots:
3939
- name: korifi-bot
4040
github: korifi-bot
41-
config:
42-
generate_rfc0015_branch_protection_rules: true
4341
areas:
4442
- name: Korifi
4543
approvers:

0 commit comments

Comments
 (0)