summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.star50
-rw-r--r--.cirrus.yml12
-rw-r--r--src/tools/ci/README11
3 files changed, 67 insertions, 6 deletions
diff --git a/.cirrus.star b/.cirrus.star
index d2d6ceca207..29f019114a1 100644
--- a/.cirrus.star
+++ b/.cirrus.star
@@ -7,7 +7,7 @@ https://github.com/bazelbuild/starlark/blob/master/spec.md
See also .cirrus.yml and src/tools/ci/README
"""
-load("cirrus", "env", "fs")
+load("cirrus", "env", "fs", "yaml")
def main():
@@ -18,19 +18,36 @@ def main():
1) the contents of .cirrus.yml
- 2) if defined, the contents of the file referenced by the, repository
+ 2) computed environment variables
+
+ 3) if defined, the contents of the file referenced by the, repository
level, REPO_CI_CONFIG_GIT_URL variable (see
https://cirrus-ci.org/guide/programming-tasks/#fs for the accepted
format)
- 3) .cirrus.tasks.yml
+ 4) .cirrus.tasks.yml
"""
output = ""
# 1) is evaluated implicitly
+
# Add 2)
+ additional_env = compute_environment_vars()
+ env_fmt = """
+###
+# Computed environment variables start here
+###
+{0}
+###
+# Computed environment variables end here
+###
+"""
+ output += env_fmt.format(yaml.dumps({'env': additional_env}))
+
+
+ # Add 3)
repo_config_url = env.get("REPO_CI_CONFIG_GIT_URL")
if repo_config_url != None:
print("loading additional configuration from \"{}\"".format(repo_config_url))
@@ -38,12 +55,37 @@ def main():
else:
output += "\n# REPO_CI_CONFIG_URL was not set\n"
- # Add 3)
+
+ # Add 4)
output += config_from(".cirrus.tasks.yml")
+
return output
+def compute_environment_vars():
+ cenv = {}
+
+ # Some tasks are manually triggered by default because they might use too
+ # many resources for users of free Cirrus credits, but they can be
+ # triggered automatically by naming them in an environment variable e.g.
+ # REPO_CI_AUTOMATIC_TRIGGER_TASKS="task_name other_task" under "Repository
+ # Settings" on Cirrus CI's website.
+
+ default_manual_trigger_tasks = []
+
+ repo_ci_automatic_trigger_tasks = env.get('REPO_CI_AUTOMATIC_TRIGGER_TASKS', '')
+ for task in default_manual_trigger_tasks:
+ name = 'CI_TRIGGER_TYPE_' + task.upper()
+ if repo_ci_automatic_trigger_tasks.find(task) != -1:
+ value = 'automatic'
+ else:
+ value = 'manual'
+ cenv[name] = value
+
+ return cenv
+
+
def config_from(config_src):
"""return contents of config file `config_src`, surrounded by markers
indicating start / end of the the included file
diff --git a/.cirrus.yml b/.cirrus.yml
index a83129ae46d..f270f61241f 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -10,12 +10,20 @@
#
# 1) the contents of this file
#
-# 2) if defined, the contents of the file referenced by the, repository
+# 2) computed environment variables
+#
+# Used to enable/disable tasks based on the execution environment. See
+# .cirrus.star: compute_environment_vars()
+#
+# 3) if defined, the contents of the file referenced by the, repository
# level, REPO_CI_CONFIG_GIT_URL variable (see
# https://cirrus-ci.org/guide/programming-tasks/#fs for the accepted
# format)
#
-# 3) .cirrus.tasks.yml
+# This allows running tasks in a different execution environment than the
+# default, e.g. to have sufficient resources for cfbot.
+#
+# 4) .cirrus.tasks.yml
#
# This composition is done by .cirrus.star
diff --git a/src/tools/ci/README b/src/tools/ci/README
index d67e9c54935..edb824bbebf 100644
--- a/src/tools/ci/README
+++ b/src/tools/ci/README
@@ -82,3 +82,14 @@ defined in .cirrus.yml, by redefining the relevant yaml anchors.
Custom compute resources can be provided using
- https://cirrus-ci.org/guide/supported-computing-services/
- https://cirrus-ci.org/guide/persistent-workers/
+
+
+Enabling manual tasks by default
+================================
+
+Some tasks are not triggered automatically by default, to avoid using up CI
+credits too quickly. This can be changed on the repository level, e.g. when
+custom compute resources are configured.
+
+The following repository level environment variables are recognized:
+- REPO_CI_AUTOMATIC_TRIGGER_TASKS=""