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