Bug 1881774 - point browsertime-mobile at fenix-nightly-simulation builds. r=sparky...
[gecko.git] / taskcluster / android_taskgraph / transforms / browsertime.py
blob4bba655e11dc272c4f01fd9928e4be458adbaadf
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 Apply some defaults and minor modifications to the jobs defined in the build
6 kind.
7 """
9 import copy
10 import json
11 from copy import deepcopy
13 from taskgraph.transforms.base import TransformSequence
14 from taskgraph.util.schema import resolve_keyed_by
15 from taskgraph.util.treeherder import inherit_treeherder_from_dep
17 transforms = TransformSequence()
20 @transforms.add
21 def split_raptor_subtests(config, tests):
22 for test in tests:
23 # For tests that have 'page-load-tests' listed, we want to create a separate
24 # test job for every subtest (i.e. split out each page-load URL into its own job)
25 subtests = test.pop("page-load-tests", None)
26 if not subtests:
27 yield test
28 continue
30 for subtest in subtests:
31 pageload_test = deepcopy(test)
33 if isinstance(subtest, list):
34 pageload_test["test-name"] = subtest[0]
35 pageload_test["subtest-symbol"] = subtest[1]
36 else:
37 pageload_test["test-name"] = subtest
38 pageload_test["subtest-symbol"] = subtest
39 yield pageload_test
42 @transforms.add
43 def add_variants(config, tasks):
44 only_types = config.config["only-for-build-types"]
45 only_abis = config.config["only-for-abis"]
47 tests = list(tasks)
49 for dep_task in config.kind_dependencies_tasks.values():
50 build_type = dep_task.attributes.get("build-type", "")
51 if build_type not in only_types:
52 continue
54 for abi, apk_metadata in dep_task.attributes["apks"].items():
55 if abi not in only_abis:
56 continue
57 apk_path = apk_metadata["name"]
58 for test in tests:
59 test = copy.deepcopy(test)
60 attributes = copy.deepcopy(dep_task.attributes)
61 attributes.update(test.get("attributes", {}))
62 attributes["abi"] = abi
63 attributes["apk"] = apk_path
64 test["attributes"] = attributes
65 test["primary-dependency"] = dep_task
66 yield test
69 @transforms.add
70 def build_browsertime_task(config, tasks):
71 for task in tasks:
72 signing = task.pop("primary-dependency")
73 task.setdefault("dependencies", {})["signing"] = signing.label
74 build_type = task["attributes"]["build-type"]
75 abi = task["attributes"]["abi"]
76 apk = task["attributes"]["apk"]
78 for key in ("args", "treeherder.platform", "worker-type"):
79 resolve_keyed_by(task, key, item_name=task["name"], **{"abi": abi})
81 task["treeherder"] = inherit_treeherder_from_dep(task, signing)
83 test_name = task.pop("test-name")
84 platform = task["treeherder"]["platform"]
86 task_name = "{}-{}-{}-{}".format(platform, test_name, build_type, abi)
87 task["name"] = task_name
88 task["description"] = task_name
90 extra_config = {
91 "installer_url": "<signing/{}>".format(apk),
92 "test_packages_url": "<geckoview-nightly/public/build/en-US/target.test_packages.json>",
94 env = task["worker"]["env"]
95 env["EXTRA_MOZHARNESS_CONFIG"] = {
96 "artifact-reference": json.dumps(extra_config, sort_keys=True)
98 env["GECKO_HEAD_REV"] = "default"
99 env["MOZILLA_BUILD_URL"] = {"artifact-reference": "<signing/{}>".format(apk)}
100 env["MOZHARNESS_URL"] = {
101 "artifact-reference": "<geckoview-nightly/public/build/en-US/mozharness.zip>"
103 env["TASKCLUSTER_WORKER_TYPE"] = task["worker-type"]
105 worker = task["worker"]
106 worker.setdefault("mounts", []).append(
108 "content": {
109 "url": "https://hg.mozilla.org/mozilla-central/raw-file/default/taskcluster/scripts/tester/test-linux.sh"
111 "file": "./test-linux.sh",
114 task["run"]["command"].append("--test={}".format(test_name))
115 task["run"]["command"].extend(task.pop("args", []))
117 # Setup treherder symbol
118 symbol = task.pop("subtest-symbol", None)
120 # taskcluster is merging task attributes with the default ones
121 # resulting the --cold extra option in the ytp warm tasks
122 if "youtube-playback" in task["name"]:
123 symbol = test_name.replace("youtube-playback-", "ytp-")
125 # Setup chimera for combined warm+cold testing
126 if task.pop("chimera", False):
127 task["run"]["command"].append("--chimera")
129 # Add '-c' to taskcluster symbol when running cold tests
130 elif "--cold" in task["run"]["command"]:
131 symbol += "-c"
133 # Setup visual metrics
134 run_visual_metrics = task.pop("run-visual-metrics", False)
135 if run_visual_metrics:
136 task["run"]["command"].append("--browsertime-video")
137 task["run"]["command"].append("--browsertime-visualmetrics")
138 task["run"]["command"].append("--browsertime-no-ffwindowrecorder")
140 # Build taskcluster group and symol
141 task["treeherder"]["symbol"] = "Btime(%s)" % symbol
142 task["name"] = (
143 task["name"].replace("tp6m-", "tp6m-{}-".format(symbol)).replace("-hv", "")
145 yield task
148 @transforms.add
149 def setup_nofis(config, tasks):
150 for task in tasks:
151 if task.pop("run-with-fission", False):
152 # Don't continue after this since this flag says
153 # that a fission and a non-fission variant should
154 # run
155 fission_task = copy.deepcopy(task)
156 yield fission_task
158 # Disable fission
159 task["run"]["command"].append("--disable-fission")
161 # Build taskcluster group and symol
162 task["treeherder"]["symbol"] = task["treeherder"]["symbol"].replace(
163 "Btime", "Btime-nofis"
165 task["name"] += "-nofis"
167 yield task
170 @transforms.add
171 def fill_email_data(config, tasks):
172 product_name = config.params["project"]
173 format_kwargs = {
174 "product_name": product_name.lower(),
175 "head_rev": config.params["head_rev"],
178 for task in tasks:
179 format_kwargs["task_name"] = task["name"]
181 resolve_keyed_by(
182 task, "notify", item_name=task["name"], level=config.params["level"]
184 email = task["notify"].get("email")
185 if email:
186 email["link"]["href"] = email["link"]["href"].format(**format_kwargs)
187 email["subject"] = email["subject"].format(**format_kwargs)
189 yield task