WebKit Bugzilla
Attachment 358345 Details for
Bug 193140
: [ews-build] Add build step to validate the patch before processing it
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated patch
ews-build-validate-patch_v2.patch (text/plain), 7.51 KB, created by
Aakash Jain
on 2019-01-04 12:10:56 PST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Aakash Jain
Created:
2019-01-04 12:10:56 PST
Size:
7.51 KB
patch
obsolete
>Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 239609) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,24 @@ >+2019-01-04 Aakash Jain <aakash_jain@apple.com> >+ >+ [ews-build] Add build step to validate the patch before processing it >+ https://bugs.webkit.org/show_bug.cgi?id=193140 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * BuildSlaveSupport/ews-build/factories.py: >+ (Factory.__init__): Added ValidatePatch step. >+ * BuildSlaveSupport/ews-build/steps.py: >+ (ValidatePatch): >+ (ValidatePatch.fetch_data_from_url): Fetch data from a url. >+ (ValidatePatch.get_patch_json): Get patch json data. >+ (ValidatePatch.get_bug_json): Get bug json data. >+ (ValidatePatch.get_bug_id_from_patch): Get bug id from a patch id. >+ (ValidatePatch._is_patch_obsolete): Check if the patch is obsolete. >+ (ValidatePatch._is_patch_review_denied): Check if the patch is marked r-. >+ (ValidatePatch._is_bug_closed): Check if the bug is already closed. >+ (ValidatePatch.skip_build): Skip the build. >+ (ValidatePatch.start): >+ > 2019-01-03 Ross Kirsling <ross.kirsling@sony.com> > > test262-runner misbehaves when test file YAML has a trailing space >Index: Tools/BuildSlaveSupport/ews-build/factories.py >=================================================================== >--- Tools/BuildSlaveSupport/ews-build/factories.py (revision 239607) >+++ Tools/BuildSlaveSupport/ews-build/factories.py (working copy) >@@ -33,6 +33,7 @@ class Factory(factory.BuildFactory): > def __init__(self, platform, configuration=None, architectures=None, buildOnly=True, additionalArguments=None, **kwargs): > factory.BuildFactory.__init__(self) > self.addStep(ConfigureBuild(platform, configuration, architectures, buildOnly, additionalArguments)) >+ self.addStep(ValidatePatch()) > self.addStep(CheckOutSource()) > > >Index: Tools/BuildSlaveSupport/ews-build/steps.py >=================================================================== >--- Tools/BuildSlaveSupport/ews-build/steps.py (revision 239607) >+++ Tools/BuildSlaveSupport/ews-build/steps.py (working copy) >@@ -27,6 +27,7 @@ from buildbot.steps.source import git > from twisted.internet import defer > > import re >+import requests > > BUG_SERVER_URL = 'https://bugs.webkit.org/' > EWS_URL = 'http://ews-build.webkit-uat.org/' >@@ -193,6 +194,137 @@ class CheckPatchRelevance(buildstep.Buil > return None > > >+class ValidatePatch(buildstep.BuildStep): >+ name = 'validate-patch' >+ description = ['validate-patch running'] >+ descriptionDone = ['validate-patch'] >+ flunkOnFailure = True >+ haltOnFailure = True >+ bug_open_statuses = ["UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED"] >+ bug_closed_statuses = ["RESOLVED", "VERIFIED", "CLOSED"] >+ >+ @defer.inlineCallbacks >+ def _addToLog(self, logName, message): >+ try: >+ log = self.getLog(logName) >+ except KeyError: >+ log = yield self.addLog(logName) >+ log.addStdout(message) >+ >+ def fetch_data_from_url(self, url): >+ response = None >+ try: >+ response = requests.get(url) >+ except Exception as e: >+ if response: >+ self._addToLog('stdio', 'Failed to access {url} with status code {status_code}.\n'.format(url=url, status_code=response.status_code)) >+ else: >+ self._addToLog('stdio', 'Failed to access {url} with exception: {exception}\n'.format(url=url, exception=e)) >+ return None >+ if response.status_code != 200: >+ self._addToLog('stdio', 'Accessed {url} with unexpected status code {status_code}.\n'.format(url=url, status_code=response.status_code)) >+ return None >+ return response >+ >+ def get_patch_json(self, patch_id): >+ patch_url = '{}rest/bug/attachment/{}'.format(BUG_SERVER_URL, patch_id) >+ patch = self.fetch_data_from_url(patch_url) >+ if not patch: >+ return None >+ patch_json = patch.json().get('attachments') >+ if not patch_json or len(patch_json) == 0: >+ return None >+ return patch_json.get(str(patch_id)) >+ >+ def get_bug_json(self, bug_id): >+ bug_url = '{}rest/bug/{}'.format(BUG_SERVER_URL, bug_id) >+ bug = self.fetch_data_from_url(bug_url) >+ if not bug: >+ return None >+ bugs_json = bug.json().get('bugs') >+ if not bugs_json or len(bugs_json) == 0: >+ return None >+ return bugs_json[0] >+ >+ def get_bug_id_from_patch(self, patch_id): >+ patch_json = self.get_patch_json(patch_id) >+ if not patch_json: >+ self._addToLog('stdio', 'Unable to fetch patch {}.\n'.format(patch_id)) >+ return -1 >+ return patch_json.get('bug_id') >+ >+ def _is_patch_obsolete(self, patch_id): >+ patch_json = self.get_patch_json(patch_id) >+ if not patch_json: >+ self._addToLog('stdio', 'Unable to fetch patch {}.\n'.format(patch_id)) >+ return -1 >+ >+ if patch_json.get('id') != self.getProperty('patch_id', ''): >+ self._addToLog('stdio', 'Fetched Patch id {} does not match with requested patch id {}. Unable to validate.\n'.format(patch_json.get('id'), self.getProperty('patch_id', ''))) >+ return -1 >+ >+ return patch_json.get('is_obsolete') >+ >+ def _is_patch_review_denied(self, patch_id): >+ patch_json = self.get_patch_json(patch_id) >+ if not patch_json: >+ self._addToLog('stdio', 'Unable to fetch patch {}.\n'.format(patch_id)) >+ return -1 >+ >+ for flag in patch_json.get('flags', []): >+ if flag.get('name') == 'review' and flag.get('status') == '-': >+ return 1 >+ return 0 >+ >+ def _is_bug_closed(self, bug_id): >+ bug_json = self.get_bug_json(bug_id) >+ if not bug_json or not bug_json.get('status'): >+ self._addToLog('stdio', 'Unable to fetch bug {}.\n'.format(bug_id)) >+ return -1 >+ >+ if bug_json.get('status') in self.bug_closed_statuses: >+ return 1 >+ return 0 >+ >+ def skip_build(self, reason): >+ self._addToLog('stdio', reason) >+ self.finished(FAILURE) >+ self.build.results = SKIPPED >+ self.build.buildFinished([reason], SKIPPED) >+ >+ 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.finished(FAILURE) >+ return None >+ >+ bug_id = self.getProperty('bug_id', self.get_bug_id_from_patch(patch_id)) >+ >+ bug_closed = self._is_bug_closed(bug_id) >+ if bug_closed == 1: >+ self.skip_build('Bug {} is already closed'.format(bug_id)) >+ return None >+ >+ obsolete = self._is_patch_obsolete(patch_id) >+ if obsolete == 1: >+ self.skip_build('Patch {} is obsolete'.format(patch_id)) >+ return None >+ >+ review_denied = self._is_patch_review_denied(patch_id) >+ if review_denied == 1: >+ self.skip_build('Patch {} is marked r-'.format(patch_id)) >+ return None >+ >+ if obsolete == -1 or review_denied == -1 or bug_closed == -1: >+ self.finished(WARNINGS) >+ return None >+ >+ self._addToLog('stdio', 'Bug is open.\nPatch is not obsolete.\nPatch is not marked r-.\n') >+ self.finished(SUCCESS) >+ return None >+ >+ > class UnApplyPatchIfRequired(CheckOutSource): > name = 'unapply-patch' >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
lforschler
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193140
:
358317
|
358324
|
358345
|
358405