Required gitlab labels is subset of set labels

All labels in require.labels should be set on the change for the
pipeline to start

Change-Id: Ib3660a08dd7c72f9a7363587f9d1829bec92b8c2
This commit is contained in:
Niklas Borg 2022-01-14 17:53:43 +00:00
parent 56865e57d2
commit f0a7e4c4ec
4 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1,7 @@
---
fixes:
- |
The `labels` pipeline requirement in the `gitlab` driver erroneously treated
the labels as a boolean `or` but should have treated them as a boolean `and`
(i.e., all listed labels are required).
The behavior has been updated to match the documentation and other drivers.

View File

@ -42,7 +42,9 @@
manager: independent
require:
gitlab:
labels: gateit
labels:
- gateit
- another_label
trigger:
gitlab:
- event: gl_merge_request
@ -89,4 +91,4 @@
name: org/project3
label-check:
jobs:
- project3-test
- project3-test

View File

@ -641,6 +641,12 @@ class TestGitlabDriver(ZuulTestCase):
A.labels = ['gateit', 'prio:low']
self.fake_gitlab.emitEvent(A.getMergeRequestUpdatedEvent())
self.waitUntilSettled()
self.assertEqual(0, len(self.history))
A.labels = ['gateit', 'prio:low', 'another_label']
self.fake_gitlab.emitEvent(A.getMergeRequestUpdatedEvent())
self.waitUntilSettled()
self.assertEqual(1, len(self.history))

View File

@ -264,7 +264,7 @@ class GitlabRefFilter(RefFilter):
return False
if self.labels:
if not set(change.labels).intersection(set(self.labels)):
if not set(self.labels).issubset(set(change.labels)):
return False
return True