condprof.py (3819B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 """ 5 This transform constructs tasks generate conditioned profiles from 6 the condprof/kind.yml file 7 """ 8 9 from taskgraph.transforms.base import TransformSequence 10 from taskgraph.util.copy import deepcopy 11 from taskgraph.util.schema import Schema 12 from voluptuous import Optional 13 14 from gecko_taskgraph.transforms.job import job_description_schema 15 from gecko_taskgraph.transforms.task import task_description_schema 16 17 diff_description_schema = Schema({ 18 # default is settled, but add 'full' to get both 19 Optional("scenarios"): [str], 20 Optional("description"): task_description_schema["description"], 21 Optional("dependencies"): task_description_schema["dependencies"], 22 Optional("fetches"): job_description_schema["fetches"], 23 Optional("index"): task_description_schema["index"], 24 Optional("task-from"): str, 25 Optional("name"): str, 26 Optional("run"): job_description_schema["run"], 27 Optional("run-on-projects"): task_description_schema["run-on-projects"], 28 Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"], 29 Optional("scopes"): task_description_schema["scopes"], 30 Optional("treeherder"): task_description_schema["treeherder"], 31 Optional("use-python"): job_description_schema["use-python"], 32 Optional("worker"): job_description_schema["worker"], 33 Optional("worker-type"): task_description_schema["worker-type"], 34 }) 35 36 transforms = TransformSequence() 37 transforms.add_validate(diff_description_schema) 38 39 40 @transforms.add 41 def generate_scenarios(config, tasks): 42 for task in tasks: 43 cmds = task["run"]["command"] 44 symbol = task["treeherder"]["symbol"].split(")")[0] 45 index = task["index"] 46 jobname = index["job-name"] 47 label = task["name"] 48 run_as_root = task["run"].get("run-as-root", False) 49 50 for scenario in set(task["scenarios"]): 51 extra_args = "" 52 if scenario == "settled": 53 extra_args = " --force-new " 54 55 tcmd = cmds.replace("${EXTRA_ARGS}", extra_args) 56 tcmd = tcmd.replace("${SCENARIO}", scenario) 57 58 index["job-name"] = "%s-%s" % (jobname, scenario) 59 60 taskdesc = { 61 "name": "%s-%s" % (label, scenario), 62 "description": task["description"], 63 "treeherder": { 64 "symbol": "%s-%s)" % (symbol, scenario), 65 "platform": task["treeherder"]["platform"], 66 "kind": task["treeherder"]["kind"], 67 "tier": task["treeherder"]["tier"], 68 }, 69 "worker-type": deepcopy(task["worker-type"]), 70 "worker": deepcopy(task["worker"]), 71 "index": deepcopy(index), 72 "run": { 73 "using": "run-task", 74 "cwd": task["run"]["cwd"], 75 "checkout": task["run"]["checkout"], 76 "tooltool-downloads": deepcopy(task["run"]["tooltool-downloads"]), 77 "command": tcmd, 78 "run-as-root": run_as_root, 79 }, 80 "run-on-projects": deepcopy(task["run-on-projects"]), 81 "run-on-repo-type": task.get("run-on-repo-type", ["git", "hg"]), 82 "scopes": deepcopy(task["scopes"]), 83 "dependencies": deepcopy(task["dependencies"]), 84 "fetches": deepcopy(task["fetches"]), 85 } 86 87 use_taskcluster_python = task.get("use-python", "system") 88 if use_taskcluster_python != "system": 89 taskdesc["use-python"] = use_taskcluster_python 90 91 yield taskdesc