Changeset 258611 in webkit
- Timestamp:
- Mar 17, 2020 5:01:42 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py
r258407 r258611 34 34 import ews.common.util as util 35 35 import ews.config as config 36 import dateutil.parser 36 37 37 38 _log = logging.getLogger(__name__) … … 50 51 attachment_json['path'] = Bugzilla.file_path_for_patch(attachment_id) 51 52 return attachment_json 53 54 @classmethod 55 def get_cq_plus_timestamp(cls, attachment_id): 56 attachment_json = Bugzilla._fetch_attachment_json(attachment_id) 57 if not attachment_json: 58 _log.warn('Unable to fetch attachment {}.'.format(attachment_id)) 59 return None 60 61 for flag in attachment_json.get('flags'): 62 if flag.get('name') == 'commit-queue' and flag.get('status') == '+': 63 try: 64 return dateutil.parser.parse(flag.get('modification_date')) 65 except: 66 _log.error('Unable to parse timestamp: {}'.format(flag.get('modification_date'))) 67 return None 52 68 53 69 @classmethod -
trunk/Tools/BuildSlaveSupport/ews-app/ews/common/buildbot.py
r255269 r258611 40 40 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELLED = ALL_RESULTS 41 41 icons_for_queues_mapping = {} 42 builder_name_to_id_mapping = {} 42 43 43 44 @classmethod … … 100 101 Buildbot.icons_for_queues_mapping[shortname] = builder.get('icon') 101 102 102 return Buildbot.icons_for_queues_mapping 103 @classmethod 104 def update_builder_name_to_id_mapping(cls): 105 url = 'https://{}/api/v2/builders'.format(config.BUILDBOT_SERVER_HOST) 106 builders_data = util.fetch_data_from_url(url) 107 if not builders_data: 108 return 109 for builder in builders_data.json().get('builders', []): 110 name = builder.get('name') 111 Buildbot.builder_name_to_id_mapping[name] = builder.get('builderid') 112 113 @classmethod 114 def fetch_pending_and_inprogress_builds(cls, builder_full_name): 115 builderid = Buildbot.builder_name_to_id_mapping.get(builder_full_name) 116 if not builderid: 117 _log.error('Invalid builder: {}'.format(builder_full_name)) 118 return {} 119 url = 'https://{}/api/v2/builders/{}/buildrequests?complete=false&property=*'.format(config.BUILDBOT_SERVER_HOST, builderid) 120 builders_data = util.fetch_data_from_url(url) 121 if not builders_data: 122 return {} 123 return builders_data.json() 124 125 @classmethod 126 def get_patches_in_queue(cls, builder_full_name): 127 patch_ids = [] 128 builds = cls.fetch_pending_and_inprogress_builds(builder_full_name) 129 for buildrequest in builds.get('buildrequests', []): 130 properties = buildrequest.get('properties') 131 if properties: 132 patch_ids.append(properties.get('patch_id')[0]) 133 _log.debug('Patches in queue for {}: {}'.format(builder_full_name, patch_ids)) 134 return patch_ids 103 135 104 136 @classmethod -
trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py
r255269 r258611 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 import datetime 23 24 import logging 25 import pytz 24 26 import threading 25 27 import time … … 28 30 from ews.common.buildbot import Buildbot 29 31 from ews.models.patch import Patch 32 from ews.views.statusbubble import StatusBubble 30 33 31 34 _log = logging.getLogger(__name__) … … 40 43 41 44 def run(self): 45 Buildbot.update_builder_name_to_id_mapping() 42 46 while True: 43 47 Buildbot.update_icons_for_queues_mapping() … … 70 74 _log.debug('cq+ patches: {}'.format(patch_ids_commit_queue)) 71 75 Patch.save_patches(patch_ids_commit_queue) 72 patches_to_send = self.patches_to_send_to_ buildbot(patch_ids_commit_queue, commit_queue=True)76 patches_to_send = self.patches_to_send_to_commit_queue(patch_ids_commit_queue) 73 77 _log.info('{} cq+ patches, {} patches need to be sent to commit queue: {}'.format(len(patch_ids_commit_queue), len(patches_to_send), patches_to_send)) 74 78 self.send_patches_to_buildbot(patches_to_send, send_to_commit_queue=True) … … 86 90 Patch.set_obsolete(patch_id) 87 91 continue 88 if Patch.is_patch_sent_to_buildbot(patch_id, commit_queue=send_to_commit_queue):89 _log.error('Patch {} is already sent to buildbot /commit-queue.'.format(patch_id))92 if not send_to_commit_queue and Patch.is_patch_sent_to_buildbot(patch_id): 93 _log.error('Patch {} is already sent to buildbot.'.format(patch_id)) 90 94 continue 91 95 Patch.set_sent_to_buildbot(patch_id, True, commit_queue=send_to_commit_queue) … … 100 104 #FIXME: send an email for this failure 101 105 102 def patches_to_send_to_buildbot(self, patch_ids, commit_queue=False): 103 return [patch_id for patch_id in patch_ids if not Patch.is_patch_sent_to_buildbot(patch_id, commit_queue)] 106 def patches_to_send_to_buildbot(self, patch_ids): 107 return [patch_id for patch_id in patch_ids if not Patch.is_patch_sent_to_buildbot(patch_id)] 108 109 def patches_to_send_to_commit_queue(self, patch_ids): 110 if not patch_ids: 111 return patch_ids 112 patches_in_queue = set(Buildbot.get_patches_in_queue('Commit-Queue')) 113 patch_ids = [patch_id for patch_id in set(patch_ids) if str(patch_id) not in patches_in_queue] 114 115 patch_ids_to_send = [] 116 for patch_id in patch_ids: 117 patch = Patch.get_patch(patch_id) 118 recent_build, _ = StatusBubble().get_latest_build_for_queue(patch, 'commit') 119 if not recent_build: 120 patch_ids_to_send.append(patch_id) 121 continue 122 recent_build_timestamp = datetime.datetime.fromtimestamp(recent_build.complete_at, tz=pytz.UTC) 123 cq_timestamp = Bugzilla.get_cq_plus_timestamp(patch_id) 124 if not cq_timestamp: 125 patch_ids_to_send.append(patch_id) 126 continue 127 if cq_timestamp > recent_build_timestamp: 128 patch_ids_to_send.append(patch_id) 129 return patch_ids_to_send 104 130 105 131 @classmethod -
trunk/Tools/ChangeLog
r258598 r258611 1 2020-03-17 Aakash Jain <aakash_jain@apple.com> 2 3 [ews] Resubmit patches to commit-queue which were cq- by commit-queue and later cq+ 4 https://bugs.webkit.org/show_bug.cgi?id=208920 5 6 Reviewed by Jonathan Bedard. 7 8 * BuildSlaveSupport/ews-app/ews/common/buildbot.py: 9 (Buildbot.update_builder_name_to_id_mapping): Method to generate builder name to id mapping. 10 (Buildbot.fetch_pending_and_inprogress_builds): Method to fetch pendign and in-progress builds from buildbot. 11 (Buildbot.get_patches_in_queue): Method to fetch list of patches which are pending or are in-progress on buildbot. 12 * BuildSlaveSupport/ews-app/ews/common/bugzilla.py: 13 (Bugzilla.get_cq_plus_timestamp): Get UTC timestamp when cq+ flag was set. 14 * BuildSlaveSupport/ews-app/ews/fetcher.py: 15 (FetchLoop.run): Update builder name to id mapping. We just need to update it one-time, since we need the id only 16 for commit-queue which isn't expected to change. 17 (BugzillaPatchFetcher.fetch_commit_queue_patches): 18 (BugzillaPatchFetcher.send_patches_to_buildbot): Allow sending the patch again to commit-queue. 19 (BugzillaPatchFetcher.patches_to_send_to_commit_queue): Find patches which needs to be sent to commit-queue. Filter 20 out patches which are already waiting or in-progress on commit-queue, or whose recent build was completed after 21 setting cq+ flag on bugzilla. 22 1 23 2020-03-17 Chris Dumez <cdumez@apple.com> 2 24
Note: See TracChangeset
for help on using the changeset viewer.