Open anarazel opened 1 year ago
I think you can already achieve this using Starlark and CIRRUS_REPO_OWNER
environment variable. You can extract the YAML achors in two different files like .ci/our_instances.yml
and .ci/cirrus_instances.yml
and put something like the following in your .cirrus.star
file:
load("cirrus", "env", "fs")
def main(ctx):
if env.get("CIRRUS_REPO_OWNER") == "OUR GITHUB ORGANIZATION":
return fs.read(".ci/our_instances.yml")
return fs.read(".ci/cirrus_instances.yml")
Unfortunately I think that doesn't work, presumably due to yaml anchors having to be defined before they're used, and the starlark configuration is appended to .cirrus.yml
. I get
Error while parsing tasks: INVALID_ARGUMENT: yaml: unknown anchor 'linux_instance' referenced!
and .cirrus.star isn't even executed.
Nor does my sketch from above work: matrix can be defined only under a task, docker_builder or pipe
You can probably move .cirrus.yml
into .ci/cirrus.yml
and then do concatication in any order you'd like in .cirrus.start
.
load("cirrus", "env", "fs")
def main(ctx):
if env.get("CIRRUS_REPO_OWNER") == "OUR GITHUB ORGANIZATION":
return fs.read(".ci/our_instances.yml") + "\n" + fs.read(".ci/cirrus.yml")
return fs.read(".ci/cirrus_instances.yml") + "\n" + fs.read(".ci/cirrus.yml")
Hi,
For an open source process it makes a lot of sense to allow everyone to use cirrus-ci in their forks using the "free" credits, but to use custom compute or persistent runners for the, commonly much higher, usage of the project itself. The switch would need to happen based on what's present in repository level environment variables. Right now that's somewhat painful to implement in
.cirrus.yml
however.Part of the issue are some small differences in the way tasks are specified. E.g. for
custom_engine_instance:
image families are specified viaimage: family/docker-kvm
whereas forgce_instance:
they are specified asimage_family: ubuntu-2204-lts-arm64
.My current best guess for how to implement this is something roughly like:
Which does end up somewhat painful...
Thanks,
Andres