Skip to content

Instantly share code, notes, and snippets.

@jwmoss
Created October 24, 2024 18:18
Show Gist options
  • Save jwmoss/e1b625a5361b632ed3ca3b7272fb1f2f to your computer and use it in GitHub Desktop.
Save jwmoss/e1b625a5361b632ed3ca3b7272fb1f2f to your computer and use it in GitHub Desktop.
parse_task
# pip install mozci
# pip install zstandard
import requests
import sys
from mozci.util.taskcluster import get_task
#input_task_id = "OkI2h843RBGsyOzo5NH1Dg"
input_task_id = sys.argv[1]
# download the log/task info
task = get_task(input_task_id)
# fetch mounts (mozharness.zip, run-task, fetch-content)
mounts = task["payload"]["mounts"]
for m in mounts:
if 'url' in m["content"]:
print("wget %s" % m["content"]["url"])
elif 'taskId' in m["content"]:
url = "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/%s/runs/0/artifacts/%s" % (m["content"]["taskId"], m["content"]["artifact"])
fname = m["content"]["artifact"].split('/')[-1]
print("wget -O %s %s" % (fname, url))
print("mkdir %s" % m["directory"])
print("mv %s %s/" % (fname, m["directory"]))
print("pushd %s" % m["directory"])
print("unzip %s" % fname)
print("popd")
else:
print("# " + m)
print("\n")
# get the env vars
env = task["payload"]["env"]
for e in env:
print("export %s='%s'" % (e, env[e]))
print("export TASKCLUSTER_ROOT_URL='https://firefox-ci-tc.services.mozilla.com'")
print("\n")
# get the top level script command to setup and rerun
command = task["payload"]["command"]
print(command[0].replace('\\', '/'))
print("\n")
# for future debugging, get the individual harness command
# parse the live_backing.log, look for
url = "https://firefoxci.taskcluster-artifacts.net/%s/0/public/logs/live_backing.log" % input_task_id
r = requests.get(url)
lines = r.text
for line in lines.split('\n'):
if 'USERNAME' in line:
task_username = line.split("'USERNAME': ")[1].strip().strip("'")
if 'INFO - Copy/paste:' in line and 'python -u' in line:
cmd = line.split('INFO - Copy/paste: ')[-1].replace("%s\\" % task_username, "").replace("\\", "/")
print("# uncomment this to run repeated and target specific tests")
print("# %s" % cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment