forked from cgrindel/rules_swift_package_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_infos.bzl
197 lines (178 loc) · 5.8 KB
/
example_infos.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
"""Module exposing information about the example integration tests."""
load("@bazel_binaries//:defs.bzl", "bazel_binaries")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@cgrindel_bazel_starlib//bzllib:defs.bzl", "lists")
load(
"@rules_bazel_integration_test//bazel_integration_test:defs.bzl",
"bazel_integration_tests",
"integration_test_utils",
)
load(
"//ci:defs.bzl",
"ci_integration_test_params",
"ci_test_params_suite",
)
def _new(name, oss, versions, enable_bzlmods):
# Remove the Bazel label prefix if it exists.
# Depending upon the whether bzmlod is enabled, the prefix could be `@@//:`
# Replace periods (.) with underscore (_), after the first character
clean_versions = [
v.removeprefix("//:").removeprefix("@@//:")
for v in versions
]
clean_versions = [
v[0] + v[1:].replace(".", "_")
for v in clean_versions
]
return struct(
name = name,
oss = oss,
versions = versions,
clean_versions = clean_versions,
enable_bzlmods = enable_bzlmods,
)
def _test_name_prefix(name):
return name + "_test"
def _test_name(example_name, version):
return integration_test_utils.bazel_integration_test_name(
_test_name_prefix(example_name),
version,
)
def _bazel_integration_test(ei):
target_compatible_with = select(dicts.add(
{
"@platforms//os:{}".format(os): []
for os in ei.oss
},
{"//conditions:default": ["@platforms//:incompatible"]},
))
timeout = _timeouts.get(ei.name, _default_timeout)
workspace_files = integration_test_utils.glob_workspace_files(ei.name) + [
"//:runtime_files",
]
workspace_path = ei.name
for enable_bzlmod in ei.enable_bzlmods:
if not enable_bzlmod:
fail("The {name} example still has legacy test enabled.".format(name = ei.name))
test_runner = ":test_runner"
bazel_integration_tests(
name = _test_name_prefix(ei.name),
bazel_binaries = bazel_binaries,
bazel_versions = ei.versions,
tags = integration_test_utils.DEFAULT_INTEGRATION_TEST_TAGS + [
# Avoid file permssion error when using disk and repository cache after
# 7.0.0rc2 upgrade.
# https://github.com/bazelbuild/bazel/issues/19908
"no-sandbox",
],
timeout = timeout,
target_compatible_with = target_compatible_with,
test_runner = test_runner,
workspace_files = workspace_files,
workspace_path = workspace_path,
)
for version in ei.versions:
_ci_integration_test_params(ei, version)
def _test_params_name(name, version):
test_name = _test_name(name, version)
return _test_params_name_from_test_name(test_name)
def _test_params_name_from_test_name(test_name):
return "{}_params".format(test_name)
def _ci_integration_test_params(ei, version):
test_name = _test_name(ei.name, version)
ci_integration_test_params(
name = _test_params_name_from_test_name(test_name),
oss = ei.oss,
test_names = [test_name],
visibility = ["//:__subpackages__"],
)
def _ci_test_params_suite(name, example_infos):
ci_test_params_suite(
name = name,
test_params = lists.flatten([
[
_test_params_name(ei.name, v)
for v in ei.versions
]
for ei in example_infos
]),
visibility = ["//:__subpackages__"],
)
# Switched the default to eternal as CI is failing intermittently.
_default_timeout = "eternal"
_timeouts = {
"firebase_example": "eternal",
"soto_example": "eternal",
"vapor_example": "eternal",
"xcmetrics_example": "eternal",
}
_default_enable_bzlmods = [True]
_enable_bzlmods = {}
_all_os_all_bazel_versions_test_examples = [
"pkg_manifest_minimal",
]
_all_os_single_bazel_version_test_examples = [
"vapor_example",
"grpc_example",
]
_macos_single_bazel_version_test_examples = [
"firebase_example",
"google_maps_example",
"interesting_deps",
"ios_sim",
"lottie_ios_example",
"messagekit_example",
"nimble_example",
"objc_code",
"phone_number_kit",
"soto_example", # Soto supports Linux and MacOS. However, the resolved package is different.
"resources_example",
"shake_ios_example",
"snapkit_example",
"stripe_example",
"xcmetrics_example",
"tca_example",
"symlink_example",
]
_linux_single_bazel_version_test_examples = []
_all = [
_new(
name = name,
oss = ["macos", "linux"],
versions = bazel_binaries.versions.all,
enable_bzlmods = _enable_bzlmods.get(name, _default_enable_bzlmods),
)
for name in _all_os_all_bazel_versions_test_examples
] + [
_new(
name = name,
oss = ["macos", "linux"],
versions = [bazel_binaries.versions.current],
enable_bzlmods = _enable_bzlmods.get(name, _default_enable_bzlmods),
)
for name in _all_os_single_bazel_version_test_examples
] + [
_new(
name = name,
oss = ["macos"],
versions = [bazel_binaries.versions.current],
enable_bzlmods = _enable_bzlmods.get(name, _default_enable_bzlmods),
)
for name in _macos_single_bazel_version_test_examples
] + [
_new(
name = name,
oss = ["linux"],
versions = [bazel_binaries.versions.current],
enable_bzlmods = _enable_bzlmods.get(name, _default_enable_bzlmods),
)
for name in _linux_single_bazel_version_test_examples
]
example_infos = struct(
all = _all,
bazel_integration_test = _bazel_integration_test,
ci_test_params_suite = _ci_test_params_suite,
new = _new,
test_name_prefix = _test_name_prefix,
test_name = _test_name,
)