Skip to content

Commit

Permalink
[ews-build.webkit.org] Specify branches to trigger queues on
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=255562
rdar://108168587

Reviewed by Aakash Jain.

Some queues should only be triggered by certain branches. Allow factories
to define this.

* Tools/CISupport/ews-build/factories.py:
(Factory): Add 'branches' class variable.
(Factory.__init__): Pass 'branches' to ValidateChange.
(WinCairoFactory): Only run WinCairo tests on 'main'.
(GTKBuildFactory): Only run tests on 'main' and 'webkit' branches.
(WPEBuildFactory): Ditto.
* Tools/CISupport/ews-build/steps.py:
(ValidateChange.__init__): Allow caller to limit queue to specific branches.
(ValidateChange.run): Skip build if target branch is not supported by this queue.
* Tools/CISupport/ews-build/steps_unittest.py:

Canonical link: https://commits.webkit.org/267047@main
  • Loading branch information
JonWBedard committed Aug 18, 2023
1 parent 662d6eb commit ae57f1d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Tools/CISupport/ews-build/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

class Factory(factory.BuildFactory):
findModifiedLayoutTests = False
branches = None

def __init__(self, platform, configuration=None, architectures=None, buildOnly=True, triggers=None, triggered_by=None, remotes=None, additionalArguments=None, checkRelevance=False, **kwargs):
factory.BuildFactory.__init__(self)
Expand All @@ -47,7 +48,7 @@ def __init__(self, platform, configuration=None, architectures=None, buildOnly=T
self.addStep(CheckChangeRelevance())
if self.findModifiedLayoutTests:
self.addStep(FindModifiedLayoutTests())
self.addStep(ValidateChange())
self.addStep(ValidateChange(branches=self.branches))
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
Expand Down Expand Up @@ -253,6 +254,8 @@ class macOSWK2Factory(TestFactory):


class WinCairoFactory(Factory):
branches = [r'main']

def __init__(self, platform, configuration=None, architectures=None, triggers=None, additionalArguments=None, **kwargs):
Factory.__init__(self, platform=platform, configuration=configuration, architectures=architectures, buildOnly=True, triggers=triggers, additionalArguments=additionalArguments)
self.addStep(KillOldProcesses())
Expand All @@ -261,15 +264,15 @@ def __init__(self, platform, configuration=None, architectures=None, triggers=No


class GTKBuildFactory(BuildFactory):
pass
branches = [r'main', r'webkit.+']


class GTKTestsFactory(TestFactory):
LayoutTestClass = RunWebKitTestsRedTree


class WPEBuildFactory(BuildFactory):
pass
branches = [r'main', r'webkit.+']


class WPETestsFactory(TestFactory):
Expand Down
10 changes: 10 additions & 0 deletions Tools/CISupport/ews-build/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@ def __init__(
verifyMergeQueue=False,
verifyNoDraftForMergeQueue=False,
enableSkipEWSLabel=True,
branches=None,
):
self.verifyObsolete = verifyObsolete
self.verifyBugClosed = verifyBugClosed
Expand All @@ -1664,6 +1665,10 @@ def __init__(
self.verifyNoDraftForMergeQueue = verifyNoDraftForMergeQueue
self.enableSkipEWSLabel = enableSkipEWSLabel
self.addURLs = addURLs

branches = branches or [r'.+']
self.branches = [branch if isinstance(branch, re.Pattern) else re.compile(branch) for branch in branches]

super().__init__()

def getResultSummary(self):
Expand Down Expand Up @@ -1694,6 +1699,11 @@ def fail_build(self, reason):
def run(self):
patch_id = self.getProperty('patch_id', '')
pr_number = self.getProperty('github.number', '')
branch = self.getProperty('github.base.ref', DEFAULT_BRANCH)

if not any(candidate.match(branch) for candidate in self.branches):
rc = yield self.skip_build(f"Changes to '{branch}' are not tested")
return defer.returnValue(rc)

if not patch_id and not pr_number:
yield self._addToLog('stdio', 'No patch_id or pr_number found. Unable to proceed without one of them.\n')
Expand Down
13 changes: 13 additions & 0 deletions Tools/CISupport/ews-build/steps_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5727,6 +5727,19 @@ def test_sensative_patch(self):
self.assertEqual(self.getProperty('comment_text'), message)
return rc

def test_skipped_branch(self):
self.setupStep(ValidateChange(verifyBugClosed=False, branches=[r'main']))
ValidateChange.get_pr_json = lambda x, pull_request, repository_url=None, retry=None: self.get_pr(pr_number=pull_request)
self.setProperty('github.number', '1234')
self.setProperty('repository', 'https://github.com/WebKit/WebKit')
self.setProperty('github.head.sha', '7496f8ecc4cc8011f19c8cc1bc7b18fe4a88ad5c')
self.setProperty('github.base.ref', 'safari-123-branch')

self.expectOutcome(result=FAILURE, state_string="Changes to 'safari-123-branch' are not tested")
rc = self.runStep()
self.assertEqual(self.getProperty('fast_commit_queue'), None, 'fast_commit_queue is unexpectedly set')
return rc


class TestValidateCommitterAndReviewer(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit ae57f1d

Please sign in to comment.