-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use pkl-gha
for GitHub Action Workflows
#47
Conversation
I love the idea! I don't mind commit hooks as a developer convenience, but they're insufficient to guarantee consistency. Could you please add a new CI check that verifies that the generated YAML config is up-to-date with the Pkl source (like the TS |
We might also want to remove the dependabot config for GitHub Actions, since it would propose updates to the generated files, not the pkl sources: https://github.com/pkl-community/setup-pkl/blob/main/.github/dependabot.yml#L3 |
597812c
to
d7247e4
Compare
Actually I wouldn't do that. Since dependabot runs on GitHub actions we can add chain a new workflow with that. For now I would manually update the pkl files. |
pkl-gha
for GitHub Action Workflows
I'm not talking about disabling Dependabot altogether, just for the Actions part. I don't think it makes sense for it to open PRs to generated files. |
Related, it would be helpful to have pkl render out the files as eg |
Right now the generated yml files get the preamble: # Do not modify!
# This file was generated from a template using https://github.com/StefMa/pkl-gha Will also add the Is this even possible with an custom renderer? 🤔 |
Hey @jasongwartz I wanted to push this to the finish line 🙃 This question is still open: Other than that, I also rereanged some things:
Thats it I guess 🙃 Can't wait to get this thing merged 😇 |
Could you please incorporate the changes from #41 ? |
["test-action"] { | ||
strategy { | ||
matrix { | ||
["os"] = new { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this has been typed correctly in your base module, you shouldn't need = new {}
to create a new list, the override syntax ["os"] { ... }
should work. The only reason to do that typically with a Listing would be if there are default values in the parent object and you want to "start fresh" with a new Listing. Let me go check the typing in your parent module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at https://github.com/StefMa/pkl-gha/blob/main/GitHubAction.pkl#L592, I think there's extra complexity because matrix
is typed as Listing<String|*Dynamic>
. Can it really be a Dynamic object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be Dynamic.
See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-using-a-multi-dimension-matrix
A variable configuration in a matrix can be an array of objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha - to me that looks more like it could be Mapping<String, String>
- remember that Dynamic
can contain properties, entries, AND elements, eg:
new {
"an entry"
prop1 = "value"
["entry one"] = "value2"
}
Note that this is actually not representable in JSON or YAML at all (below is from the REPL):
pkl> x = new {
> "an entry"
> prop1 = "value"
> ["entry one"] = "value2"
> }
pkl> (new JsonRenderer {}).renderDocument(x)
–– Pkl Error ––
Cannot render object with both elements and properties/entries as JSON.
Object: new Dynamic { prop1 = "value"; ["entry one"] = "value2"; "an entry" }
But that's an aside, not important to this PR. Just info for you and your library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint!
Do you now how I could model this better/differently? 🤔
Thanks @StefMa ! Left a few other pointers. Re:
In So could you please add a new script there called something like "gen:actions", which runs the one-liner from my comment on the current bash script? (The script won't be necessary after that) And then you can modify the "npm run package" script to add |
Feel free to send me a message on Discord if you want a hand working through any of that! And sorry for the delay in getting back to you on this |
@jasongwartz its ready for review again 🙃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for the contribution!
Hey there 👋
as a pkl-community you might be interested in using
pkl
"everywhere" 🙃So I played over the weekened a bit and introduce
pkl-gha
(pkl for github actions) to this project.I don't mind if gets rejected.
But I just thought as pkl "fanatics" I thought it make sense to use it here 😁
Maybe todos:
pkl-gha
created files with dependabot (yaml) updates? StefMa/pkl-gha#4 (comment)