Created
February 17, 2016 22:08
-
-
Save jmaher/c3f89ec173dfe7b35e81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import datetime | |
import operator | |
import requests | |
from collections import defaultdict | |
def get_orangefactor_bugs(platform='linux', startday=None, endday=None): | |
endday = datetime.date.today() if endday is None else endday | |
startday = endday - datetime.timedelta(days=7) if startday is None else endday | |
r = requests.get('https://brasstacks.mozilla.com/orangefactor/api/bybug?startday={startday}&endday={endday}&platform={platform}&type=All&test=All&tree=trunk'.format( | |
platform=platform, | |
startday=startday.isoformat(), | |
endday=endday.isoformat(), | |
)) | |
if r.status_code != 200: | |
raise Exception('Failed to get orangefactor data: HTTP status %d' % r.status_code) | |
data = r.json() | |
for bug in data['bugs'].itervalues(): | |
bug['oranges'] = [] | |
for _, oranges in data['oranges'].iteritems(): | |
for orange in oranges['oranges']: | |
data['bugs'][orange['bug']]['oranges'].append(orange) | |
return sorted(data['bugs'].values(), | |
key=lambda b: len(b['oranges']), | |
reverse=True) | |
def main(): | |
for bug in get_orangefactor_bugs()[:50]: | |
builds = set(o['buildtype'] for o in bug['oranges']) | |
if 'opt' in builds or 'debug' in builds: | |
if bug['status'] == 'RESOLVED': | |
continue | |
try: | |
if bug['summary'].index('browser_') >= 0: | |
continue | |
except: | |
pass | |
try: | |
if bug['summary'].index('taskcluster') >= 0: | |
continue | |
except: | |
pass | |
try: | |
if bug['summary'].index('leakcheck') >= 0: | |
continue | |
except: | |
pass | |
try: | |
if bug['summary'].index('No tests run') >= 0: | |
continue | |
except: | |
pass | |
tests = defaultdict(int) | |
for o in bug['oranges']: | |
testname = o['test'].split()[-1] if o['test'].startswith('[TC]') else o['test'] | |
if testname.startswith('mochitest-devtools') or \ | |
testname.startswith('mochitest-e10s-browser-chrome'): | |
continue | |
if not testname.startswith('mochitest') and \ | |
not testname.startswith('web-platform-tests') and \ | |
not testname.startswith('jetpack') and \ | |
not testname.startswith('gtest') and \ | |
not testname.startswith('reftest') and \ | |
not testname.startswith('crashtest'): | |
continue | |
tests[testname] += 1 | |
if len(tests) > 0: | |
print('{} - {}'.format(bug['status'], bug['summary'])) | |
for test, count in sorted(tests.iteritems(), key=operator.itemgetter(1), reverse=True): | |
print('\t{}\t{}'.format(count, test)) | |
print() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment