forked from mozilla/mozilla_ci_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import logging | ||
|
||
from thclient import TreeherderClient | ||
|
||
|
||
LOG = logging.getLogger('mozci') | ||
PENDING, RUNNING, COALESCED, UNKNOWN = range(-4, 0) | ||
SUCCESS, WARNING, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELLED = range(7) | ||
|
||
|
||
def query_jobs_schedule(repo_name, revision): | ||
""" | ||
Return all jobs for a given revision | ||
""" | ||
treeherder_client = TreeherderClient() | ||
results = treeherder_client.get_resultsets(repo_name, revision=revision) | ||
revision_id = results[0]["id"] | ||
all_jobs = treeherder_client.get_jobs(repo_name, count=2000, result_set_id=revision_id) | ||
return all_jobs | ||
|
||
|
||
def _matching_jobs(buildername, all_jobs): | ||
""" | ||
Return all jobs that matched the criteria. | ||
""" | ||
matching_jobs = [] | ||
for j in all_jobs: | ||
if j["ref_data_name"] == buildername: | ||
matching_jobs.append(j) | ||
|
||
return matching_jobs | ||
|
||
|
||
def query_job_status(job): | ||
""" | ||
Helper to determine the scheduling status of a job from treeherder. | ||
""" | ||
if job["result"] == "unknown": | ||
if job["state"] == "pending": | ||
return PENDING | ||
elif job["state"] == "running": | ||
return RUNNING | ||
else: | ||
return UNKNOWN | ||
|
||
if job["job_coalesced_to_guid"] is not None: | ||
return COALESCED | ||
|
||
if job["state"] == "completed": | ||
if job["result"] == "success": | ||
return SUCCESS | ||
elif job["result"] == "busted" or job["result"] == "testfailed": | ||
return FAILURE | ||
elif job["result"] == "skipped": | ||
return SKIPPED | ||
elif job["result"] == "exception": | ||
return EXCEPTION | ||
elif job["result"] == "retry": | ||
return RETRY | ||
elif job["result"] == "usercancel": | ||
return CANCELLED | ||
|
||
raise Exception("Unexpected status") |
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