Fix issue with sparse-checkout of include-vars

Path of include-vars were not correctly added to the list of sparse
paths for the matching connection/project. Instead they were added to
the paths for the last processed playbook connection/project.

Change-Id: I4aa0dbcd6f3b4a84c0f412f90cc742483741c22d
This commit is contained in:
Simon Westphahl
2025-02-04 15:00:51 +01:00
parent 03d5ba8181
commit 4ff13056b0
4 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1 @@
foo: project2

View File

@@ -0,0 +1,10 @@
- job:
name: test-workspace-checkout-multi-include-vars
parent: test-workspace-checkout-false
files: '.*' # Reset parent file matcher
include-vars: zuul.include/vars.yaml
- project:
check:
jobs:
- test-workspace-checkout-multi-include-vars

View File

@@ -1473,3 +1473,15 @@ class TestExecutorWorkspaceCheckout(ZuulTestCase, ExecutorReposMixin):
for f, expected in file_checks.items():
exists = os.path.exists(os.path.join(path, f))
self.assertEqual(expected, exists, f)
def test_workspace_checkout_multi_include_vars(self):
A = self.fake_gerrit.addFakeChange('org/project2', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertHistory([
dict(
name='test-workspace-checkout-multi-include-vars',
result='SUCCESS'
),
], ordered=False)

View File

@@ -2321,6 +2321,7 @@ class AnsibleJob(object):
for iv in self.job.include_vars:
# For each include-vars, add the contining dir
key = (iv['connection'], iv['project'])
paths = self.repo_sparse_paths[key]
ivpath = os.path.dirname(iv['name'])
# Remove any / at the start and add one at the end.
ivpath = ivpath.lstrip('/') + '/'