async def get_action_tasks(session, pushlog_id, index_repo): async with async_timeout.timeout(100): index_string = ACTION_INDEX.format(pushid=pushlog_id, repo=index_repo) index = Index(session=session) data = await index.listTasks(index_string) tasks = [t['taskId'] for t in data['tasks']] return tasks
async def test_verify_production_cot(branch_context): index = Index(options={"rootUrl": branch_context["taskcluster_root_url"]}) queue = Queue(options={"rootUrl": branch_context["taskcluster_root_url"]}) async def get_task_id_from_index(index_path): res = await index.findTask(index_path) return res["taskId"] async def get_completed_task_info_from_labels(decision_task_id, label_to_task_type): label_to_taskid = await queue.getLatestArtifact( decision_task_id, "public/label-to-taskid.json") task_info = {} for re_label, task_type in label_to_task_type.items(): r = re.compile(re_label) for label, task_id in label_to_taskid.items(): if r.match(label): status = await queue.status(task_id) # only run verify_cot against tasks with completed deps. if status["status"]["state"] in ("completed", "running", "pending", "failed"): task_info[task_id] = task_type break else: log.warning( "Not running verify_cot against {} {} because there are no elegible completed tasks" .format(decision_task_id, task_type)) return task_info async def verify_cot(name, task_id, task_type, check_task=True): log.info("Verifying {} {} {}...".format(name, task_id, task_type)) context.task = await queue.task(task_id) cot = ChainOfTrust(context, task_type, task_id=task_id) await verify_chain_of_trust(cot, check_task=check_task) async with get_context({ "cot_product": branch_context["cot_product"], "verify_cot_signature": True }) as context: context.queue = queue task_id = await get_task_id_from_index(branch_context["index"]) assert task_id, "{}: Can't get task_id from index {}!".format( branch_context["name"], branch_context["index"]) if branch_context.get("task_label_to_task_type"): task_info = await get_completed_task_info_from_labels( task_id, branch_context["task_label_to_task_type"]) assert "check_task" not in branch_context, "{}: Can't disable check_task.".format( branch_context["name"], ) for task_id, task_type in task_info.items(): name = "{} {}".format(branch_context["name"], task_type) await verify_cot(name, task_id, task_type) else: await verify_cot( branch_context["name"], task_id, branch_context["task_type"], branch_context.get("check_task", True), )
async def test_verify_production_cot(branch_context): index = Index(options={'rootUrl': DEFAULT_CONFIG['taskcluster_root_url']}) queue = Queue(options={'rootUrl': DEFAULT_CONFIG['taskcluster_root_url']}) async def get_task_id_from_index(index_path): res = await index.findTask(index_path) return res['taskId'] async def get_completed_task_info_from_labels(decision_task_id, label_to_task_type): label_to_taskid = await queue.getLatestArtifact( decision_task_id, "public/label-to-taskid.json") task_info = {} for re_label, task_type in label_to_task_type.items(): r = re.compile(re_label) for label, task_id in label_to_taskid.items(): if r.match(label): status = await queue.status(task_id) # only run verify_cot against tasks with completed deps. if status['status']['state'] in ('completed', 'running', 'pending', 'failed'): task_info[task_id] = task_type break else: log.warning( "Not running verify_cot against {} {} because there are no elegible completed tasks" .format(decision_task_id, task_type)) return task_info async def verify_cot(name, task_id, task_type): log.info("Verifying {} {} {}...".format(name, task_id, task_type)) context.task = await queue.task(task_id) cot = ChainOfTrust(context, task_type, task_id=task_id) await verify_chain_of_trust(cot) async with get_context({'cot_product': branch_context['cot_product']}) as context: context.queue = queue task_id = await get_task_id_from_index(branch_context['index']) assert task_id, "{}: Can't get task_id from index {}!".format( branch_context['name'], branch_context['index']) if branch_context.get('task_label_to_task_type'): task_info = await get_completed_task_info_from_labels( task_id, branch_context['task_label_to_task_type']) for task_id, task_type in task_info.items(): name = "{} {}".format(branch_context['name'], task_type) await verify_cot(name, task_id, task_type) else: await verify_cot(branch_context['name'], task_id, branch_context['task_type'])
async def load_nightly_graph(dt=None, platform='linux-opt'): """Given a date, load the relevant nightly task graph.""" async with aiohttp.ClientSession() as session: index = Index(options=tc_options(), session=session) queue = Queue(options=tc_options(), session=session) if not dt: dt = datetime.now() datestr = dt.strftime("%Y.%m.%d") basestr = "gecko.v2.mozilla-central.nightly.{date}.latest.firefox.{platform}" found = await index.findTask(basestr.format(date=datestr, platform=platform)) taskid = found.get('taskId') taskdef = await queue.task(taskid) # except taskcluster.exceptions.TaskclusterRestFailure: taskgroup = taskdef.get('taskGroupId') log.debug("Looking at {} for {}".format(taskgroup, datestr)) if taskgroup: return {'date': datestr, 'graph': await TaskGraph(taskgroup)} return None