Exemple #1
0
    def CheckBuild(self):
        _, out, _ = self.Call('git-cl issue')

        issue = int(out.split()[2])

        _, out, _ = self.Call('git config user.email')
        email = ''
        rpc_server = upload.GetRpcServer(CODE_REVIEW_SERVER, email)
        try:
            props = json.loads(rpc_server.Send('/api/%d' % issue))
        except Exception as e:
            print('Failed to load patch data: %s' % e)
            return {}

        patchset = int(props['patchsets'][-1])

        try:
            try_job_results = json.loads(
                rpc_server.Send('/api/%d/%d/try_job_results' %
                                (issue, patchset)))
        except Exception as e:
            print('Failed to load try job results: %s' % e)
            return {}

        if not try_job_results:
            print('No try jobs found on most recent patchset')
            return {}

        results = {}
        for job in try_job_results:
            builder = job['builder']
            if builder == 'linux_chromium_gn_upload':
                platform = 'linux64'
            elif builder == 'mac_chromium_gn_upload':
                platform = 'mac'
            elif builder == 'win8_chromium_gn_upload':
                platform = 'win'
            else:
                print('Unexpected builder: %s')
                continue

            TRY_JOB_RESULT_STATES = ('started', 'success', 'warnings',
                                     'failure', 'skipped', 'exception',
                                     'retry', 'pending')
            state = TRY_JOB_RESULT_STATES[int(job['result']) + 1]
            url_str = ' %s' % job['url']
            build = url_str.split('/')[-1]

            sha1 = '-'
            results.setdefault(platform, {
                'build': -1,
                'sha1': '',
                'url': url_str
            })

            if state == 'success':
                jsurl = url_str.replace(
                    'http://build.chromium.org/',
                    'http://chrome-build-extract.appspot.com/')
                jsurl = jsurl + '?json=1'
                try:
                    fp = urllib2.urlopen(jsurl)
                except urllib2.HTTPError as e:
                    print('Failed to open %s: %s' % (jsurl, e))
                    return {}

                js = json.loads(fp.read())
                fp.close()
                sha1_step_name = 'gn sha1'
                for step in js['steps']:
                    if step['name'] == sha1_step_name:
                        # TODO: At some point infra changed the step text to
                        # contain the step name; once all of the masters have been
                        # restarted we can probably assert that the step text
                        # with the step_name.
                        sha1_step_text_prefix = sha1_step_name + '<br>'
                        if step['text'][-1].startswith(sha1_step_text_prefix):
                            sha1 = step['text'][-1][len(sha1_step_text_prefix
                                                        ):]
                        else:
                            sha1 = step['text'][-1]

            if results[platform]['build'] < build:
                results[platform]['build'] = build
                results[platform]['sha1'] = sha1
                results[platform]['state'] = state
                results[platform]['url'] = url_str

        for platform, r in results.items():
            print(platform)
            print('  sha1:  %s' % r['sha1'])
            print('  state: %s' % r['state'])
            print('  build: %s' % r['build'])
            print('  url:   %s' % r['url'])
            print()

        return results
Exemple #2
0
    def CheckBuild(self):
        _, out, _ = self.Call('git-cl issue')

        issue = int(out.split()[2])

        _, out, _ = self.Call('git config user.email')
        email = ''
        rpc_server = upload.GetRpcServer(CODE_REVIEW_SERVER, email)
        try:
            props = json.loads(rpc_server.Send('/api/%d' % issue))
        except Exception as _e:
            raise

        patchset = int(props['patchsets'][-1])

        try:
            try_job_results = json.loads(
                rpc_server.Send('/api/%d/%d/try_job_results' %
                                (issue, patchset)))
        except Exception as _e:
            raise

        if not try_job_results:
            print('No try jobs found on most recent patchset')
            return {}

        results = {}
        for job in try_job_results:
            builder = job['builder']
            if builder == 'linux_chromium_gn_upload':
                platform = 'linux64'
            elif builder == 'mac_chromium_gn_upload':
                platform = 'mac'
            elif builder == 'win8_chromium_gn_upload':
                platform = 'win'
            else:
                print('Unexpected builder: %s')
                continue

            TRY_JOB_RESULT_STATES = ('started', 'success', 'warnings',
                                     'failure', 'skipped', 'exception',
                                     'retry', 'pending')
            state = TRY_JOB_RESULT_STATES[int(job['result']) + 1]
            url_str = ' %s' % job['url']
            build = url_str.split('/')[-1]

            sha1 = '-'
            results.setdefault(platform, {
                'build': -1,
                'sha1': '',
                'url': url_str
            })

            if state == 'success':
                jsurl = url_str.replace('/builders/', '/json/builders/')
                fp = urllib2.urlopen(jsurl)
                js = json.loads(fp.read())
                fp.close()
                for step in js['steps']:
                    if step['name'] == 'gn sha1':
                        sha1 = step['text'][1]

            if results[platform]['build'] < build:
                results[platform]['build'] = build
                results[platform]['sha1'] = sha1
                results[platform]['state'] = state
                results[platform]['url'] = url_str

        for platform, r in results.items():
            print(platform)
            print('  sha1:  %s' % r['sha1'])
            print('  state: %s' % r['state'])
            print('  build: %s' % r['build'])
            print('  url:   %s' % r['url'])
            print()

        return results