summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/unit/test_github_driver.py16
-rw-r--r--zuul/scheduler.py7
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index f35f8ffbe..0558c9994 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -209,11 +209,27 @@ class TestGithubDriver(ZuulTestCase):
sha = tag.commit.hexsha
del repo
+ # Notify zuul about the new branch to load the config
+ self.fake_github.emitEvent(
+ self.fake_github.getPushEvent(
+ 'org/project',
+ ref='refs/heads/%s' % 'tagbranch'))
+ self.waitUntilSettled()
+
+ # Record previous tenant reconfiguration time
+ before = self.scheds.first.sched.tenant_last_reconfigured.get(
+ 'tenant-one', 0)
+
self.fake_github.emitEvent(
self.fake_github.getPushEvent('org/project', 'refs/tags/newtag',
new_rev=sha))
self.waitUntilSettled()
+ # Make sure the tenant hasn't been reconfigured due to the new tag
+ after = self.scheds.first.sched.tenant_last_reconfigured.get(
+ 'tenant-one', 0)
+ self.assertEqual(before, after)
+
build_params = self.builds[0].parameters
self.assertEqual('refs/tags/newtag', build_params['zuul']['ref'])
self.assertFalse('oldrev' in build_params['zuul'])
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 01254f937..cfcc64485 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -1282,12 +1282,17 @@ class Scheduler(threading.Thread):
if ((event.branch_updated and
hasattr(change, 'files') and
change.updatesConfig(tenant)) or
- event.branch_created or
(event.branch_deleted and
self.abide.hasUnparsedBranchCache(event.project_name,
event.branch))):
reconfigure_tenant = True
+ # The branch_created attribute is also true when a tag is
+ # created. Since we load config only from branches only trigger
+ # a tenant reconfiguration if the branch is set as well.
+ if event.branch_created and event.branch:
+ reconfigure_tenant = True
+
# If the driver knows the branch but we don't have a config, we
# also need to reconfigure. This happens if a GitHub branch
# was just configured as protected without a push in between.