Fix regex project templates
* The simple_layout test fixture needs to avoid creating a project for "regex" projects (ie, don't create a git reponamed "^.*$"). * Add some missing attributes to the ProjectConfig copy method, which could cause the config to error if a regex project added a template. * Add tests to exercise regex project templates. Change-Id: I821a70fc6b93ce6da3145eda03ff6570b5410dba
This commit is contained in:
parent
76ad900d17
commit
1feb1d3016
|
@ -2382,6 +2382,8 @@ class ZuulTestCase(BaseTestCase):
|
|||
for item in layout:
|
||||
if 'project' in item:
|
||||
name = item['project']['name']
|
||||
if name.startswith('^'):
|
||||
continue
|
||||
untrusted_projects.append(name)
|
||||
self.init_repo(name)
|
||||
self.addCommitToRepo(name, 'initial commit',
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
- pipeline:
|
||||
name: gate
|
||||
manager: dependent
|
||||
trigger: {}
|
||||
|
||||
- job:
|
||||
name: base
|
||||
parent: null
|
||||
run: playbooks/base.yaml
|
||||
|
||||
- project:
|
||||
name: ^.*$
|
||||
gate:
|
||||
queue: integrated
|
||||
jobs:
|
||||
- base
|
||||
|
||||
- project:
|
||||
name: org/project1
|
||||
|
||||
- project:
|
||||
name: org/project2
|
|
@ -0,0 +1,27 @@
|
|||
- pipeline:
|
||||
name: gate
|
||||
manager: dependent
|
||||
trigger: {}
|
||||
|
||||
- job:
|
||||
name: base
|
||||
parent: null
|
||||
run: playbooks/base.yaml
|
||||
|
||||
- project-template:
|
||||
name: integrated-jobs
|
||||
gate:
|
||||
queue: integrated
|
||||
jobs:
|
||||
- base
|
||||
|
||||
- project:
|
||||
name: ^.*$
|
||||
templates:
|
||||
- integrated-jobs
|
||||
|
||||
- project:
|
||||
name: org/project1
|
||||
|
||||
- project:
|
||||
name: org/project2
|
|
@ -2741,7 +2741,29 @@ class TestScheduler(ZuulTestCase):
|
|||
|
||||
@simple_layout("layouts/template-queue.yaml")
|
||||
def test_template_queue(self):
|
||||
"Test a shared queue can be constructed from a preject-template"
|
||||
"Test a shared queue can be constructed from a project-template"
|
||||
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||
(trusted, project1) = tenant.getProject('org/project1')
|
||||
(trusted, project2) = tenant.getProject('org/project2')
|
||||
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
|
||||
q2 = tenant.layout.pipelines['gate'].getQueue(project2)
|
||||
self.assertEqual(q1.name, 'integrated')
|
||||
self.assertEqual(q2.name, 'integrated')
|
||||
|
||||
@simple_layout("layouts/regex-template-queue.yaml")
|
||||
def test_regex_template_queue(self):
|
||||
"Test a shared queue can be constructed from a regex project-template"
|
||||
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||
(trusted, project1) = tenant.getProject('org/project1')
|
||||
(trusted, project2) = tenant.getProject('org/project2')
|
||||
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
|
||||
q2 = tenant.layout.pipelines['gate'].getQueue(project2)
|
||||
self.assertEqual(q1.name, 'integrated')
|
||||
self.assertEqual(q2.name, 'integrated')
|
||||
|
||||
@simple_layout("layouts/regex-queue.yaml")
|
||||
def test_regex_queue(self):
|
||||
"Test a shared queue can be constructed from a regex project"
|
||||
tenant = self.sched.abide.tenants.get('tenant-one')
|
||||
(trusted, project1) = tenant.getProject('org/project1')
|
||||
(trusted, project2) = tenant.getProject('org/project2')
|
||||
|
|
|
@ -2512,6 +2512,12 @@ class ProjectConfig(ConfigObject):
|
|||
# Pipeline name -> ProjectPipelineConfig
|
||||
self.pipelines = {}
|
||||
self.branch_matcher = None
|
||||
# These represent the values from the config file, but should
|
||||
# not be used directly; instead, use the ProjectMetadata to
|
||||
# find the computed value from across all project config
|
||||
# stanzas.
|
||||
self.merge_mode = None
|
||||
self.default_branch = None
|
||||
|
||||
def copy(self):
|
||||
r = self.__class__(self.name)
|
||||
|
@ -2520,6 +2526,8 @@ class ProjectConfig(ConfigObject):
|
|||
r.templates = self.templates
|
||||
r.pipelines = self.pipelines
|
||||
r.branch_matcher = self.branch_matcher
|
||||
r.merge_mode = self.merge_mode
|
||||
r.default_branch = self.default_branch
|
||||
return r
|
||||
|
||||
def addImpliedBranchMatcher(self, branch):
|
||||
|
|
Loading…
Reference in New Issue