How to Limit what can trigger a build on Cirrus CI #1223
-
With the bigger changes going on over here at Cirrus, I'm hoping to limit the amount of builds that are run for one of my repositories, but reading through the docs I'm having a hard time finding out how to do what I'm hoping. I'm hoping to limit Cirrus builds like so:
Thing is, I'm hoping to enforce these as the only way to trigger a Cirrus build. If I add both: required_pr_labels: initial-review
trigger_type: manual Will this work? Or will the Is there anything I can inspect within the cirrus script to conditionally start a task based on what triggered it? Similar to the GitHub Actions As you can see I'm a little stuck, but I'm hoping there's a way to restrict builds only to the three events listed above, or at least a subset of them, or at the very least a way to disable automatic tasks on every commit and PR, would greatly appreciate any assistance. Thanks! EDIT: Would it be possible to add an Since to put those requirements into real world usage:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, I'm another member of the same team (pulsar-edit org on GitHub). So, I totally concur with this post, we want to know how to block most types of builds to control credit use. EDIT: I realize the crux of my original comment was a tangentially related feature request, kind of off-topic or more of a long-term thing, whereas original post is a short-term question, so I'm hiding it behind an expandable thingy... Original comment (click to expand):My two cents: I hope [eventually] these restrictions can be done on the Cirrus site's settings dashboard, so various GitHub users have no way to evade the restrictions (or simply edit them out of (The permissions model being a privileged team member-only action, not editable in a regular config file in the repo (for example in a drive-by PR) is what I'm thinking of.) The motivation to restrict what can trigger builds is to preserve the credits, as we are being very careful to budget our use within the free credit allocation. More about the motivation (click to expand, if you want):Not being able to effectively limit builds makes the credits (especially the first 50 free credits) feel a little unpredictable to use and make plans around. (In an example: We could go from $0 to suddenly tens or hundreds of dollars. And someone might be able to deliberately target and use up our credits if we can't lock it down. So, that is a very different scenario for planning and budgeting.) Even if we are willing to pay some amount to cover our usage, not being able to confidently specify what the usage goes toward sort of reduces the value proposition of what we can consider the credits are good for. We have to have a way to be very deliberate about what we spend money for, since we are crowd-funded and we are stewarding donated money for our operations. We have the public trust to keep in mind as for how we spend these credits/CI costs. So we want to be sure they are accomplishing something useful for the project only.) [ EDIT to clarify: We are of course also hoping to lock down what triggers our builds within the next few days, with existing technologies. I realize my comment reads like a feature request. For the medium-to-long term, I do hope for a way to do it in the Cirrus settings dashboard. But I suppose @confused-Techie was just asking how we can even restrict these things today, with |
Beta Was this translation helpful? Give feedback.
-
Hey @confused-Techie, If we are talking only about the two use case from the edit ( As for the initial question:
Finally, you can program Cirrus configuration with Starlark which can give you even more flexibility. Here is an example how you can construct tasks from multiple sources: # .cirrus.star
load("cirrus", "env", "fs")
def main(ctx):
if env.get("CIRRUS_TAG") != None:
return fs.read(".cirrus.release.yml")
if env.get("CIRRUS_PR") != None:
return fs.read(".cirrus.pr.yml")
return fs.read(".cirrus.pr.yml") + fs.read(".cirrus.e2e.yml") |
Beta Was this translation helpful? Give feedback.
Hey @confused-Techie,
If we are talking only about the two use case from the edit (
rolling
on a cron invocation andrelease
on a Github Release), then you can utilizeCIRRUS_CRON
environment variable which will contain name of the cron configuration (e.g.daily
) andCIRRUS_TAG
environment variable that will contain tag name. You can check this example of a configuration where we have a two tasks: one updates virtual machines monthly and the other builds the latest one on a GitHub release.As for the initial question:
trigger_type: manual
or better yet via therequired_pr_labels: initial-review
.…