Пример #1
0
 def fetch_commit_queue_patches(self):
     patch_ids_commit_queue = Bugzilla.get_list_of_patches_for_commit_queue()
     patch_ids_commit_queue = BugzillaPatchFetcher.filter_valid_patches(patch_ids_commit_queue)
     _log.debug('cq+ patches: {}'.format(patch_ids_commit_queue))
     Patch.save_patches(patch_ids_commit_queue)
     patches_to_send = self.patches_to_send_to_commit_queue(patch_ids_commit_queue)
     _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))
     self.send_patches_to_buildbot(patches_to_send, send_to_commit_queue=True)
Пример #2
0
 def send_patches_to_buildbot(self, patches_to_send, send_to_commit_queue=False):
     if not patches_to_send:
         return
     for patch_id in patches_to_send:
         bz_patch = Bugzilla.retrieve_attachment(patch_id)
         if not bz_patch or bz_patch['id'] != patch_id:
             _log.error('Unable to retrive patch "{}"'.format(patch_id))
             if len(patches_to_send) == 1:
                 return ERR_UNABLE_TO_FETCH_PATCH
             continue
         if bz_patch.get('is_obsolete'):
             _log.warn('Patch is obsolete, skipping')
             Patch.set_obsolete(patch_id)
             if len(patches_to_send) == 1:
                 return ERR_OBSOLETE_PATCH
             continue
         if not send_to_commit_queue and Patch.is_patch_sent_to_buildbot(patch_id):
             _log.error('Patch {} is already sent to buildbot.'.format(patch_id))
             continue
         Patch.set_sent_to_buildbot(patch_id, True, commit_queue=send_to_commit_queue)
         rc = Buildbot.send_patch_to_buildbot(bz_patch['path'],
                  send_to_commit_queue=send_to_commit_queue,
                  properties=['patch_id={}'.format(patch_id), 'bug_id={}'.format(bz_patch['bug_id']), 'owner={}'.format(bz_patch.get('creator', ''))])
         if rc == 0:
             Patch.set_bug_id(patch_id, bz_patch['bug_id'])
         else:
             _log.error('Failed to send patch to buildbot.')
             Patch.set_sent_to_buildbot(patch_id, False, commit_queue=send_to_commit_queue)
Пример #3
0
    def fetch(self, patch_ids=None):
        if patch_ids and type(patch_ids) != list:
            _log.error('Error: patch_ids should be a list, found: {}'.format(type(patch_ids)))
            return -1

        if not patch_ids:
            patch_ids = Bugzilla.get_list_of_patches_needing_reviews()
        patch_ids = BugzillaPatchFetcher.filter_valid_patches(patch_ids)
        _log.debug('r? patches: {}'.format(patch_ids))
        Patch.save_patches(patch_ids)
        patches_to_send = self.patches_to_send_to_buildbot(patch_ids)
        _log.info('{} r? patches, {} patches need to be sent to Buildbot: {}'.format(len(patch_ids), len(patches_to_send), patches_to_send))
        return self.send_patches_to_buildbot(patches_to_send)
Пример #4
0
    def fetch(self, patch_ids=None):
        if patch_ids and type(patch_ids) != list:
            _log.error('Error: patch_ids should be a list, found: {}'.format(type(patch_ids)))
            return -1

        if not patch_ids:
            patch_ids = Bugzilla.get_list_of_patches_needing_reviews()
        patch_ids = BugzillaPatchFetcher.filter_valid_patches(patch_ids)
        _log.debug('r? patches: {}'.format(patch_ids))
        Patch.save_patches(patch_ids)
        patches_to_send = self.patches_to_send_to_buildbot(patch_ids)
        _log.info('{} r? patches, {} patches need to be sent to Buildbot.'.format(len(patch_ids), len(patches_to_send)))

        for patch_id in patches_to_send:
            bz_patch = Bugzilla.retrieve_attachment(patch_id)
            if not bz_patch or bz_patch['id'] != patch_id:
                _log.error('Unable to retrive patch "{}"'.format(patch_id))
                continue
            if bz_patch.get('is_obsolete'):
                _log.warn('Patch is obsolete, skipping')
                Patch.set_obsolete(patch_id)
                continue
            rc = Buildbot.send_patch_to_buildbot(bz_patch['path'],
                     properties=['patch_id={}'.format(patch_id), 'bug_id={}'.format(bz_patch['bug_id']), 'owner={}'.format(bz_patch.get('creator', ''))])
            if rc == 0:
                Patch.set_bug_id(patch_id, bz_patch['bug_id'])
                Patch.set_sent_to_buildbot(patch_id)
            else:
                _log.error('Failed to send patch to buildbot.')
                #FIXME: send an email for this failure
        return patch_ids
Пример #5
0
    def post(self, request):
        try:
            patch_id = request.POST.get('patch_id')
            patch_id = int(patch_id)
        except:
            return HttpResponse("Invalid patch id {}".format(
                request.POST.get('patch_id')))

        _log.info('SubmitToEWS::patch: {}'.format(patch_id))
        if Patch.is_patch_sent_to_buildbot(patch_id):
            _log.info(
                'SubmitToEWS::patch {} already submitted'.format(patch_id))
            if request.POST.get('next_action') == 'return_to_bubbles':
                return redirect('/status-bubble/{}'.format(patch_id))
            return HttpResponse(
                "Patch {} already submitted. Please wait for status-bubbles.".
                format(patch_id))

        rc = BugzillaPatchFetcher().fetch([patch_id])
        if rc == ERR_UNABLE_TO_FETCH_PATCH:
            return HttpResponse(
                'EWS is unable to access patch {}. Please ensure that this patch is publicly accessible or has r? set.'
                .format(patch_id))
        if rc == ERR_OBSOLETE_PATCH:
            return HttpResponse(
                'Patch {} is obsolete, not submitting to EWS.'.format(
                    patch_id))

        if request.POST.get('next_action') == 'return_to_bubbles':
            return redirect('/status-bubble/{}'.format(patch_id))
        return HttpResponse("Submitted patch {} to EWS.".format(patch_id))
Пример #6
0
    def patches_to_send_to_commit_queue(self, patch_ids):
        if not patch_ids:
            return patch_ids
        patches_in_queue = set(Buildbot.get_patches_in_queue('Commit-Queue'))
        patch_ids = [
            patch_id for patch_id in set(patch_ids)
            if str(patch_id) not in patches_in_queue
        ]

        patch_ids_to_send = []
        for patch_id in patch_ids:
            patch = Patch.get_patch(patch_id)
            recent_build, _ = StatusBubble().get_latest_build_for_queue(
                patch, 'commit')
            if not recent_build:
                patch_ids_to_send.append(patch_id)
                continue
            recent_build_timestamp = datetime.datetime.fromtimestamp(
                recent_build.complete_at, tz=pytz.UTC)
            cq_timestamp = Bugzilla.get_cq_plus_timestamp(patch_id)
            if not cq_timestamp:
                patch_ids_to_send.append(patch_id)
                continue
            if cq_timestamp > recent_build_timestamp:
                patch_ids_to_send.append(patch_id)
        return patch_ids_to_send
Пример #7
0
 def find_failed_builds_for_patch(self, patch_id):
     patch = Patch.get_patch(patch_id)
     if not patch:
         return []
     failed_builds = []
     for queue in StatusBubble.ALL_QUEUES:
         build, _ = self.get_latest_build_for_queue(patch, queue)
         if not build:
             continue
         if build.result in (Buildbot.FAILURE, Buildbot.EXCEPTION, Buildbot.CANCELLED):
             failed_builds.append(build)
     return failed_builds
Пример #8
0
    def get(self, request, patch_id):
        patch_id = int(patch_id)
        patch = Patch.get_patch(patch_id)
        bubbles, show_submit_to_ews, show_failure_to_apply = self._build_bubbles_for_patch(patch)

        template_values = {
            'bubbles': bubbles,
            'patch_id': patch_id,
            'show_submit_to_ews': show_submit_to_ews,
            'show_failure_to_apply': show_failure_to_apply,
        }
        return render(request, 'statusbubble.html', template_values)
Пример #9
0
    def get(self, request, patch_id):
        hide_icons = request.GET.get('hide_icons', False)
        patch_id = int(patch_id)
        patch = Patch.get_patch(patch_id)
        bubbles, show_submit_to_ews, show_failure_to_apply, show_retry = self._build_bubbles_for_patch(patch, hide_icons)

        template_values = {
            'bubbles': bubbles,
            'patch_id': patch_id,
            'show_submit_to_ews': show_submit_to_ews,
            'show_failure_to_apply': show_failure_to_apply,
            'show_retry_button': show_retry,
        }
        return render(request, 'statusbubble.html', template_values)
Пример #10
0
    def _fetch_attachment_json(cls, attachment_id):
        if not Patch.is_valid_patch_id(attachment_id):
            _log.warn('Invalid attachment id: "{}", skipping download.'.format(
                attachment_id))
            return None

        attachment_url = '{}rest/bug/attachment/{}'.format(
            config.BUG_SERVER_URL, attachment_id)
        attachment = util.fetch_data_from_url(attachment_url)
        if not attachment:
            return None
        attachment_json = attachment.json().get('attachments')
        if not attachment_json or len(attachment_json) == 0:
            return None
        return attachment_json.get(str(attachment_id))
Пример #11
0
    def post(self, request):
        try:
            patch_id = request.POST.get('patch_id')
            patch_id = int(patch_id)
        except:
            return HttpResponse("Invalid patch id {}".format(request.POST.get('patch_id')))

        _log.debug('SubmitToEWS::patch: {}'.format(patch_id))
        if Patch.is_patch_sent_to_buildbot(patch_id):
            _log.info('SubmitToEWS::patch {} already submitted'.format(patch_id))
            if request.POST.get('next_action') == 'return_to_bubbles':
                return redirect('/status-bubble/{}'.format(patch_id))
            return HttpResponse("Patch {} already submitted. Please wait for status-bubbles.".format(patch_id))

        BugzillaPatchFetcher().fetch([patch_id])

        if request.POST.get('next_action') == 'return_to_bubbles':
            return redirect('/status-bubble/{}'.format(patch_id))
        return HttpResponse("Submitted patch {} to EWS.".format(patch_id))
Пример #12
0
 def filter_valid_patches(cls, patch_ids):
     return list(filter(lambda p: Patch.is_valid_patch_id(p), patch_ids))
Пример #13
0
 def patches_to_send_to_buildbot(self, patch_ids):
     return [patch_id for patch_id in patch_ids if not Patch.is_patch_sent_to_buildbot(patch_id)]
Пример #14
0
 def get(self, request, patch_id):
     patch_id = int(patch_id)
     patch = Patch.get_patch(patch_id)
     response_data = self._build_statuses_for_patch(patch)
     return JsonResponse(response_data)
Пример #15
0
 def patches_to_send_to_buildbot(self, patch_ids, commit_queue=False):
     return [
         patch_id for patch_id in patch_ids
         if not Patch.is_patch_sent_to_buildbot(patch_id, commit_queue)
     ]