-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathre_test_common.bzl
72 lines (67 loc) · 2.63 KB
/
re_test_common.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
load("@prelude//:build_mode.bzl", "BuildModeInfo")
load("@prelude//:is_full_meta_repo.bzl", "is_full_meta_repo")
load(":toolchains_common.bzl", "toolchains_common")
def _opts_for_tests_arg() -> Attr:
# Attributes types do not have records.
# The expected shape of re_opts is:
# {
# "capabilities": Dict<str, str> | None
# "listing_capabilities": Dict<str, str> | None
# "local_listing_enabled": bool | None
# "local_enabled": bool | None
# "use_case": str | None
# "remote_cache_enabled": bool | None
# "dependencies": list<Dict<str, str>> | []
# "resource_units": int | None
# "remote_execution_dynamic_image": dict<str, str | list<str>> | None
# }
return attrs.dict(
key = attrs.string(),
value = attrs.option(
attrs.one_of(
attrs.dict(
key = attrs.string(),
value = attrs.one_of(
attrs.string(),
attrs.list(attrs.string()),
),
sorted = False,
),
attrs.string(),
attrs.bool(),
attrs.list(attrs.dict(key = attrs.string(), value = attrs.string()), default = []),
attrs.int(),
),
# TODO(cjhopman): I think this default does nothing, it should be deleted
default = None,
),
sorted = False,
)
def _action_key_provider_arg() -> Attr:
if is_full_meta_repo():
default_build_mode = read_root_config("fb", "remote_execution_test_build_mode", "fbcode//buck2/platform/build_mode:build_mode")
return attrs.dep(providers = [BuildModeInfo], default = default_build_mode)
else:
return attrs.option(attrs.dep(providers = [BuildModeInfo]), default = None)
def _test_args() -> dict[str, Attr]:
return {
"remote_execution": attrs.option(
attrs.one_of(
attrs.string(),
_opts_for_tests_arg(),
),
default = None,
),
"remote_execution_action_key_providers": _action_key_provider_arg(),
"_remote_test_execution_toolchain": toolchains_common.remote_test_execution(),
}
re_test_common = struct(
test_args = _test_args,
opts_for_tests_arg = _opts_for_tests_arg,
)