Optionally limit github to protected branches
When using a branch and pull model on a shared repository there are
usually one or more protected branches which are gated and a dynamic
number of temporary personal/feature branches which are the source for
the pull requests. These temporary branches while ungated can
potentially include broken zuul config and therefore break the global
tenant wide configuration.
In order to deal with this model add support for excluding unprotected
branches. This can be configured on tenant level and overridden per
project.
Change-Id: I8a45fd41539a3c964a84142f04c1644585c0fdcf
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index 0e199df..68fbe29 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -683,3 +683,20 @@
self.fake_github.emitEvent,
('ping', pevent),
)
+
+
+class TestGithubUnprotectedBranches(ZuulTestCase):
+ config_file = 'zuul-github-driver.conf'
+ tenant_config_file = 'config/unprotected-branches/main.yaml'
+
+ def test_unprotected_branches(self):
+ tenant = self.sched.abide.tenants.get('tenant-one')
+
+ project1 = tenant.untrusted_projects[0]
+ project2 = tenant.untrusted_projects[1]
+
+ # project1 should have parsed master
+ self.assertIn('master', project1.unparsed_branch_config.keys())
+
+ # project2 should have no parsed branch
+ self.assertEqual(0, len(project2.unparsed_branch_config.keys()))