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

Generate action wrappers code #71

Closed
krzema12 opened this issue Feb 3, 2022 · 5 comments
Closed

Generate action wrappers code #71

krzema12 opened this issue Feb 3, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@krzema12
Copy link
Member

krzema12 commented Feb 3, 2022

There should be a piece of logic that, given basic info about the action, generates Kotlin code.

@jmfayard
Copy link
Collaborator

jmfayard commented Feb 8, 2022

I can work on that if you want @krzema12
I have experience working with https://github.com/square/kotlinpoet

@krzema12
Copy link
Member Author

krzema12 commented Feb 8, 2022

@jmfayard That would be really cool, let's try that! I thought about kotlinpoet, but then I figured it will be simpler to generate the whole code by hand because I don't have experience with kotlinpoet. However, I'm open to checking how kotlinpoet will work for us.

So far I don't have much: https://github.com/krzema12/github-actions-kotlin-dsl/commits/generator .
Quickly describing my idea and plan:

  • an independent Gradle module that handles wrappers code generation. Input for a single wrapper: actions's owner, name and version. Output: wrapper's code and target path
  • have a central place with a list of wrappers that should be generated
  • each wrapper should be customizable in terms of e.g. how a certain input should be modeled. Default is a string, but one could use various modes like "integer with special value" or "enumeration with custom value"
  • generating the wrappers on demand, not during building the library. In the future, we can thought about making it more intelligent, e.g. (re)generating only these that need to be (re)generated
  • best if generated code was kept in another source set, to distinguish it from the manually written code
  • prior to generation, remove all generated code so that no leftover from previous generations is left
  • have solid tests for different edge cases

I propose to implement and merge it often and in small pieces, so that if our ideas diverge, we can quickly sync and no large amount of work could be wasted in case of change of approach.

@jmfayard
Copy link
Collaborator

jmfayard commented Feb 8, 2022

I have a MVP here #75

krzema12 added a commit that referenced this issue Feb 9, 2022
krzema12 added a commit that referenced this issue Feb 9, 2022
Reading GitHub docs, it turned out this YAML file is called "metadata".
krzema12 pushed a commit that referenced this issue Feb 10, 2022
PoC prepared by Jean-Michel Fayard, refactored by Piotr Krzemiński.
krzema12 added a commit that referenced this issue Feb 10, 2022
It's not really needed to make them data classes, it's even against
their real meaning. Their task is to get built and execute
`toYamlArguments()` function.
krzema12 added a commit that referenced this issue Feb 10, 2022
This is the first wrapper that can be generated. It's the simplest one.
krzema12 added a commit that referenced this issue Feb 10, 2022
It's not needed since the code is generated, and we have unit tests in
the generator for generated code.
krzema12 added a commit that referenced this issue Feb 10, 2022
To say more about the complexity level of this action and wrapper.
krzema12 added a commit that referenced this issue Feb 11, 2022
krzema12 added a commit that referenced this issue Feb 11, 2022
krzema12 added a commit that referenced this issue Feb 12, 2022
…name

Needed to generate custom type name in enum typing.
krzema12 added a commit that referenced this issue Feb 12, 2022
krzema12 added a commit that referenced this issue Feb 13, 2022
Before this change, when rendering the comment in IntelliJ, the link
was invisible. Now it's visible and clickable. I couldn't set the same
visible text as the URL because then the link is not visible (a bug?).
krzema12 added a commit that referenced this issue Feb 13, 2022
Not needed when all wrappers are generated.
@krzema12
Copy link
Member Author

krzema12 commented Feb 13, 2022

Nice milestone: all wrappers are now generated, there're no hand-crafted ones. What I plan to do still in this task:

@jmfayard
Copy link
Collaborator

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants