blob: ddf3bdc2993b9ada9173574eadae9eb036b4abb5 [file] [log] [blame]
Ryan Harrisoncd5492c2021-06-03 19:58:51 +00001#!/usr/bin/env lucicfg
2#
3# Copyright 2021 The Tint Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7"""
8main.star: lucicfg configuration for Tint's standalone builers.
9"""
10
Andrii Shyshkalov762c81b2021-07-12 14:40:22 +000011# Enable realms experiment.
12lucicfg.enable_experiment("crbug.com/1085650")
Ryan Harrisond148be42021-11-01 19:00:52 +000013luci.builder.defaults.experiments.set({
14 "luci.use_realms": 100,
15 "luci.recipes.use_python3": 100,
16})
Andrii Shyshkalov762c81b2021-07-12 14:40:22 +000017
Ryan Harrisoncd5492c2021-06-03 19:58:51 +000018lucicfg.config(fail_on_warnings = True)
19
20luci.project(
21 name = "tint",
22 buildbucket = "cr-buildbucket.appspot.com",
23 logdog = "luci-logdog.appspot.com",
24 milo = "luci-milo.appspot.com",
25 notify = "luci-notify.appspot.com",
26 scheduler = "luci-scheduler.appspot.com",
27 swarming = "chromium-swarm.appspot.com",
28 acls = [
29 acl.entry(
30 roles = [
31 acl.PROJECT_CONFIGS_READER,
32 acl.LOGDOG_READER,
33 acl.BUILDBUCKET_READER,
34 acl.SCHEDULER_READER,
35 ],
36 groups = "all",
37 ),
38 acl.entry(
39 roles = [
40 acl.SCHEDULER_OWNER,
41 ],
42 groups = "project-tint-admins",
43 ),
44 acl.entry(
45 roles = [
46 acl.LOGDOG_WRITER,
47 ],
48 groups = "luci-logdog-chromium-writers",
49 ),
50 ],
Vadim Shtayura90eb5aa2021-11-16 15:17:12 +000051 bindings = [
52 luci.binding(
53 roles = "role/configs.validator",
54 users = "tint-try-builder@chops-service-accounts.iam.gserviceaccount.com",
55 ),
56 ],
Ryan Harrisoncd5492c2021-06-03 19:58:51 +000057)
58
59luci.logdog(gs_bucket = "chromium-luci-logdog")
60
61luci.bucket(
62 name = "ci",
63 acls = [
64 acl.entry(
65 roles = [
66 acl.BUILDBUCKET_READER,
67 ],
68 groups = "all",
69 ),
70 acl.entry(
71 acl.BUILDBUCKET_TRIGGERER,
Ryan Harrisoncd5492c2021-06-03 19:58:51 +000072 ),
73 ],
74)
75
76luci.bucket(
77 name = "try",
78 acls = [
79 acl.entry(
80 acl.BUILDBUCKET_TRIGGERER,
81 groups = [
82 "project-tint-tryjob-access",
83 "service-account-cq",
84 ],
85 ),
86 ],
87)
88
89os_category = struct(
90 LINUX = "Linux",
91 MAC = "Mac",
92 WINDOWS = "Windows",
93 UNKNOWN = "Unknown",
94)
95
96def os_enum(dimension, category, console_name):
97 return struct(dimension = dimension, category = category, console_name = console_name)
98
99os = struct(
100 LINUX = os_enum("Ubuntu-18.04", os_category.LINUX, "linux"),
101 MAC = os_enum("Mac-10.15", os_category.MAC, "mac"),
102 WINDOWS = os_enum("Windows-10", os_category.WINDOWS, "win"),
103 UNKNOWN = os_enum("Unknown", os_category.UNKNOWN, "unknown"),
104)
105
106# Recipes
107
108def get_builder_executable():
109 """Get standard executable for builders
110
111 Returns:
112 A luci.recipe
113 """
114 return luci.recipe(
115 name = "tint",
116 cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
117 cipd_version = "refs/heads/master",
118 )
119
120def get_os_from_arg(arg):
121 """Get OS enum for a builder name string
122
123 Args:
124 arg: builder name string to get enum for
125
126 Returns:
127 An OS enum struct
128
129 """
130
131 if arg.startswith("linux"):
132 return os.LINUX
133 if arg.startswith("win"):
134 return os.WINDOWS
135 if arg.startswith("mac"):
136 return os.MAC
137 return os.UNKNOWN
138
139def get_default_caches(os, clang):
140 """Get standard caches for builders
141
142 Args:
143 os: OS enum for the builder
144 clang: is this builder running clang
145
146 Returns:
147 A list of caches
148 """
149 caches = []
150 if os.category == os_category.WINDOWS and clang:
151 caches.append(swarming.cache(name = "win_toolchain", path = "win_toolchain"))
152 elif os.category == os_category.MAC:
153 # Cache for mac_toolchain tool and XCode.app
154 caches.append(swarming.cache(name = "osx_sdk", path = "osx_sdk"))
155 return caches
156
157def get_default_dimensions(os):
158 """Get dimensions for a builder that don't depend on being CI vs Try
159
160 Args:
161 os: OS enum for the builder
162
163 Returns:
164 A dimension dict
165
166 """
167 dimensions = {}
168
169 # We have 32bit test configurations but some of our toolchain is 64bit (like CIPD)
170 dimensions["cpu"] = "x86-64"
171 dimensions["os"] = os.dimension
172
173 return dimensions
174
175def get_default_properties(os, clang, debug, cpu):
176 """Get the properties for a builder that don't depend on being CI vs Try
177
178 Args:
179 os: OS enum for the builder
180 clang: is this builder running clang
181 debug: is this builder generating debug builds
182 cpu: string representing the target CPU architecture
183
184 Returns:
185 A properties dict
186 """
187 properties = {}
188
189 properties["debug"] = debug
190 properties["target_cpu"] = cpu
191
192 properties["clang"] = clang
193 msvc = os.category == os_category.WINDOWS and not clang
194
195 if msvc != True:
196 goma_props = {}
197 goma_props.update({
198 "server_host": "goma.chromium.org",
199 "rpc_extra_params": "?prod",
200 })
201 if os.category != os_category.MAC:
202 goma_props["enable_ats"] = True
203 properties["$build/goma"] = goma_props
204
Ryan Harrisoncd5492c2021-06-03 19:58:51 +0000205 return properties
206
207def add_ci_builder(name, os, clang, debug, cpu):
208 """Add a CI builder
209
210 Args:
211 name: builder's name in string form
212 os: OS enum for the builder
213 clang: is this builder running clang
214 debug: is this builder generating debug builds
215 cpu: string representing the target CPU architecture
216 """
217 dimensions_ci = get_default_dimensions(os)
218 dimensions_ci["pool"] = "luci.flex.ci"
219 properties_ci = get_default_properties(os, clang, debug, cpu)
220 triggered_by_ci = ["primary-poller"]
221 luci.builder(
222 name = name,
223 bucket = "ci",
224 triggered_by = triggered_by_ci,
225 executable = get_builder_executable(),
226 properties = properties_ci,
227 dimensions = dimensions_ci,
228 caches = get_default_caches(os, clang),
229 service_account = "tint-ci-builder@chops-service-accounts.iam.gserviceaccount.com",
230 )
231
232def add_try_builder(name, os, clang, debug, cpu):
233 """Add a Try builder
234
235 Args:
236 name: builder's name in string form
237 os: OS enum for the builder
238 clang: is this builder running clang
239 debug: is this builder generating debug builds
240 cpu: string representing the target CPU architecture
241 """
242 dimensions_try = get_default_dimensions(os)
243 dimensions_try["pool"] = "luci.flex.try"
244 properties_try = get_default_properties(os, clang, debug, cpu)
245 properties_try["$depot_tools/bot_update"] = {
246 "apply_patch_on_gclient": True,
247 }
248 luci.builder(
249 name = name,
250 bucket = "try",
251 executable = get_builder_executable(),
252 properties = properties_try,
253 dimensions = dimensions_try,
254 caches = get_default_caches(os, clang),
255 service_account = "tint-try-builder@chops-service-accounts.iam.gserviceaccount.com",
256 )
257
258def tint_standalone_builder(name, clang, debug, cpu):
259 """Adds both the CI and Try standalone builders
260
261 Args:
262 name: builder's name in string form
263 clang: is this builder running clang
264 debug: is this builder generating debug builds
265 cpu: string representing the target CPU architecture
266
267 """
268 os = get_os_from_arg(name)
269
270 add_ci_builder(name, os, clang, debug, cpu)
271 add_try_builder(name, os, clang, debug, cpu)
272
273 config = ""
274 if clang:
275 config = "clang"
276 elif os.category == os_category.WINDOWS:
277 config = "msvc"
278
279 category = os.console_name
280
281 if os.category != os_category.MAC:
282 category += "|" + config
283 if config != "msvc":
284 category += "|dbg" if debug else "|rel"
285
286 short_name = "dbg" if debug else "rel"
287 if os.category != os_category.MAC:
288 if config != "msvc":
289 short_name = cpu
290
291 luci.console_view_entry(
292 console_view = "ci",
293 builder = "ci/" + name,
294 category = category,
295 short_name = short_name,
296 )
297
298 luci.list_view_entry(
299 list_view = "try",
300 builder = "try/" + name,
301 )
302
303 luci.cq_tryjob_verifier(
304 cq_group = "Tint-CQ",
305 builder = "tint:try/" + name,
306 )
307
308luci.gitiles_poller(
309 name = "primary-poller",
310 bucket = "ci",
311 repo = "https://dawn.googlesource.com/tint",
312 refs = [
313 "refs/heads/main",
314 ],
315)
316
317luci.list_view_entry(
318 list_view = "try",
319 builder = "try/presubmit",
320)
321
322luci.builder(
323 name = "presubmit",
324 bucket = "try",
325 executable = luci.recipe(
326 name = "run_presubmit",
327 cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
328 cipd_version = "refs/heads/master",
329 ),
330 dimensions = {
331 "cpu": "x86-64",
332 "os": os.LINUX.dimension,
333 "pool": "luci.flex.try",
334 },
335 properties = {
336 "repo_name": "tint",
337 "runhooks": True,
338 "$depot_tools/bot_update": {
339 "apply_patch_on_gclient": True,
340 },
341 },
342 service_account = "tint-try-builder@chops-service-accounts.iam.gserviceaccount.com",
343)
344
345# name, clang, debug, cpu
346tint_standalone_builder("linux-clang-dbg-x64", True, True, "x64")
347tint_standalone_builder("linux-clang-rel-x64", True, False, "x64")
348tint_standalone_builder("linux-clang-dbg-x86", True, True, "x86")
349tint_standalone_builder("linux-clang-rel-x86", True, False, "x86")
350tint_standalone_builder("mac-dbg", True, True, "x64")
351tint_standalone_builder("mac-rel", True, False, "x64")
352tint_standalone_builder("win-clang-dbg-x64", True, True, "x64")
353tint_standalone_builder("win-clang-rel-x64", True, False, "x64")
354tint_standalone_builder("win-clang-dbg-x86", True, True, "x86")
355tint_standalone_builder("win-clang-rel-x86", True, False, "x86")
356tint_standalone_builder("win-msvc-dbg-x64", False, True, "x64")
357tint_standalone_builder("win-msvc-rel-x64", False, False, "x64")
358
Ryan Harrisoncd5492c2021-06-03 19:58:51 +0000359# Views
360
361luci.console_view(
362 name = "ci",
363 title = "Tint CI Builders",
364 repo = "https://dawn.googlesource.com/tint",
365 refs = ["refs/heads/main"],
366)
367
368luci.list_view(
369 name = "try",
370 title = "Tint try Builders",
371)
372
373# CQ
374
375luci.cq(
376 status_host = "chromium-cq-status.appspot.com",
377 submit_max_burst = 4,
378 submit_burst_delay = 480 * time.second,
379)
380
381luci.cq_group(
382 name = "Tint-CQ",
383 watch = cq.refset(
384 "https://dawn.googlesource.com/tint",
385 refs = ["refs/heads/.+"],
386 ),
387 acls = [
388 acl.entry(
389 acl.CQ_COMMITTER,
390 groups = "project-tint-committers",
391 ),
392 acl.entry(
393 acl.CQ_DRY_RUNNER,
394 groups = "project-tint-tryjobs-access",
395 ),
396 ],
397 verifiers = [
398 luci.cq_tryjob_verifier(
399 builder = "tint:try/presubmit",
400 disable_reuse = True,
401 ),
402 ],
403 retry_config = cq.retry_config(
404 single_quota = 1,
405 global_quota = 2,
406 failure_weight = 1,
407 transient_failure_weight = 1,
408 timeout_weight = 2,
409 ),
410)