Bug 1608026 - [tryselect] Switch 'try_task_config.json' files to version 2, r=releng-reviewers,perftest-reviewers,taskgraph-reviewers,sparky,jcristau

We've long supported a version 2 for try_task_config.json. v2 is a superset of
v1, so there's no point in using the v1 anymore.

I'm making this change now because I'd like to implement a feature that would
only be supported using v2.

Differential Revision: https://phabricator.services.mozilla.com/D199734
This commit is contained in:
Andrew Halberstadt 2024-01-31 16:08:09 +00:00
Родитель fb0a510531
Коммит 7a1d26a26c
21 изменённых файлов: 377 добавлений и 256 удалений

Просмотреть файл

@ -40,6 +40,7 @@ schema.EXCEPTED_SCHEMA_IDENTIFIERS.extend(
"video_location",
"profile_name",
"target_path",
"try_task_config",
]
)

Просмотреть файл

@ -428,7 +428,7 @@ def set_try_config(parameters, task_config_file):
parameters["try_task_config"] = task_config
elif task_config_version == 2:
parameters.update(task_config["parameters"])
return
parameters["try_mode"] = "try_task_config"
else:
raise Exception(
f"Unknown `try_task_config.json` version: {task_config_version}"
@ -444,11 +444,7 @@ def set_try_config(parameters, task_config_file):
# The user has explicitly requested a set of jobs, so run them all
# regardless of optimization. Their dependencies can be optimized,
# though.
parameters["optimize_target_tasks"] = False
else:
# For a try push with no task selection, apply the default optimization
# process to all of the tasks.
parameters["optimize_target_tasks"] = True
parameters.setdefault("optimize_target_tasks", False)
def set_decision_indexes(decision_task_id, params, graph_config):

Просмотреть файл

@ -139,16 +139,16 @@ def handle_presets(
return kwargs
def handle_try_config(command_context, **kwargs):
def handle_try_params(command_context, **kwargs):
from tryselect.util.dicttools import merge
to_validate = []
kwargs.setdefault("try_config", {})
kwargs.setdefault("try_config_params", {})
for cls in command_context._mach_context.handler.parser.task_configs.values():
try_config = cls.try_config(**kwargs)
if try_config is not None:
params = cls.get_parameters(**kwargs)
if params is not None:
to_validate.append(cls)
kwargs["try_config"] = merge(kwargs["try_config"], try_config)
kwargs["try_config_params"] = merge(kwargs["try_config_params"], params)
for name in cls.dests:
del kwargs[name]
@ -164,7 +164,7 @@ def run(command_context, **kwargs):
kwargs = handle_presets(command_context, **kwargs)
if command_context._mach_context.handler.parser.task_configs:
kwargs = handle_try_config(command_context, **kwargs)
kwargs = handle_try_params(command_context, **kwargs)
mod = importlib.import_module(
"tryselect.selectors.{}".format(

Просмотреть файл

@ -89,18 +89,16 @@ def check_working_directory(push=True):
sys.exit(1)
def generate_try_task_config(method, labels, try_config=None, routes=None):
try_task_config = try_config or {}
try_task_config.setdefault("env", {})["TRY_SELECTOR"] = method
try_task_config.update(
{
"version": 1,
"tasks": sorted(labels),
}
)
if routes:
try_task_config["routes"] = routes
def generate_try_task_config(method, labels, params=None, routes=None):
params = params or {}
try_config = params.setdefault("try_task_config", {})
try_config.setdefault("env", {})["TRY_SELECTOR"] = method
try_config["tasks"] = sorted(labels)
if routes:
try_config["routes"] = routes
try_task_config = {"version": 2, "parameters": params}
return try_task_config

Просмотреть файл

@ -7,6 +7,7 @@ from taskgraph.util.python_path import find_object
from ..cli import BaseTryParser
from ..push import push_to_try
from ..util.dicttools import merge
TRY_AUTO_PARAMETERS = {
"optimize_strategies": "gecko_taskgraph.optimize:tryselect.bugbug_reduced_manifests_config_selection_medium", # noqa
@ -84,15 +85,15 @@ def run(
strategy=None,
tasks_regex=None,
tasks_regex_exclude=None,
try_config=None,
try_config_params=None,
push_to_lando=False,
**ignored
):
msg = message.format(msg="Tasks automatically selected.")
params = TRY_AUTO_PARAMETERS.copy()
if try_config:
params["try_task_config"] = try_config
if try_config_params:
params = merge(params, try_config_params)
if strategy:
params["optimize_strategies"] = strategy

Просмотреть файл

@ -42,7 +42,7 @@ class ChooserParser(BaseTryParser):
def run(
update=False,
query=None,
try_config=None,
try_config_params=None,
full=False,
parameters=None,
save=False,
@ -101,7 +101,9 @@ def run(
return push_to_try(
"chooser",
message.format(msg=msg),
try_task_config=generate_try_task_config("chooser", selected, try_config),
try_task_config=generate_try_task_config(
"chooser", selected, params=try_config_params
),
stage_changes=stage_changes,
dry_run=dry_run,
closed_tree=closed_tree,

Просмотреть файл

@ -387,7 +387,7 @@ def is_opt_task(task):
def run(
try_config={},
try_config_params={},
full=False,
parameters=None,
stage_changes=False,
@ -435,14 +435,16 @@ def run(
json.dumps(resolve_tests_by_suite(test_files))
)
}
try_config.setdefault("env", {}).update(path_env)
try_config_params.setdefault("try_task_config", {}).setdefault("env", {}).update(
path_env
)
# Build commit message.
msg = "try coverage - " + test_count_message
return push_to_try(
"coverage",
message.format(msg=msg),
try_task_config=generate_try_task_config("coverage", tasks, try_config),
try_task_config=generate_try_task_config("coverage", tasks, try_config_params),
stage_changes=stage_changes,
dry_run=dry_run,
closed_tree=closed_tree,

Просмотреть файл

@ -25,7 +25,7 @@ class EmptyParser(BaseTryParser):
def run(
message="{msg}",
try_config=None,
try_config_params=None,
stage_changes=False,
dry_run=False,
closed_tree=False,
@ -35,7 +35,7 @@ def run(
return push_to_try(
"empty",
message.format(msg=msg),
try_task_config=generate_try_task_config("empty", [], try_config),
try_task_config=generate_try_task_config("empty", [], params=try_config_params),
stage_changes=stage_changes,
dry_run=dry_run,
closed_tree=closed_tree,

Просмотреть файл

@ -127,9 +127,9 @@ def run(
update=False,
query=None,
intersect_query=None,
try_config=None,
full=False,
parameters=None,
try_config_params=None,
save_query=False,
stage_changes=False,
dry_run=False,
@ -278,7 +278,9 @@ def run(
return push_to_try(
"fuzzy",
message.format(msg=msg),
try_task_config=generate_try_task_config("fuzzy", selected, try_config),
try_task_config=generate_try_task_config(
"fuzzy", selected, params=try_config_params
),
stage_changes=stage_changes,
dry_run=dry_run,
closed_tree=closed_tree,

Просмотреть файл

@ -1055,29 +1055,30 @@ class PerfParser(CompareParser):
return any("android" in task for task in selected_tasks)
def setup_try_config(
try_config, extra_args, selected_tasks, base_revision_treeherder=None
try_config_params, extra_args, selected_tasks, base_revision_treeherder=None
):
"""
Setup the try config for a push.
:param try_config dict: The current try config to be modified.
:param try_config_params dict: The current try config to be modified.
:param extra_args list: A list of extra options to add to the tasks being run.
:param selected_tasks list: List of tasks selected. Used for determining if android
tasks are selected to disable artifact mode.
:param base_revision_treeherder str: The base revision of treeherder to save
:return: None
"""
if try_config is None:
try_config = {}
if try_config_params is None:
try_config_params = {}
try_config = try_config_params.setdefault("try_task_config", {})
env = try_config.setdefault("env", {})
if extra_args:
args = " ".join(extra_args)
try_config.setdefault("env", {})["PERF_FLAGS"] = args
env["PERF_FLAGS"] = args
if base_revision_treeherder:
# Reset updated since we no longer need to worry
# about failing while we're on a base commit
try_config.setdefault("env", {})[
"PERF_BASE_REVISION"
] = base_revision_treeherder
env["PERF_BASE_REVISION"] = base_revision_treeherder
if PerfParser.found_android_tasks(selected_tasks) and try_config.get(
"use-artifact-builds", False
):
@ -1089,7 +1090,7 @@ class PerfParser(CompareParser):
selected_tasks,
selected_categories,
queries,
try_config,
try_config_params,
dry_run,
single_run,
extra_args,
@ -1153,10 +1154,10 @@ class PerfParser(CompareParser):
# Setup the base revision, and try config. This lets us change the options
# we run the tests with through the PERF_FLAGS environment variable.
base_extra_args = list(extra_args)
base_try_config = copy.deepcopy(try_config)
base_try_config_params = copy.deepcopy(try_config_params)
comparator_obj.setup_base_revision(base_extra_args)
PerfParser.setup_try_config(
base_try_config, base_extra_args, selected_tasks
base_try_config_params, base_extra_args, selected_tasks
)
with redirect_stdout(log_processor):
@ -1167,7 +1168,7 @@ class PerfParser(CompareParser):
"perf-again",
"{msg}".format(msg=msg),
try_task_config=generate_try_task_config(
"fuzzy", selected_tasks, base_try_config
"fuzzy", selected_tasks, params=base_try_config_params
),
stage_changes=False,
dry_run=dry_run,
@ -1186,7 +1187,7 @@ class PerfParser(CompareParser):
new_extra_args = list(extra_args)
comparator_obj.setup_new_revision(new_extra_args)
PerfParser.setup_try_config(
try_config,
try_config_params,
new_extra_args,
selected_tasks,
base_revision_treeherder=base_revision_treeherder,
@ -1198,7 +1199,7 @@ class PerfParser(CompareParser):
"{msg}".format(msg=msg),
# XXX Figure out if changing `fuzzy` to `perf` will break something
try_task_config=generate_try_task_config(
"fuzzy", selected_tasks, try_config
"fuzzy", selected_tasks, params=try_config_params
),
stage_changes=False,
dry_run=dry_run,
@ -1218,7 +1219,7 @@ class PerfParser(CompareParser):
update=False,
show_all=False,
parameters=None,
try_config=None,
try_config_params=None,
dry_run=False,
single_run=False,
query=None,
@ -1311,7 +1312,7 @@ class PerfParser(CompareParser):
selected_tasks,
selected_categories,
queries,
try_config,
try_config_params,
dry_run,
single_run,
kwargs.get("extra_args", []),
@ -1471,8 +1472,12 @@ def run(**kwargs):
PerfParser.check_cached_revision([])
revisions = PerfParser.run(
profile=kwargs.get("try_config", {}).get("gecko-profile", False),
rebuild=kwargs.get("try_config", {}).get("rebuild", 1),
profile=kwargs.get("try_config_params", {})
.get("try_task_config", {})
.get("gecko-profile", False),
rebuild=kwargs.get("try_config_params", {})
.get("try_task_config", {})
.get("rebuild", 1),
**kwargs,
)

Просмотреть файл

@ -81,7 +81,7 @@ def run(
migrations,
limit_locales,
tasks,
try_config=None,
try_config_params=None,
stage_changes=False,
dry_run=False,
message="{msg}",
@ -116,16 +116,14 @@ def run(
)
elif release_type == "esr":
release_type += str(version.major_number)
task_config = {
"version": 2,
"parameters": {
task_config = {"version": 2, "parameters": try_config_params or {}}
task_config["parameters"].update(
{
"target_tasks_method": TARGET_TASKS[tasks],
"optimize_target_tasks": True,
"release_type": release_type,
},
}
if try_config:
task_config["parameters"]["try_task_config"] = try_config
}
)
with open(os.path.join(vcs.path, "taskcluster/ci/config.yml")) as f:
migration_configs = yaml.safe_load(f)

Просмотреть файл

@ -108,7 +108,7 @@ def get_hg_file(parameters, path):
def run(
task_type,
release_type,
try_config=None,
try_config_params=None,
stage_changes=False,
dry_run=False,
message="{msg}",
@ -141,15 +141,9 @@ def run(
]
}
try_config = try_config or {}
task_config = {
"version": 2,
"parameters": {
"existing_tasks": existing_tasks,
"try_task_config": try_config,
"try_mode": "try_task_config",
},
}
task_config = {"version": 2, "parameters": try_config_params or {}}
task_config["parameters"]["optimize_target_tasks"] = True
task_config["parameters"]["existing_tasks"] = existing_tasks
for param in (
"app_version",
"build_number",
@ -161,6 +155,7 @@ def run(
):
task_config["parameters"][param] = previous_parameters[param]
try_config = task_config["parameters"].setdefault("try_task_config", {})
try_config["tasks"] = TASK_TYPES[task_type]
for label in try_config["tasks"]:
if label in existing_tasks:

Просмотреть файл

@ -47,7 +47,7 @@ def try_config_commit(vcs: Repository, commit_message: str):
vcs.remove_current_commit()
class TryConfig:
class ParameterConfig:
__metaclass__ = ABCMeta
def __init__(self):
@ -63,13 +63,25 @@ class TryConfig:
pass
@abstractmethod
def try_config(self, **kwargs):
def get_parameters(self, **kwargs) -> dict:
pass
def validate(self, **kwargs):
pass
class TryConfig(ParameterConfig):
@abstractmethod
def try_config(self, **kwargs) -> dict:
pass
def get_parameters(self, **kwargs):
result = self.try_config(**kwargs)
if result is None:
return None
return {"try_task_config": result}
class Artifact(TryConfig):
arguments = [
[
@ -184,7 +196,8 @@ class Pernosco(TryConfig):
}
def validate(self, **kwargs):
if kwargs["try_config"].get("use-artifact-builds"):
try_config = kwargs["try_config_params"].get("try_task_config") or {}
if try_config.get("use-artifact-builds"):
print(
"Pernosco does not support artifact builds at this time. "
"Please try again with '--no-artifact'."

Просмотреть файл

@ -24,7 +24,7 @@ def test_try_again(monkeypatch):
try_task_config=push.generate_try_task_config(
"fuzzy",
["foo", "bar"],
{"use-artifact-builds": True},
{"try_task_config": {"use-artifact-builds": True}},
),
)
@ -43,7 +43,7 @@ def test_try_again(monkeypatch):
assert args[0] == "again"
assert args[1] == "Fuzzy message"
try_task_config = kwargs.pop("try_task_config")
try_task_config = kwargs["try_task_config"]["parameters"].pop("try_task_config")
assert sorted(try_task_config.get("tasks")) == sorted(["foo", "bar"])
assert try_task_config.get("env") == {"TRY_SELECTOR": "fuzzy"}
assert try_task_config.get("use-artifact-builds")

Просмотреть файл

@ -10,11 +10,15 @@ Test empty selector
Pushed via `mach try empty`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "empty"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "empty"
},
"tasks": []
}
},
"tasks": [],
"version": 1
"version": 2
}
$ ./mach try empty --no-push --closed-tree
@ -24,11 +28,15 @@ Test empty selector
Pushed via `mach try empty`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "empty"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "empty"
},
"tasks": []
}
},
"tasks": [],
"version": 1
"version": 2
}
$ ./mach try empty --no-push --closed-tree -m "foo {msg} bar"
@ -38,10 +46,14 @@ Test empty selector
Pushed via `mach try empty`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "empty"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "empty"
},
"tasks": []
}
},
"tasks": [],
"version": 1
"version": 2
}

Просмотреть файл

@ -2,6 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import json
import os
import mozunit
@ -27,14 +28,14 @@ def test_query_paths(run_mach, capfd, show_chunk_numbers):
output = capfd.readouterr().out
print(output)
delim = "Calculated try_task_config.json:"
index = output.find(delim)
result = json.loads(output[index + len(delim) :])
# If there are more than one tasks here, it means that something went wrong
# with the path filtering.
expected = """
"tasks": [
"test-linux1804-64-qr/debug-mochitest-chrome-1proc-1"
]""".lstrip()
assert expected in output
tasks = result["parameters"]["try_task_config"]["tasks"]
assert tasks == ["test-linux1804-64-qr/debug-mochitest-chrome-1proc-1"]
@pytest.mark.skipif(os.name == "nt", reason="fzf not installed on host")
@ -48,13 +49,13 @@ def test_query(run_mach, capfd, full):
output = capfd.readouterr().out
print(output)
# Should only ever mach one task exactly.
expected = """
"tasks": [
"source-test-python-taskgraph-tests-py3"
]""".lstrip()
delim = "Calculated try_task_config.json:"
index = output.find(delim)
result = json.loads(output[index + len(delim) :])
assert expected in output
# Should only ever mach one task exactly.
tasks = result["parameters"]["try_task_config"]["tasks"]
assert tasks == ["source-test-python-taskgraph-tests-py3"]
if __name__ == "__main__":

Просмотреть файл

@ -10,16 +10,22 @@ Test fuzzy selector
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ ./mach try fuzzy $testargs -q "'bar"
no tasks selected
$ ./mach try fuzzy $testargs --full -q "'bar"
@ -29,14 +35,18 @@ Test fuzzy selector
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/bar-debug",
"test/bar-opt"
]
}
},
"tasks": [
"test/bar-debug",
"test/bar-opt"
],
"version": 1
"version": 2
}
@ -49,16 +59,20 @@ Test multiple selectors
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/bar-debug",
"test/bar-opt",
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/bar-debug",
"test/bar-opt",
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -71,13 +85,17 @@ Test query intersection
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -93,14 +111,18 @@ Test intersection with preset containing multiple queries
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ ./mach try $testargs --preset foo -xq "'test"
@ -110,14 +132,18 @@ Test intersection with preset containing multiple queries
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -130,14 +156,18 @@ Test exact match
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ ./mach try fuzzy $testargs --full --exact -q "testfoo | 'testbar"
@ -147,18 +177,21 @@ Test exact match
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/bar-debug",
"test/bar-opt"
]
}
},
"tasks": [
"test/bar-debug",
"test/bar-opt"
],
"version": 1
"version": 2
}
Test task config
$ ./mach try fuzzy --no-push --artifact -q "'foo"
@ -168,16 +201,20 @@ Test task config
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"disable-pgo": true,
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"disable-pgo": true,
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"use-artifact-builds": true
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"use-artifact-builds": true,
"version": 1
"version": 2
}
$ ./mach try fuzzy $testargs --env FOO=1 --env BAR=baz -q "'foo"
@ -187,15 +224,19 @@ Test task config
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"BAR": "baz",
"FOO": "1",
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"BAR": "baz",
"FOO": "1",
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}

Просмотреть файл

@ -12,14 +12,18 @@ Test custom commit messages with fuzzy selector
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ ./mach try fuzzy $testargs -q foo -m "Foobar: {msg}"
@ -29,14 +33,18 @@ Test custom commit messages with fuzzy selector
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ unset EDITOR

Просмотреть файл

@ -1270,7 +1270,10 @@ def test_save_revision_treeherder(args, call_counts, exists_cache_file):
),
(
int((MAX_PERF_TASKS + 2) / 2),
{"show_all": True, "try_config": {"rebuild": 2}},
{
"show_all": True,
"try_config_params": {"try_task_config": {"rebuild": 2}},
},
[1, 0, 0, 1],
(
"\n\n----------------------------------------------------------------------------------------------\n"
@ -1354,7 +1357,7 @@ def test_max_perf_tasks(
],
)
def test_artifact_mode_autodisable(try_config, selected_tasks, expected_try_config):
PerfParser.setup_try_config(try_config, [], selected_tasks)
PerfParser.setup_try_config({"try_task_config": try_config}, [], selected_tasks)
assert (
try_config["use-artifact-builds"] == expected_try_config["use-artifact-builds"]
)

Просмотреть файл

@ -131,15 +131,19 @@ Test preset with fuzzy subcommand
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -150,15 +154,19 @@ Test preset with fuzzy subcommand
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -171,16 +179,20 @@ Queries can be appended to presets
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"rebuild": 5,
"tasks": [
"build-baz",
"test/foo-debug",
"test/foo-opt"
]
}
},
"rebuild": 5,
"tasks": [
"build-baz",
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -191,14 +203,18 @@ Queries can be appended to presets
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"rebuild": 5,
"tasks": [
"test/foo-opt"
]
}
},
"rebuild": 5,
"tasks": [
"test/foo-opt"
],
"version": 1
"version": 2
}
@ -277,17 +293,21 @@ Test gecko-profile argument handling. Add in profiling to a preset.
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"gecko-profile": true,
"gecko-profile-features": "nostacksampling,cpu",
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"gecko-profile": true,
"gecko-profile-features": "nostacksampling,cpu",
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
Check whether the gecko-profile flags can be used from a preset, and check
@ -304,17 +324,21 @@ settings; everything else uses dashes.)
Pushed via `mach try fuzzy`
Calculated try_task_config.json:
{
"env": {
"TRY_SELECTOR": "fuzzy"
"parameters": {
"try_task_config": {
"env": {
"TRY_SELECTOR": "fuzzy"
},
"gecko-profile": true,
"gecko-profile-features": "nostacksampling,cpu",
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
]
}
},
"gecko-profile": true,
"gecko-profile-features": "nostacksampling,cpu",
"rebuild": 5,
"tasks": [
"test/foo-debug",
"test/foo-opt"
],
"version": 1
"version": 2
}
$ EDITOR=cat ./mach try fuzzy $testargs --edit-preset profile

Просмотреть файл

@ -15,27 +15,39 @@ from tryselect.task_config import Pernosco, all_task_configs
TASK_CONFIG_TESTS = {
"artifact": [
(["--no-artifact"], None),
(["--artifact"], {"use-artifact-builds": True, "disable-pgo": True}),
(
["--artifact"],
{"try_task_config": {"use-artifact-builds": True, "disable-pgo": True}},
),
],
"chemspill-prio": [
([], None),
(["--chemspill-prio"], {"chemspill-prio": {}}),
(["--chemspill-prio"], {"try_task_config": {"chemspill-prio": {}}}),
],
"env": [
([], None),
(["--env", "foo=bar", "--env", "num=10"], {"env": {"foo": "bar", "num": "10"}}),
(
["--env", "foo=bar", "--env", "num=10"],
{"try_task_config": {"env": {"foo": "bar", "num": "10"}}},
),
],
"path": [
([], None),
(
["dom/indexedDB"],
{"env": {"MOZHARNESS_TEST_PATHS": '{"xpcshell": ["dom/indexedDB"]}'}},
{
"try_task_config": {
"env": {"MOZHARNESS_TEST_PATHS": '{"xpcshell": ["dom/indexedDB"]}'}
}
},
),
(
["dom/indexedDB", "testing"],
{
"env": {
"MOZHARNESS_TEST_PATHS": '{"xpcshell": ["dom/indexedDB", "testing"]}'
"try_task_config": {
"env": {
"MOZHARNESS_TEST_PATHS": '{"xpcshell": ["dom/indexedDB", "testing"]}'
}
}
},
),
@ -46,7 +58,7 @@ TASK_CONFIG_TESTS = {
],
"rebuild": [
([], None),
(["--rebuild", "10"], {"rebuild": 10}),
(["--rebuild", "10"], {"try_task_config": {"rebuild": 10}}),
(["--rebuild", "1"], SystemExit),
(["--rebuild", "21"], SystemExit),
],
@ -54,7 +66,7 @@ TASK_CONFIG_TESTS = {
([], None),
(
["--worker-override", "alias=worker/pool"],
{"worker-overrides": {"alias": "worker/pool"}},
{"try_task_config": {"worker-overrides": {"alias": "worker/pool"}}},
),
(
[
@ -67,7 +79,11 @@ TASK_CONFIG_TESTS = {
),
(
["--worker-suffix", "b-linux=-dev"],
{"worker-overrides": {"b-linux": "gecko-1/b-linux-dev"}},
{
"try_task_config": {
"worker-overrides": {"b-linux": "gecko-1/b-linux-dev"}
}
},
),
(
[
@ -103,12 +119,14 @@ def test_task_configs(config_patch_resolver, task_config, args, expected):
if task_config == "path":
config_patch_resolver(**vars(args))
cfg.try_config(**vars(args))
cfg.get_parameters(**vars(args))
else:
args = parser.parse_args(args)
if task_config == "path":
config_patch_resolver(**vars(args))
assert cfg.try_config(**vars(args)) == expected
params = cfg.get_parameters(**vars(args))
assert params == expected
@pytest.fixture
@ -137,7 +155,8 @@ def test_pernosco(patch_pernosco_email_check):
cfg = Pernosco()
cfg.add_arguments(parser)
args = parser.parse_args(["--pernosco"])
assert cfg.try_config(**vars(args)) == {"env": {"PERNOSCO": "1"}}
params = cfg.get_parameters(**vars(args))
assert params == {"try_task_config": {"env": {"PERNOSCO": "1"}}}
if __name__ == "__main__":