go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/lucicfg/starlark/stdlib/internal/luci/rules/cq.star (about) 1 # Copyright 2019 The LUCI Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 """Defines luci.cq(...) rule.""" 16 17 load("@stdlib//internal/graph.star", "graph") 18 load("@stdlib//internal/lucicfg.star", "lucicfg") 19 load("@stdlib//internal/validate.star", "validate") 20 load("@stdlib//internal/luci/common.star", "keys") 21 22 def _cq( 23 ctx, # @unused 24 *, 25 submit_max_burst = None, 26 submit_burst_delay = None, 27 draining_start_time = None, 28 status_host = None): 29 """Defines optional configuration of the CQ service for this project. 30 31 CQ is a service that monitors Gerrit CLs in a configured set of Gerrit 32 projects, and launches tryjobs (which run pre-submit tests etc.) whenever a 33 CL is marked as ready for CQ, and submits the CL if it passes all checks. 34 35 **NOTE**: before adding a new luci.cq(...), visit and follow instructions 36 at http://go/luci/cv/gerrit-pubsub to ensure that pub/sub integration is 37 enabled for all the Gerrit projects. 38 39 This optional rule can be used to set global CQ parameters that apply to all 40 luci.cq_group(...) defined in the project. 41 42 Args: 43 ctx: the implicit rule context, see lucicfg.rule(...). 44 submit_max_burst: maximum number of successful CQ attempts completed by 45 submitting corresponding Gerrit CL(s) before waiting 46 `submit_burst_delay`. This feature today applies to all attempts 47 processed by CQ, across all luci.cq_group(...) instances. Optional, by 48 default there's no limit. If used, requires `submit_burst_delay` to be 49 set too. 50 submit_burst_delay: how long to wait between bursts of submissions of CQ 51 attempts. Required if `submit_max_burst` is used. 52 draining_start_time: **Temporarily not supported, see 53 https://crbug.com/1208569. Reach out to LUCI team oncall if you need 54 urgent help.**. If present, the CQ will refrain from processing any CLs, 55 on which CQ was triggered after the specified time. This is an UTC 56 RFC3339 string representing the time, e.g. `2017-12-23T15:47:58Z` and Z 57 is mandatory. 58 status_host: Optional. Decide whether user has access to the details of 59 runs in this Project in LUCI CV UI. Currently, only the following 60 hosts are accepted: 1) "chromium-cq-status.appspot.com" where everyone 61 can access run details. 2) "internal-cq-status.appspot.com" where only 62 Googlers can access run details. Please don't use the public host if 63 the Project launches internal builders for public repos. It can leak 64 the builder names, which may be confidential. 65 """ 66 submit_max_burst = validate.int("submit_max_burst", submit_max_burst, required = False) 67 submit_burst_delay = validate.duration("submit_burst_delay", submit_burst_delay, required = False) 68 69 if submit_max_burst and not submit_burst_delay: 70 fail('bad "submit_burst_delay": required if "submit_max_burst" is used') 71 if submit_burst_delay and not submit_max_burst: 72 fail('bad "submit_max_burst": required if "submit_burst_delay" is used') 73 74 key = keys.cq() 75 graph.add_node(key, props = { 76 "submit_max_burst": submit_max_burst, 77 "submit_burst_delay": submit_burst_delay, 78 "draining_start_time": validate.string("draining_start_time", draining_start_time, required = False), 79 "status_host": validate.hostname("status_host", status_host, required = False), 80 }) 81 graph.add_edge(keys.project(), key) 82 83 return graph.keyset(key) 84 85 cq = lucicfg.rule(impl = _cq)