Merge "Items in extra paths should be loaded in dependent changes"

This commit is contained in:
Zuul 2022-03-22 12:38:36 +00:00 committed by Gerrit Code Review
commit 4bc161ac29
7 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,2 @@
- job:
name: project2-private-extra-file

View File

@ -0,0 +1,6 @@
- project:
name: org/project2
check:
jobs:
- project2-private-extra-file
- project2-private-extra-dir

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,2 @@
- job:
name: project2-private-extra-dir

View File

@ -8,6 +8,10 @@
- org/project
- org/project1:
exclude: project
- org/project2:
extra-config-paths:
- .extra.yaml
- extra.d/
- tenant:
name: tenant-two

View File

@ -2880,6 +2880,41 @@ class TestInRepoConfigDir(ZuulTestCase):
], ordered=True)
class TestExtraConfigInDependent(ZuulTestCase):
# in org/project2, jobs are defined in extra config paths, while
# project is defined in .zuul.yaml
tenant_config_file = 'config/in-repo-dir/main.yaml'
scheduler_count = 1
def test_extra_config_in_dependent_change(self):
# Test that when jobs are defined in a extra-config-paths in a repo, if
# another change is dependent on a change of that repo, the jobs should
# still be loaded.
# Add an empty zuul.yaml here so we are triggering dynamic layout load
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
files={'zuul.yaml': ''})
B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B',
files={'zuul.yaml': ''})
# A Depends-On: B who has private jobs defined in extra-config-paths
A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
A.subject, B.data['url'])
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
# Jobs in both changes should be success
self.assertHistory([
dict(name='project2-private-extra-file', result='SUCCESS',
changes='2,1'),
dict(name='project2-private-extra-dir', result='SUCCESS',
changes='2,1'),
dict(name='project-test1', result='SUCCESS',
changes='2,1 1,1'),
], ordered=False)
class TestGlobalRepoState(AnsibleZuulTestCase):
config_file = 'zuul-connections-gerrit-and-github.conf'
tenant_config_file = 'config/global-repo-state/main.yaml'

View File

@ -1330,12 +1330,23 @@ class PipelineManager(metaclass=ABCMeta):
item.bundle and
item.bundle.updatesConfig(tenant) and tpc is not None
):
extra_config_files = set(tpc.extra_config_files)
extra_config_dirs = set(tpc.extra_config_dirs)
# Merge extra_config_files and extra_config_dirs of the
# dependent change
for item_ahead in item.items_ahead:
tpc_ahead = tenant.project_configs.get(
item_ahead.change.project.canonical_name)
if tpc_ahead:
extra_config_files.update(tpc_ahead.extra_config_files)
extra_config_dirs.update(tpc_ahead.extra_config_dirs)
ready = self.scheduleMerge(
item,
files=(['zuul.yaml', '.zuul.yaml'] +
list(tpc.extra_config_files)),
list(extra_config_files)),
dirs=(['zuul.d', '.zuul.d'] +
list(tpc.extra_config_dirs)))
list(extra_config_dirs)))
if build_set.merge_state == build_set.PENDING:
ready = False