Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cirrus Config via Starlark #45

Closed
fkorotkov opened this issue Oct 25, 2019 · 6 comments · Fixed by #46
Closed

Cirrus Config via Starlark #45

fkorotkov opened this issue Oct 25, 2019 · 6 comments · Fixed by #46

Comments

@fkorotkov
Copy link
Contributor

YAML is pretty limiting and doesn't allow easily to have custom logic and makes it harder to be concise in some cases.

It will be great to have an option to generate tasks via .cirrus.star written in Starlark.

def main(ctx):
  return {
    "name": "Test Task",
    "instance": container("alpine:latest")
    "steps": [
      clone(),
      script(name = "env",  content = "printenv")
    ]
  }

ctx will include ctx.env for getting environment variables and ctx.functions to invoke helper functions while generating a set of tasks.

@fkorotkov
Copy link
Contributor Author

It will be also possible to expose helper functions like fileExists(relativePath) and fileContent(relativePath) for even more advanced customization like generating a lint task only if lint config is presented. This will make it easy to start sharing common configs like described in cirruslabs/cirrus-ci-docs#106

@RDIL
Copy link

RDIL commented Oct 25, 2019

To be honest, I'm a fan of this approach, except for the proposed language. I feel like new users shouldn't need to learn a whole new language just to do advanced configuration. I feel like Python would work much better for this.

@fkorotkov
Copy link
Contributor Author

Starlark is a deterministic subset of Python basically. 👌

@RDIL
Copy link

RDIL commented Oct 25, 2019

Doesn't look too much like python :(

@RDIL
Copy link

RDIL commented Oct 25, 2019

Actually it does, but that is awful following of EP 8

@fkorotkov
Copy link
Contributor Author

Plus, let's give the ability to call GitHub APIs via ctx.github and let's evaluate the script for every GitHub Webhook Event. That way it will be possible to also write something like GitHub Actions but because of the reproducibility and ability to run Starlark in-process securely this "Cirrus Actions" will be instant and will cost nothing until the output of the evaluation is a Cirrus Build.

@fkorotkov fkorotkov transferred this issue from cirruslabs/cirrus-ci-docs Aug 21, 2020
edigaryev added a commit that referenced this issue Aug 25, 2020
edigaryev added a commit that referenced this issue Aug 25, 2020
* Remove run's --file command-line option

It makes little sense now as we're introducing Starlark.

* Basic Starlark support

Resolves #45.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants