def get_tasks_in_group(group_id): tasks = [] def _save_tasks(response): tasks.extend(response["tasks"]) queue = taskcluster.get_service("queue") queue.listTaskGroup(group_id, paginationHandler=_save_tasks) return tasks
def download_artifact(task_id, artifact, artifacts_path): fname = os.path.join(artifacts_path, task_id + "_" + os.path.basename(artifact["name"])) # As recommended by Taskcluster doc, use requests to download # from the artifact public url instead of relying on the client method queue = taskcluster.get_service("queue") url = queue.buildUrl("getLatestArtifact", task_id, artifact["name"]) if not os.path.exists(fname): download_binary(url, fname) return fname
def download_grcov(): local_path = "grcov" local_version = "grcov_ver" dest = tempfile.mkdtemp(suffix="grcov") archive = os.path.join(dest, "grcov.tar.xz") index = taskcluster.get_service("index") url = index.buildUrl("findArtifactFromTask", GRCOV_INDEX, GRCOV_ARTIFACT) download_binary(url, archive) # Extract archive in temp tar = tarfile.open(archive, "r:xz") tar.extractall(dest) tar.close() os.remove(archive) # Get version from grcov binary grcov = os.path.join(dest, "grcov") assert os.path.exists(grcov), "Missing grcov binary" version = subprocess.check_output([grcov, "--version"]).decode("utf-8") # Compare version with currently available if os.path.exists(local_path) and os.path.exists(local_version): with open(local_version, "r") as f: installed_ver = f.read() if installed_ver == version: return local_path # Promote downloaded version to installed one shutil.move(grcov, local_path) shutil.rmtree(dest) with open(local_version, "w") as f: f.write(version) return local_path
def get_task_artifacts(task_id): queue = taskcluster.get_service("queue") response = queue.listLatestArtifacts(task_id) return response["artifacts"]
def get_task_details(task_id): queue = taskcluster.get_service("queue") return queue.task(task_id)
def get_task(branch, revision): index = taskcluster.get_service("index") task = index.findTask(f"gecko.v2.{branch}.revision.{revision}.taskgraph.decision") return task["taskId"]
def get_task_status(task_id): queue = taskcluster.get_service("queue") status = queue.status(task_id) return status["status"]["state"]