1#!/usr/bin/env lucicfg 2 3lucicfg.check_version("1.30.9", "Please update depot_tools") 4 5# Use LUCI Scheduler BBv2 names and add Scheduler realms configs. 6lucicfg.enable_experiment("crbug.com/1182002") 7 8lucicfg.config( 9 config_dir = "generated", 10 tracked_files = ["*.cfg"], 11 fail_on_warnings = True, 12 lint_checks = ["default", "-module-docstring"], 13) 14 15luci.project( 16 name = "crosvm", 17 buildbucket = "cr-buildbucket.appspot.com", 18 logdog = "luci-logdog.appspot.com", 19 milo = "luci-milo.appspot.com", 20 notify = "luci-notify.appspot.com", 21 scheduler = "luci-scheduler.appspot.com", 22 swarming = "chromium-swarm.appspot.com", 23 tricium = "tricium-prod.appspot.com", 24 bindings = [ 25 # Allow owners to submit any task in any pool. 26 luci.binding( 27 roles = [ 28 "role/swarming.poolOwner", 29 "role/swarming.poolUser", 30 "role/swarming.taskTriggerer", 31 "role/buildbucket.owner", 32 ], 33 groups = "mdb/crosvm-acl-luci-admin", 34 ), 35 36 # Allow any googler to see all bots and tasks there. 37 luci.binding( 38 roles = "role/swarming.poolViewer", 39 groups = "googlers", 40 ), 41 42 # Allow any googler to read/validate/reimport the project configs. 43 luci.binding( 44 roles = "role/configs.developer", 45 groups = "googlers", 46 ), 47 ], 48 acls = [ 49 # Publicly readable. 50 acl.entry( 51 roles = [ 52 acl.BUILDBUCKET_READER, 53 acl.LOGDOG_READER, 54 acl.PROJECT_CONFIGS_READER, 55 acl.SCHEDULER_READER, 56 ], 57 groups = "all", 58 ), 59 # Allow committers to use CQ and to force-trigger and stop CI builds. 60 acl.entry( 61 roles = [ 62 acl.SCHEDULER_OWNER, 63 acl.CQ_COMMITTER, 64 ], 65 groups = ["googlers", "project-crosvm-committers"], 66 ), 67 # Group with bots that have write access to the Logdog prefix. 68 acl.entry( 69 roles = acl.LOGDOG_WRITER, 70 groups = "luci-logdog-chromium-writers", 71 ), 72 ], 73) 74 75# Per-service tweaks. 76luci.logdog(gs_bucket = "logdog-crosvm-archive") 77 78# Realms with ACLs for corresponding Swarming pools. 79luci.realm(name = "pools/ci") 80luci.realm(name = "pools/try") 81 82# Global recipe defaults 83luci.recipe.defaults.cipd_version.set("refs/heads/main") 84luci.recipe.defaults.cipd_package.set("infra/recipe_bundles/chromium.googlesource.com/crosvm/crosvm") 85 86# The try bucket will include builders which work on pre-commit or pre-review 87# code. 88luci.bucket(name = "try") 89 90# The ci bucket will include builders which work on post-commit code. 91luci.bucket( 92 name = "ci", 93 acls = [ 94 acl.entry( 95 roles = acl.BUILDBUCKET_TRIGGERER, 96 groups = [ 97 "mdb/crosvm-acl-luci-admin", 98 ], 99 ), 100 ], 101) 102 103# The prod bucket will include builders which work on post-commit code and 104# generate executable artifacts used by other users or machines. 105luci.bucket(name = "prod") 106 107# This sets the default CIPD ref to use in builds to get the right version of 108# recipes for the build. 109# 110# The recipe bundler sets CIPD refs equal in name to the git refs that it 111# processed the recipe code from. 112# 113# Note: This will cause all recipe commits to automatically deploy as soon 114# as the recipe bundler compiles them from your refs/heads/main branch. 115cipd_version = "refs/heads/main" 116 117# Configure Change Verifier to watch crosvm 118luci.cq( 119 status_host = "chromium-cq-status.appspot.com", 120) 121luci.cq_group( 122 name = "main", 123 watch = cq.refset( 124 repo = "https://chromium.googlesource.com/crosvm/crosvm", 125 refs = ["refs/heads/.+"], # will watch all branches 126 ), 127) 128 129# Console showing all postsubmit verify builders 130luci.console_view( 131 name = "Postsubmit", 132 repo = "https://chromium.googlesource.com/crosvm/crosvm", 133) 134 135# View showing all presubmit builders 136luci.list_view( 137 name = "Presubmit", 138) 139 140# View showing all infra builders 141luci.list_view( 142 name = "Infra", 143) 144 145# Allows builders to send email notifications on failures. 146luci.notifier( 147 name = "postsubmit-failures", 148 on_status_change = True, 149 notify_emails = [ 150 "[email protected]", 151 "[email protected]", 152 "[email protected]", 153 ], 154) 155luci.notifier( 156 name = "infra-failures", 157 on_status_change = True, 158 notify_emails = [ 159 "[email protected]", 160 "[email protected]", 161 ], 162) 163 164def verify_builder( 165 name, 166 dimensions, 167 presubmit = True, 168 postsubmit = True, 169 properties = dict(), 170 presubmit_properties = dict(), 171 postsubmit_properties = dict(), 172 category = "generic", 173 **args): 174 """Creates both a CI and try builder with the same properties. 175 176 The CI builder is attached to the gitlies poller and console view, and the try builder 177 is added to the change verifier. 178 179 Args: 180 name: Name of the builder 181 dimensions: Passed to luci.builder 182 presubmit: Create a presubmit builder (defaults to True) 183 postsubmit: Create a postsubmit builder (defaults to True) 184 category: Category of this builder in the concole view 185 properties: Builder properties for both presubmit and postsubmit 186 presubmit_properties: Builder properties for only presubmit 187 postsubmit_properties: Builder properties for only postsubmit 188 **args: Passed to luci.builder 189 """ 190 191 # CI builder 192 if postsubmit: 193 props = dict(**properties) 194 props.update(postsubmit_properties) 195 luci.builder( 196 name = name, 197 bucket = "ci", 198 service_account = "[email protected]", 199 dimensions = dict(pool = "luci.crosvm.ci", **dimensions), 200 notifies = ["postsubmit-failures"], 201 properties = props, 202 **args 203 ) 204 luci.gitiles_poller( 205 name = "main source", 206 bucket = "ci", 207 repo = "https://chromium.googlesource.com/crosvm/crosvm", 208 triggers = ["ci/%s" % name], 209 ) 210 luci.console_view_entry( 211 console_view = "Postsubmit", 212 builder = "ci/%s" % name, 213 category = category, 214 ) 215 216 # Try builder 217 if presubmit: 218 props = dict(**properties) 219 props.update(presubmit_properties) 220 luci.builder( 221 name = name, 222 bucket = "try", 223 service_account = "[email protected]", 224 dimensions = dict(pool = "luci.crosvm.try", **dimensions), 225 properties = props, 226 **args 227 ) 228 luci.list_view_entry( 229 list_view = "Presubmit", 230 builder = "try/%s" % name, 231 ) 232 233 # Attach try builder to Change Verifier 234 luci.cq_tryjob_verifier( 235 builder = "try/%s" % name, 236 cq_group = "main", 237 ) 238 239def verify_linux_builder(arch, **kwargs): 240 """Creates a verify builder that builds crosvm on linux 241 242 Args: 243 arch: Architecture to build and test 244 **kwargs: Passed to verify_builder 245 """ 246 name = "linux_%s" % arch 247 verify_builder( 248 name = name, 249 dimensions = { 250 "os": "Ubuntu", 251 "cpu": "x86-64", 252 }, 253 executable = luci.recipe( 254 name = "build_linux", 255 ), 256 properties = { 257 "test_arch": arch, 258 }, 259 postsubmit_properties = { 260 "profile": "postsubmit", 261 }, 262 presubmit_properties = { 263 "profile": "presubmit", 264 }, 265 caches = [ 266 swarming.cache("builder", name = "linux_builder_cache"), 267 ], 268 category = "linux", 269 **kwargs 270 ) 271 272def infra_builder(name, postsubmit, **args): 273 """Creates a ci job to run infra recipes that are not involved in verifying changes. 274 275 The builders are added to a separate infra dashboard. 276 277 Args: 278 name: Name of the builder 279 postsubmit: True if the builder should run after each submitted commit. 280 **args: Passed to luci.builder 281 """ 282 luci.builder( 283 name = name, 284 bucket = "ci", 285 service_account = "[email protected]", 286 dimensions = { 287 "pool": "luci.crosvm.ci", 288 "os": "Ubuntu", 289 "cpu": "x86-64", 290 }, 291 notifies = ["infra-failures"], 292 **args 293 ) 294 if postsubmit: 295 luci.gitiles_poller( 296 name = "main source", 297 bucket = "ci", 298 repo = "https://chromium.googlesource.com/crosvm/crosvm", 299 triggers = ["ci/%s" % name], 300 ) 301 luci.list_view_entry( 302 list_view = "Infra", 303 builder = "ci/%s" % name, 304 ) 305 306verify_linux_builder("x86_64") 307verify_linux_builder("aarch64") 308verify_linux_builder("armhf") 309verify_linux_builder("mingw64") 310 311# Disabled due to b/304875018 312# verify_linux_builder("riscv64") 313 314verify_builder( 315 name = "chromeos_hatch", 316 dimensions = { 317 "os": "Ubuntu", 318 "cpu": "x86-64", 319 }, 320 executable = luci.recipe( 321 name = "build_chromeos_hatch", 322 ), 323 category = "linux", 324 presubmit = False, 325) 326 327verify_builder( 328 name = "windows", 329 dimensions = { 330 "os": "Windows", 331 "cpu": "x86-64", 332 }, 333 executable = luci.recipe( 334 name = "build_windows", 335 ), 336 category = "windows", 337) 338 339verify_builder( 340 name = "health_check", 341 dimensions = { 342 "os": "Ubuntu", 343 "cpu": "x86-64", 344 }, 345 executable = luci.recipe( 346 name = "presubmit", 347 ), 348 properties = { 349 "group_name": "health_checks", 350 }, 351 caches = [ 352 swarming.cache("builder", name = "linux_builder_cache"), 353 ], 354 category = "linux", 355) 356 357verify_builder( 358 name = "android-aarch64", 359 dimensions = { 360 "os": "Ubuntu", 361 "cpu": "x86-64", 362 }, 363 executable = luci.recipe( 364 name = "presubmit", 365 ), 366 properties = { 367 "group_name": "android-aarch64", 368 }, 369 caches = [ 370 swarming.cache("builder", name = "linux_builder_cache"), 371 ], 372 category = "android", 373 # TODO(b/349907813): Enable in presubmit once stabilized 374 presubmit = False, 375) 376 377infra_builder( 378 name = "push_to_github", 379 executable = luci.recipe( 380 name = "push_to_github", 381 ), 382 postsubmit = True, 383) 384 385infra_builder( 386 name = "build_docs", 387 executable = luci.recipe( 388 name = "build_docs", 389 ), 390 postsubmit = True, 391) 392 393infra_builder( 394 name = "update_chromeos_merges", 395 executable = luci.recipe( 396 name = "update_chromeos_merges", 397 ), 398 schedule = "0,30 * * * *", # Run every 30 minutes 399 postsubmit = False, 400) 401