Diff
Modified: trunk/Tools/CISupport/ews-build/factories.py (288020 => 288021)
--- trunk/Tools/CISupport/ews-build/factories.py 2022-01-14 18:10:50 UTC (rev 288020)
+++ trunk/Tools/CISupport/ews-build/factories.py 2022-01-14 19:37:23 UTC (rev 288021)
@@ -32,7 +32,7 @@
RunEWSUnitTests, RunResultsdbpyTests, RunJavaScriptCoreTests, RunWebKit1Tests, RunWebKitPerlTests, RunWebKitPyPython2Tests,
RunWebKitPyPython3Tests, RunWebKitTests, RunWebKitTestsRedTree, RunWebKitTestsInStressMode, RunWebKitTestsInStressGuardmallocMode,
SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdateWorkingDirectory,
- ValidatePatch, ValidateChangeLogAndReviewer, ValidateCommiterAndReviewer, WaitForCrashCollection,
+ ValidateChange, ValidateChangeLogAndReviewer, ValidateCommiterAndReviewer, WaitForCrashCollection,
InstallBuiltProduct, VerifyGitHubIntegrity)
@@ -46,7 +46,7 @@
self.addStep(CheckPatchRelevance())
if self.findModifiedLayoutTests:
self.addStep(FindModifiedLayoutTests())
- self.addStep(ValidatePatch())
+ self.addStep(ValidateChange())
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
@@ -63,7 +63,7 @@
def __init__(self, platform, configuration=None, architectures=None, triggers=None, remotes=None, additionalArguments=None, **kwargs):
factory.BuildFactory.__init__(self)
self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=triggers, remotes=remotes, additionalArguments=additionalArguments))
- self.addStep(ValidatePatch())
+ self.addStep(ValidateChange())
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
@@ -78,7 +78,7 @@
def __init__(self, platform, configuration=None, architectures=None, triggers=None, remotes=None, additionalArguments=None, **kwargs):
factory.BuildFactory.__init__(self)
self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=triggers, remotes=remotes, additionalArguments=additionalArguments))
- self.addStep(ValidatePatch())
+ self.addStep(ValidateChange())
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
@@ -243,7 +243,7 @@
Factory.__init__(self, platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=triggers, additionalArguments=additionalArguments, checkRelevance=True)
self.addStep(KillOldProcesses())
self.addStep(CompileWebKit(skipUpload=True))
- self.addStep(ValidatePatch(verifyBugClosed=False, addURLs=False))
+ self.addStep(ValidateChange(verifyBugClosed=False, addURLs=False))
self.addStep(RunWebKit1Tests())
self.addStep(SetBuildSummary())
@@ -285,7 +285,7 @@
def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
factory.BuildFactory.__init__(self)
self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architectures=architectures, buildOnly=False, triggers=None, remotes=None, additionalArguments=additionalArguments))
- self.addStep(ValidatePatch(verifycqplus=True))
+ self.addStep(ValidateChange(verifycqplus=True))
self.addStep(ValidateCommiterAndReviewer())
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo(default_branch='master'))
@@ -300,10 +300,10 @@
self.addStep(KillOldProcesses())
self.addStep(CompileWebKit(skipUpload=True))
self.addStep(KillOldProcesses())
- self.addStep(ValidatePatch(addURLs=False, verifycqplus=True))
+ self.addStep(ValidateChange(addURLs=False, verifycqplus=True))
self.addStep(CheckPatchStatusOnEWSQueues())
self.addStep(RunWebKitTests())
- self.addStep(ValidatePatch(addURLs=False, verifycqplus=True))
+ self.addStep(ValidateChange(addURLs=False, verifycqplus=True))
self.addStep(CheckOutSource(repourl='https://git.webkit.org/git/WebKit-https'))
self.addStep(ShowIdentifier())
self.addStep(UpdateWorkingDirectory())
Modified: trunk/Tools/CISupport/ews-build/factories_unittest.py (288020 => 288021)
--- trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-01-14 18:10:50 UTC (rev 288020)
+++ trunk/Tools/CISupport/ews-build/factories_unittest.py 2022-01-14 19:37:23 UTC (rev 288021)
@@ -31,7 +31,7 @@
expected_steps = {
'Style-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -43,7 +43,7 @@
],
'Apply-WatchList-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -55,7 +55,7 @@
],
'GTK-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -70,7 +70,7 @@
],
'GTK-WK2-Tests-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -89,7 +89,7 @@
],
'iOS-15-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -102,7 +102,7 @@
],
'iOS-15-Simulator-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -115,7 +115,7 @@
],
'iOS-15-Simulator-WK2-Tests-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -136,7 +136,7 @@
'macOS-AppleSilicon-Big-Sur-Debug-Build-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -149,7 +149,7 @@
],
'macOS-AppleSilicon-Big-Sur-Debug-WK2-Tests-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -169,7 +169,7 @@
],
'macOS-Catalina-Release-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -183,7 +183,7 @@
'macOS-Catalina-Release-WK1-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -203,7 +203,7 @@
],
'macOS-Catalina-Release-WK2-Tests-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -224,7 +224,7 @@
'macOS-Release-WK2-Stress-Tests-EWS': [
'configure-build',
'find-modified-layout-tests',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -242,7 +242,7 @@
],
'macOS-Catalina-Debug-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -256,7 +256,7 @@
'macOS-Catalina-Debug-WK1-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -276,7 +276,7 @@
],
'watchOS-8-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -289,7 +289,7 @@
],
'watchOS-8-Simulator-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -302,7 +302,7 @@
],
'tvOS-15-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -315,7 +315,7 @@
],
'tvOS-15-Simulator-Build-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -329,7 +329,7 @@
'Windows-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -339,13 +339,13 @@
'apply-patch',
'kill-old-processes',
'compile-webkit',
- 'validate-patch',
+ 'validate-change',
'layout-tests',
'set-build-summary'
],
'WinCairo-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -358,7 +358,7 @@
],
'WPE-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -373,7 +373,7 @@
'JSC-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -388,7 +388,7 @@
'JSC-MIPSEL-32bits-Build-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -402,7 +402,7 @@
'JSC-MIPSEL-32bits-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -418,7 +418,7 @@
'JSC-ARMv7-32bits-Build-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -432,7 +432,7 @@
'JSC-ARMv7-32bits-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -448,7 +448,7 @@
'JSC-i386-32bits-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -462,7 +462,7 @@
'Bindings-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -475,7 +475,7 @@
'WebKitPy-Tests-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -489,7 +489,7 @@
],
'WebKitPerl-Tests-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -501,7 +501,7 @@
],
'API-Tests-iOS-Simulator-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -516,7 +516,7 @@
],
'API-Tests-macOS-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -531,7 +531,7 @@
],
'API-Tests-GTK-EWS': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -548,7 +548,7 @@
'Services-EWS': [
'configure-build',
'check-patch-relevance',
- 'validate-patch',
+ 'validate-change',
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
@@ -564,7 +564,7 @@
],
'Commit-Queue': [
'configure-build',
- 'validate-patch',
+ 'validate-change',
'validate-commiter-and-reviewer',
'configuration',
'clean-up-git-repo',
@@ -579,10 +579,10 @@
'kill-old-processes',
'compile-webkit',
'kill-old-processes',
- 'validate-patch',
+ 'validate-change',
'check-status-on-other-ewses',
'layout-tests',
- 'validate-patch',
+ 'validate-change',
'clean-and-update-working-directory',
'show-identifier',
'update-working-directory',
Modified: trunk/Tools/CISupport/ews-build/steps.py (288020 => 288021)
--- trunk/Tools/CISupport/ews-build/steps.py 2022-01-14 18:10:50 UTC (rev 288020)
+++ trunk/Tools/CISupport/ews-build/steps.py 2022-01-14 19:37:23 UTC (rev 288021)
@@ -54,9 +54,9 @@
RESULTS_DB_URL = 'https://results.webkit.org/'
WithProperties = properties.WithProperties
Interpolate = properties.Interpolate
-BRANCH_PR_RE = re.compile(r'^refs/pull/(?P<id>\d+)/merge$')
GITHUB_URL = 'https://github.com/'
GITHUB_PROJECTS = ['WebKit/WebKit']
+HASH_LENGTH_TO_DISPLAY = 8
class BufferLogHeaderObserver(logobserver.BufferLogObserver):
@@ -86,9 +86,97 @@
return ''
if not pr_number or not isinstance(pr_number, int):
return ''
- return '{}pull/{}'.format(repository_url, pr_number)
+ return '{}/pull/{}'.format(repository_url, pr_number)
+ @classmethod
+ def api_url(cls, repository_url=None):
+ if not repository_url:
+ repository_url = '{}{}'.format(GITHUB_URL, GITHUB_PROJECTS[0])
+ if repository_url not in GitHub.repository_urls():
+ return ''
+ _, url_base = repository_url.split('://', 1)
+ host, path = url_base.split('/', 1)
+ return 'https://api.{}/repos/{}'.format(host, path)
+
+ @classmethod
+ def credentials(cls):
+ try:
+ passwords = json.load(open('passwords.json'))
+ return passwords.get('GITHUB_COM_USERNAME', None), passwords.get('GITHUB_COM_ACCESS_TOKEN', None)
+ except Exception as e:
+ print('Error reading GitHub credentials')
+ return None, None
+
+
+class GitHubMixin(object):
+ addURLs = False
+ pr_open_states = ['open']
+ pr_closed_states = ['closed']
+
+ def fetch_data_from_url_with_authentication(self, url):
+ response = None
+ try:
+ username, access_token = self.credentials()
+ auth = HTTPBasicAuth(username, access_token) if username and access_token else None
+ response = requests.get(
+ url, timeout=60, auth=auth,
+ headers=dict(Accept='application/vnd.github.v3+json'),
+ )
+ if response.status_code // 100 != 2:
+ self._addToLog('stdio', 'Accessed {url} with unexpected status code {status_code}.\n'.format(url="" status_code=response.status_code))
+ return None
+ except Exception as e:
+ # Catching all exceptions here to safeguard access token.
+ self._addToLog('stdio', 'Failed to access {url}.\n'.format(url=""
+ return None
+ return response
+
+ def get_pr_json(self, pr_number, repository_url=None):
+ api_url = GitHub.api_url(repository_url)
+ if not api_url:
+ return None
+
+ pr_url = '{}/pulls/{}'.format(api_url, pr_number)
+ content = self.fetch_data_from_url_with_authentication(pr_url)
+ if not content:
+ return None
+ try:
+ pr_json = content.json()
+ except Exception as e:
+ print('Failed to get pull request data from {}, error: {}'.format(pr_url, e))
+ return None
+ if not pr_json or len(pr_json) == 0:
+ return None
+ return pr_json
+
+ def _is_pr_closed(self, pr_number, repository_url=None):
+ if not pr_number:
+ self._addToLog('stdio', 'Skipping pull request status validation since pull request is None.\n')
+ return -1
+
+ pr_json = self.get_pr_json(pr_number, repository_url)
+ if not pr_json or not pr_json.get('state'):
+ self._addToLog('stdio', 'Unable to fetch pull request {}.\n'.format(pr_number))
+ return -1
+ if pr_json.get('state') in self.pr_closed_states:
+ return 1
+ return 0
+
+ def _is_pr_obsolete(self, pr_number, repository_url=None):
+ pr_json = self.get_pr_json(pr_number, repository_url)
+ if not pr_json:
+ self._addToLog('stdio', 'Unable to fetch pull request {}.\n'.format(pr_number))
+ return -1
+
+ pr_sha = pr_json.get('head', {}).get('sha', '')
+ if not pr_sha:
+ self._addToLog('stdio', 'Failed to fetch hash of pull request {}\n'.format(pr_number))
+ return -1
+
+ return 0 if pr_sha == self.getProperty('revision', '?') else 1
+
+
class Contributors(object):
url = ''
contributors = {}
@@ -115,12 +203,16 @@
return {}, 'Failed to access {url}\n'.format(url=""
@classmethod
- def load(cls):
+ def load(cls, use_network=True):
errors = []
- contributors_json, error = cls.load_from_github()
- if error:
- errors.append(error)
+ if use_network:
+ contributors_json, error = cls.load_from_github()
+ if error:
+ errors.append(error)
+ else:
+ contributors_json = []
+
if not contributors_json:
contributors_json, error = cls.load_from_disk()
if error:
@@ -138,7 +230,7 @@
contributors[github_username] = dict(
name=name,
status=value.get('status'),
- email=emails[0],
+ email=emails[0].lower(),
)
return contributors, errors
@@ -927,10 +1019,10 @@
return SUCCESS
-class ValidatePatch(buildstep.BuildStep, BugzillaMixin):
- name = 'validate-patch'
- description = ['validate-patch running']
- descriptionDone = ['Validated patch']
+class ValidateChange(buildstep.BuildStep, BugzillaMixin, GitHubMixin):
+ name = 'validate-change'
+ description = ['validate-change running']
+ descriptionDone = ['Validated change']
flunkOnFailure = True
haltOnFailure = True
@@ -945,7 +1037,7 @@
def getResultSummary(self):
if self.results == FAILURE:
return {'step': self.descriptionDone}
- return super(ValidatePatch, self).getResultSummary()
+ return super(ValidateChange, self).getResultSummary()
def doStepIf(self, step):
return not self.getProperty('skip_validation', False)
@@ -959,56 +1051,107 @@
def start(self):
patch_id = self.getProperty('patch_id', '')
- if not patch_id:
- self._addToLog('stdio', 'No patch_id found. Unable to proceed without patch_id.\n')
- self.descriptionDone = 'No patch id found'
+ pr_number = self.getProperty('github.number', '')
+
+ if not patch_id and not pr_number:
+ self._addToLog('stdio', 'No patch_id or pr_number found. Unable to proceed without one of them.\n')
+ self.descriptionDone = 'No change found'
self.finished(FAILURE)
return None
+ if patch_id and pr_number:
+ self._addToLog('stdio', 'Both patch_id and pr_number found. Unable to proceed with both.\n')
+ self.descriptionDone = 'Error: both PR and patch number found'
+ self.finished(FAILURE)
+ return None
+
+ if patch_id and not self.validate_bugzilla(patch_id):
+ return None
+ if pr_number and not self.validate_github(pr_number):
+ return None
+
+ if self.verifyBugClosed and patch_id:
+ self._addToLog('stdio', 'Bug is open.\n')
+ if self.verifyObsolete:
+ self._addToLog('stdio', 'Change is not obsolete.\n')
+ if self.verifyReviewDenied:
+ self._addToLog('stdio', 'Change has not been denied.\n')
+ if self.verifycqplus:
+ self._addToLog('stdio', 'Change is in commit queue.\n')
+ self._addToLog('stdio', 'Change has been reviewed.\n')
+ self.finished(SUCCESS)
+ return None
+
+ def validate_bugzilla(self, patch_id):
bug_id = self.getProperty('bug_id', '') or self.get_bug_id_from_patch(patch_id)
bug_closed = self._is_bug_closed(bug_id) if self.verifyBugClosed else 0
if bug_closed == 1:
self.skip_build('Bug {} is already closed'.format(bug_id))
- return None
+ return False
obsolete = self._is_patch_obsolete(patch_id) if self.verifyObsolete else 0
if obsolete == 1:
self.skip_build('Patch {} is obsolete'.format(patch_id))
- return None
+ return False
review_denied = self._is_patch_review_denied(patch_id) if self.verifyReviewDenied else 0
if review_denied == 1:
self.skip_build('Patch {} is marked r-'.format(patch_id))
- return None
+ return False
cq_plus = self._is_patch_cq_plus(patch_id) if self.verifycqplus else 1
if cq_plus != 1:
self.skip_build('Patch {} is not marked cq+.'.format(patch_id))
- return None
+ return False
acceptable_review_flag = self._does_patch_have_acceptable_review_flag(patch_id) if self.verifycqplus else 1
if acceptable_review_flag != 1:
self.skip_build('Patch {} does not have acceptable review flag.'.format(patch_id))
- return None
+ return False
if obsolete == -1 or review_denied == -1 or bug_closed == -1:
self.finished(WARNINGS)
- return None
+ return False
+ return True
- if self.verifyBugClosed:
- self._addToLog('stdio', 'Bug is open.\n')
- if self.verifyObsolete:
- self._addToLog('stdio', 'Patch is not obsolete.\n')
- if self.verifyReviewDenied:
- self._addToLog('stdio', 'Patch is not marked r-.\n')
- if self.verifycqplus:
- self._addToLog('stdio', 'Patch is marked cq+.\n')
- self._addToLog('stdio', 'Patch have acceptable review flag.\n')
- self.finished(SUCCESS)
- return None
+ def validate_github(self, pr_number):
+ if not pr_number:
+ return False
+ repository_url = self.getProperty('repository', '')
+ title = self.getProperty('github.title', '')
+ owners = self.getProperty('owners', [])
+ if self.addURLs and title and repository_url:
+ self.addURL('[PR {}] {}'.format(pr_number, title), GitHub.pr_url(pr_number, repository_url))
+ if self.addURLs and owners:
+ contributors, errors = Contributors.load(use_network=False)
+ for error in errors:
+ print(error)
+ self._addToLog('stdio', error)
+ github_username = owners[0]
+ contributor = contributors.get(github_username, {})
+ display_name = contributor.get('email', github_username)
+ self.addURL('PR by: {}'.format(display_name), '{}{}'.format(GITHUB_URL, github_username))
+
+ pr_closed = self._is_pr_closed(pr_number, repository_url=repository_url) if self.verifyBugClosed else 0
+ if pr_closed == 1:
+ self.skip_build('Pull request {} is already closed'.format(pr_number))
+ return False
+
+ obsolete = self._is_pr_obsolete(pr_number, repository_url=repository_url) if self.verifyObsolete else 0
+ if obsolete == 1:
+ self.skip_build('Pull request {} (sha {}) is obsolete'.format(pr_number, self.getProperty('revision', '?')[:HASH_LENGTH_TO_DISPLAY]))
+ return False
+
+ if obsolete == -1 or pr_closed == -1:
+ self.finished(WARNINGS)
+ return False
+
+ return True
+
+
class ValidateCommiterAndReviewer(buildstep.BuildStep):
name = 'validate-commiter-and-reviewer'
descriptionDone = ['Validated commiter and reviewer']
@@ -1680,7 +1823,7 @@
def evaluateCommand(self, cmd):
if cmd.didFail():
self.setProperty('patchFailedToBuild', True)
- steps_to_add = [UnApplyPatchIfRequired(), ValidatePatch(verifyBugClosed=False, addURLs=False)]
+ steps_to_add = [UnApplyPatchIfRequired(), ValidateChange(verifyBugClosed=False, addURLs=False)]
platform = self.getProperty('platform')
if platform == 'wpe':
steps_to_add.append(InstallWpeDependencies())
@@ -1960,9 +2103,9 @@
else:
self.setProperty('patchFailedTests', True)
self.build.addStepsAfterCurrentStep([UnApplyPatchIfRequired(),
- ValidatePatch(verifyBugClosed=False, addURLs=False),
+ ValidateChange(verifyBugClosed=False, addURLs=False),
CompileJSCWithoutPatch(),
- ValidatePatch(verifyBugClosed=False, addURLs=False),
+ ValidateChange(verifyBugClosed=False, addURLs=False),
KillOldProcesses(),
RunJSCTestsWithoutPatch(),
AnalyzeJSCTestsResults()])
@@ -2385,7 +2528,7 @@
ArchiveTestResults(),
UploadTestResults(),
ExtractTestResults(),
- ValidatePatch(verifyBugClosed=False, addURLs=False),
+ ValidateChange(verifyBugClosed=False, addURLs=False),
KillOldProcesses(),
ReRunWebKitTests(),
])
@@ -2480,9 +2623,9 @@
UploadTestResults(identifier='rerun'),
ExtractTestResults(identifier='rerun'),
UnApplyPatchIfRequired(),
- ValidatePatch(verifyBugClosed=False, addURLs=False),
+ ValidateChange(verifyBugClosed=False, addURLs=False),
CompileWebKitWithoutPatch(retry_build_on_failure=True),
- ValidatePatch(verifyBugClosed=False, addURLs=False),
+ ValidateChange(verifyBugClosed=False, addURLs=False),
KillOldProcesses(),
RunWebKitTestsWithoutPatch()])
return rc
@@ -2805,7 +2948,7 @@
rc = self.evaluateResult(cmd)
next_steps = [ArchiveTestResults(), UploadTestResults(), ExtractTestResults()]
if first_results_failing_tests:
- next_steps.extend([ValidatePatch(verifyBugClosed=False, addURLs=False), KillOldProcesses(), RunWebKitTestsRepeatFailuresRedTree()])
+ next_steps.extend([ValidateChange(verifyBugClosed=False, addURLs=False), KillOldProcesses(), RunWebKitTestsRepeatFailuresRedTree()])
elif first_results_flaky_tests:
next_steps.append(AnalyzeLayoutTestsResultsRedTree())
elif rc == SUCCESS or rc == WARNINGS:
@@ -2823,7 +2966,7 @@
if retry_count < AnalyzeLayoutTestsResultsRedTree.MAX_RETRY:
next_steps.append(AnalyzeLayoutTestsResultsRedTree())
else:
- next_steps.extend([UnApplyPatchIfRequired(), CompileWebKitWithoutPatch(retry_build_on_failure=True), ValidatePatch(verifyBugClosed=False, addURLs=False), RunWebKitTestsWithoutPatchRedTree()])
+ next_steps.extend([UnApplyPatchIfRequired(), CompileWebKitWithoutPatch(retry_build_on_failure=True), ValidateChange(verifyBugClosed=False, addURLs=False), RunWebKitTestsWithoutPatchRedTree()])
if next_steps:
self.build.addStepsAfterCurrentStep(next_steps)
return rc
@@ -2853,8 +2996,8 @@
next_steps = [ArchiveTestResults(), UploadTestResults(identifier='repeat-failures'), ExtractTestResults(identifier='repeat-failures')]
if with_patch_repeat_failures_results_nonflaky_failures or with_patch_repeat_failures_timedout:
self.setProperty('patchFailedTests', True)
- next_steps.extend([ValidatePatch(verifyBugClosed=False, addURLs=False), KillOldProcesses(), UnApplyPatchIfRequired(), CompileWebKitWithoutPatch(retry_build_on_failure=True),
- ValidatePatch(verifyBugClosed=False, addURLs=False), RunWebKitTestsRepeatFailuresWithoutPatchRedTree()])
+ next_steps.extend([ValidateChange(verifyBugClosed=False, addURLs=False), KillOldProcesses(), UnApplyPatchIfRequired(), CompileWebKitWithoutPatch(retry_build_on_failure=True),
+ ValidateChange(verifyBugClosed=False, addURLs=False), RunWebKitTestsRepeatFailuresWithoutPatchRedTree()])
else:
next_steps.append(AnalyzeLayoutTestsResultsRedTree())
if next_steps:
@@ -3257,7 +3400,7 @@
self.build.results = SUCCESS
self.build.buildFinished([message], SUCCESS)
else:
- self.build.addStepsAfterCurrentStep([ValidatePatch(verifyBugClosed=False, addURLs=False), KillOldProcesses(), ReRunAPITests()])
+ self.build.addStepsAfterCurrentStep([ValidateChange(verifyBugClosed=False, addURLs=False), KillOldProcesses(), ReRunAPITests()])
return rc
@@ -3273,7 +3416,7 @@
self.build.buildFinished([message], SUCCESS)
else:
self.setProperty('patchFailedTests', True)
- steps_to_add = [UnApplyPatchIfRequired(), ValidatePatch(verifyBugClosed=False, addURLs=False)]
+ steps_to_add = [UnApplyPatchIfRequired(), ValidateChange(verifyBugClosed=False, addURLs=False)]
platform = self.getProperty('platform')
if platform == 'wpe':
steps_to_add.append(InstallWpeDependencies())
@@ -3280,7 +3423,7 @@
elif platform == 'gtk':
steps_to_add.append(InstallGtkDependencies())
steps_to_add.append(CompileWebKitWithoutPatch(retry_build_on_failure=True))
- steps_to_add.append(ValidatePatch(verifyBugClosed=False, addURLs=False))
+ steps_to_add.append(ValidateChange(verifyBugClosed=False, addURLs=False))
steps_to_add.append(KillOldProcesses())
steps_to_add.append(RunAPITestsWithoutPatch())
steps_to_add.append(AnalyzeAPITestsResults())
Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (288020 => 288021)
--- trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-01-14 18:10:50 UTC (rev 288020)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py 2022-01-14 19:37:23 UTC (rev 288021)
@@ -56,7 +56,7 @@
RunWebKitTestsWithoutPatch, RunWebKitTestsRedTree, RunWebKitTestsRepeatFailuresRedTree, RunWebKitTestsRepeatFailuresWithoutPatchRedTree,
RunWebKitTestsWithoutPatchRedTree, AnalyzeLayoutTestsResultsRedTree, TestWithFailureCount, ShowIdentifier,
Trigger, TransferToS3, UnApplyPatchIfRequired, UpdateWorkingDirectory, UploadBuiltProduct,
- UploadTestResults, ValidateChangeLogAndReviewer, ValidateCommiterAndReviewer, ValidatePatch, VerifyGitHubIntegrity)
+ UploadTestResults, ValidateChangeLogAndReviewer, ValidateCommiterAndReviewer, ValidateChange, VerifyGitHubIntegrity)
# Workaround for https://github.com/buildbot/buildbot/issues/4669
from buildbot.test.fake.fakebuild import FakeBuild
@@ -4525,7 +4525,7 @@
return rc
-class TestValidatePatch(BuildStepMixinAdditions, unittest.TestCase):
+class TestValidateChange(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
return self.setUpBuildStep()
@@ -4543,26 +4543,68 @@
"is_patch": 1,
"summary": "{}"}}'''.format(obsolete, title))
- def test_skipped(self):
- self.setupStep(ValidatePatch())
+ def get_pr(self, pr_number, title='Sample pull request', closed=False):
+ return dict(
+ number=pr_number,
+ state='closed' if closed else 'open',
+ title=title,
+ user=dict(login='JonWBedard'),
+ head=dict(
+ sha='7496f8ecc4cc8011f19c8cc1bc7b18fe4a88ad5c',
+ ref='eng/pull-request',
+ repo=dict(
+ name='WebKit',
+ full_name='JonWBedard/WebKit',
+ ),
+ ), base=dict(
+ sha='528b99575eebf7fa5b94f1fc51de81977f265005',
+ ref='main',
+ repo=dict(
+ name='WebKit',
+ full_name='WebKit/WebKit',
+ ),
+ ),
+ )
+
+ def test_skipped_patch(self):
+ self.setupStep(ValidateChange())
self.setProperty('patch_id', '1234')
self.setProperty('bug_id', '5678')
self.setProperty('skip_validation', True)
- self.expectOutcome(result=SKIPPED, state_string='Validated patch (skipped)')
+ self.expectOutcome(result=SKIPPED, state_string='Validated change (skipped)')
return self.runStep()
- def test_success(self):
- self.setupStep(ValidatePatch(verifyBugClosed=False))
- ValidatePatch.get_patch_json = lambda x, patch_id: self.get_patch()
+ def test_skipped_pr(self):
+ self.setupStep(ValidateChange())
+ self.setProperty('github.number', '1234')
+ self.setProperty('repository', 'https://github.com/WebKit/WebKit')
+ self.setProperty('skip_validation', True)
+ self.expectOutcome(result=SKIPPED, state_string='Validated change (skipped)')
+ return self.runStep()
+
+ def test_success_patch(self):
+ self.setupStep(ValidateChange(verifyBugClosed=False))
+ ValidateChange.get_patch_json = lambda x, patch_id: self.get_patch()
self.setProperty('patch_id', '425806')
- self.expectOutcome(result=SUCCESS, state_string='Validated patch')
+ self.expectOutcome(result=SUCCESS, state_string='Validated change')
rc = self.runStep()
self.assertEqual(self.getProperty('fast_commit_queue'), None, 'fast_commit_queue is unexpectedly set')
return rc
+ def test_success_pr(self):
+ self.setupStep(ValidateChange(verifyBugClosed=False))
+ ValidateChange.get_pr_json = lambda x, pull_request, repository_url=None: self.get_pr(pr_number=pull_request)
+ self.setProperty('github.number', '1234')
+ self.setProperty('repository', 'https://github.com/WebKit/WebKit')
+ self.setProperty('revision', '7496f8ecc4cc8011f19c8cc1bc7b18fe4a88ad5c')
+ self.expectOutcome(result=SUCCESS, state_string='Validated change')
+ rc = self.runStep()
+ self.assertEqual(self.getProperty('fast_commit_queue'), None, 'fast_commit_queue is unexpectedly set')
+ return rc
+
def test_obsolete_patch(self):
- self.setupStep(ValidatePatch(verifyBugClosed=False))
- ValidatePatch.get_patch_json = lambda x, patch_id: self.get_patch(obsolete=1)
+ self.setupStep(ValidateChange(verifyBugClosed=False))
+ ValidateChange.get_patch_json = lambda x, patch_id: self.get_patch(obsolete=1)
self.setProperty('patch_id', '425806')
self.expectOutcome(result=FAILURE, state_string='Patch 425806 is obsolete')
rc = self.runStep()
@@ -4569,13 +4611,24 @@
self.assertEqual(self.getProperty('fast_commit_queue'), None, 'fast_commit_queue is unexpectedly set')
return rc
+ def test_obsolete_pr(self):
+ self.setupStep(ValidateChange(verifyBugClosed=False))
+ ValidateChange.get_pr_json = lambda x, pull_request, repository_url=None: self.get_pr(pr_number=pull_request)
+ self.setProperty('github.number', '1234')
+ self.setProperty('repository', 'https://github.com/WebKit/WebKit')
+ self.setProperty('revision', '1ad60d45a112301f7b9f93dac06134524dae8480')
+ self.expectOutcome(result=FAILURE, state_string='Pull request 1234 (sha 1ad60d45) is obsolete')
+ rc = self.runStep()
+ self.assertEqual(self.getProperty('fast_commit_queue'), None, 'fast_commit_queue is unexpectedly set')
+ return rc
+
def test_fast_cq_patches_trigger_fast_cq_mode(self):
fast_cq_patch_titles = ('REVERT OF r1234', 'revert of r1234', '[fast-cq]Patch', '[FAST-cq] patch', 'fast-cq-patch', 'FAST-CQ Patch')
for fast_cq_patch_title in fast_cq_patch_titles:
- self.setupStep(ValidatePatch(verifyBugClosed=False))
- ValidatePatch.get_patch_json = lambda x, patch_id: self.get_patch(title=fast_cq_patch_title)
+ self.setupStep(ValidateChange(verifyBugClosed=False))
+ ValidateChange.get_patch_json = lambda x, patch_id: self.get_patch(title=fast_cq_patch_title)
self.setProperty('patch_id', '425806')
- self.expectOutcome(result=SUCCESS, state_string='Validated patch')
+ self.expectOutcome(result=SUCCESS, state_string='Validated change')
rc = self.runStep()
self.assertEqual(self.getProperty('fast_commit_queue'), True, 'fast_commit_queue is not set, patch title: {}'.format(fast_cq_patch_title))
return rc
Modified: trunk/Tools/ChangeLog (288020 => 288021)
--- trunk/Tools/ChangeLog 2022-01-14 18:10:50 UTC (rev 288020)
+++ trunk/Tools/ChangeLog 2022-01-14 19:37:23 UTC (rev 288021)
@@ -1,3 +1,44 @@
+2022-01-13 Jonathan Bedard <[email protected]>
+
+ [EWS] Support pull-requests in ValidateChange
+ https://bugs.webkit.org/show_bug.cgi?id=234861
+ <rdar://problem/87114299>
+
+ Reviewed by Aakash Jain.
+
+ * CISupport/ews-build/factories.py:
+ (Factory.__init__): Rename ValidatePatch to ValidateChange.
+ (StyleFactory.__init__): Ditto.
+ (WatchListFactory.__init__): Ditto.
+ (WindowsFactory.__init__): Ditto.
+ (CommitQueueFactory.__init__): Ditto.
+ * CISupport/ews-build/factories_unittest.py:
+ (TestExpectedBuildSteps): Step name changed from validate-patch to validate-change.
+ * CISupport/ews-build/steps.py:
+ (GitHub.pr_url): Add missing /.
+ (GitHub.api_url): Convert a repository URL to the API url for that repository.
+ (GitHub.credentials): Access GitHub credentials from passwords.json.
+ (GitHubMixin):
+ (GitHubMixin.fetch_data_from_url_with_authentication):
+ (GitHubMixin.get_pr_json):
+ (GitHubMixin._is_pr_closed): Check if a pull-request is closed.
+ (GitHubMixin._is_pr_obsolete): Check if a pull-request is obsolete.
+ (ValidateChange): Renamed from ValidatePatch.
+ (ValidateChange.getResultSummary):
+ (ValidateChange.start): Invoke validate_bugzilla or validate_github.
+ (ValidateChange.validate_bugzilla): Check a bugzilla patch.
+ (ValidateChange.validate_github): Check a GitHub pull-request.
+ (CompileWebKit.evaluateCommand): Rename ValidatePatch to ValidateChange.
+ (RunJavaScriptCoreTests.evaluateCommand): Ditto.
+ (RunWebKitTests.evaluateCommand): Ditto.
+ (ReRunWebKitTests.evaluateCommand): Ditto.
+ (RunWebKitTestsRedTree.evaluateCommand): Ditto.
+ (RunWebKitTestsRepeatFailuresRedTree.evaluateCommand): Ditto.
+ (RunAPITests.evaluateCommand): Ditto.
+ (ReRunAPITests.evaluateCommand): Ditto.
+ (ValidatePatch): Renamed to ValidateChange.
+ * CISupport/ews-build/steps_unittest.py:
+
2022-01-14 J Pascoe <[email protected]>
Expose way to encode CTAP commands with only the hash of ClientDataJSON