Created
December 4, 2018 16:01
-
-
Save tomrittervg/3cc0f08995a7cb71a2c66317204c0340 to your computer and use it in GitHub Desktop.
Treeherder Query - for programatically searching try pushes matching criteria
This file contains hidden or 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 | |
import os | |
import pdb | |
import json | |
import datetime | |
import requests | |
import argparse | |
COUNT=500 | |
BASEURL = "https://treeherder.mozilla.org/api/project/try/resultset/[email protected]&count=" + str(COUNT) + "&format=json" | |
HEADERS = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0'} | |
search_jobs = False | |
search_revisions = True | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Find Treeherder Runs that fill a crieria') | |
args = parser.parse_args() | |
# Get Try Pushes | |
r = requests.get(BASEURL, headers=HEADERS) | |
try_runs = json.loads(r.text) | |
# Loop through try pushes | |
for run in try_runs['results']: | |
if search_revisions: | |
for rev in run['revisions']: | |
if 'timeout' in rev['comments']: | |
print "Matched a job at https://treeherder.mozilla.org/#/jobs?repo=try&revision=%s" % \ | |
(run['revision']) | |
if search_jobs: | |
# Get jobs for this push | |
r = requests.get('https://treeherder.mozilla.org/api/project/try/jobs/?format=json&count=2000&push_id=' + str(run['id']), headers=HEADERS) | |
jobs = json.loads(r.text) | |
# Loop through the jobs | |
for job in jobs['results']: | |
if 'build-win64-mingwclang' in job['job_type_name'] and job['result'] == 'success': | |
print "Successful job on %s at https://treeherder.mozilla.org/#/jobs?repo=try&revision=%s" % \ | |
(datetime.datetime.utcfromtimestamp(job['end_timestamp']), run['revision']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment