From 4ff13056b09d7923b34c4a24dca0d8a7b6e64523 Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Tue, 4 Feb 2025 15:00:51 +0100 Subject: [PATCH] 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 --- .../git/org_project2/zuul.include/vars.yaml | 1 + .../workspace-checkout/git/org_project2/zuul.yaml | 10 ++++++++++ tests/unit/test_executor.py | 12 ++++++++++++ zuul/executor/server.py | 1 + 4 files changed, 24 insertions(+) create mode 100644 tests/fixtures/config/workspace-checkout/git/org_project2/zuul.include/vars.yaml create mode 100644 tests/fixtures/config/workspace-checkout/git/org_project2/zuul.yaml diff --git a/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.include/vars.yaml b/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.include/vars.yaml new file mode 100644 index 0000000000..dc3cda2de6 --- /dev/null +++ b/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.include/vars.yaml @@ -0,0 +1 @@ +foo: project2 diff --git a/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.yaml b/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.yaml new file mode 100644 index 0000000000..52c16191a8 --- /dev/null +++ b/tests/fixtures/config/workspace-checkout/git/org_project2/zuul.yaml @@ -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 diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py index eeba5f860a..29bf6ced90 100644 --- a/tests/unit/test_executor.py +++ b/tests/unit/test_executor.py @@ -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) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 7992e25e2a..37b93f258f 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -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('/') + '/'