Ennio Visconti
06/14/2023, 12:25 PMval workflow = workflow(
name = "test"
on = listOf(Push())
) {
job(
id = "test_job"
) {
// ...
}
}
workflow.writeToFile()
To:
workflow {
name = "test"
on = listOf(Push())
job {
id = "test_job"
// ...
}
writeToFile()
}
My motivation for this is that it is more in-line with gradle’s dsl and closer to the original yaml syntax.
You can read more details here: https://github.com/typesafegithub/github-workflows-kt/issues/874Piotr Krzemiński
06/14/2023, 12:30 PMprint(workflow.toYaml())
, but that’s actually discouraged - nowadays we do `workflow { }.writeToFile()`(fixed the docs here). It’s important to get the full picture of how the YAML gets into the actual YAML filePiotr Krzemiński
06/14/2023, 12:31 PMEnnio Visconti
06/14/2023, 12:33 PMPiotr Krzemiński
06/14/2023, 12:34 PMworkflow(
name = "test"
on = listOf(Push())
) {
job(
id = "test_job"
) {
// ...
}
}.writeToFile()
which makes it a bit shorter. Probably a matter of style nowEnnio Visconti
06/14/2023, 12:38 PMPiotr Krzemiński
06/14/2023, 12:39 PM.writeToFile()
inside the workflow
function, right?Piotr Krzemiński
06/14/2023, 12:39 PMwriteToFile()
inside workflow { }
Piotr Krzemiński
06/14/2023, 12:39 PMPiotr Krzemiński
06/14/2023, 12:41 PMPiotr Krzemiński
06/14/2023, 12:41 PMEnnio Visconti
06/14/2023, 12:45 PMworkflow {..}
, wouldn’t it?Piotr Krzemiński
06/14/2023, 12:47 PMworkflow {
// ...
writeToFile()
}
looks like writeToFile()
is a part of the process of building the workflow object, and it’s not - it’s storing the object in a serialized form, so in my head it doesn’t fit the curly braces for workflow { ... }
- do you know what I mean?Piotr Krzemiński
06/14/2023, 12:47 PMworkflow { }
- build the workflow
• .writeToFile()
- store the file
seems logicalPiotr Krzemiński
06/14/2023, 12:48 PMwriteToFile()
inside the implementation of workflow { }
which would kinda simplify the workflow file, and it actually made more sense to me because people usually do itEnnio Visconti
06/14/2023, 12:49 PMEnnio Visconti
06/14/2023, 12:50 PMPiotr Krzemiński
06/14/2023, 12:51 PMEnnio Visconti
06/14/2023, 12:51 PMtoYaml
, writeToFile
, etc.Piotr Krzemiński
06/14/2023, 12:51 PMPiotr Krzemiński
06/14/2023, 12:53 PMtoYaml()
in your workflows in some fancy way, or it’s just building the workflow and storing/printing it?Piotr Krzemiński
06/14/2023, 12:56 PMPiotr Krzemiński
06/14/2023, 12:56 PMwriteToFile()
hidden in the implementation of workflow
makes most sense to meEnnio Visconti
06/14/2023, 1:01 PMVampire
06/14/2023, 1:38 PMtoYaml
afair as it produces a different result, e.g. regarding the consistency check.
When I had to modify the result, e.g. before the explicit preamble support, I used writeToFile
, then read the file modify and save again.Vampire
06/14/2023, 1:40 PMPiotr Krzemiński
06/14/2023, 1:52 PMworkflow
call, preserving current defaults. I'm also tempted to remove toYaml()
altogetherVampire
06/14/2023, 2:49 PMtoYaml()
for example for cases where someone has some other management / system from which he uses the lib instead of using it from a .main.kts
file?
I vaguely remember at least one conversation here about such a case.Vampire
06/14/2023, 2:52 PMPiotr Krzemiński
06/14/2023, 2:54 PMNikky
06/15/2023, 1:04 PMname = "test"
on = listOf(Push())
is that you are not as sure that you passed in all the required parameters.. discoverability is more of a pain..
this would imho remove some of the benefits of writing this in kotlin
if we can maintain both .. or it can be pubished as a separate optional library.. that would be less of a issue
it does seem to look nicer…
BUT i hate having to run code just to have the code crash at runtime, telling me that i missed some required parameter… probably without even giving me a line to look at.. or deeply hidden in some stacktrace that i have to pull out if the terminal with fucked up linebreaksPiotr Krzemiński
06/15/2023, 1:06 PMNikky
06/15/2023, 1:07 PMNikky
06/15/2023, 1:08 PMEnnio Visconti
06/15/2023, 1:10 PMNikky
06/15/2023, 1:12 PMthis.
to hope for it to give you a list of all the properties and function that you could be calling on the current scope (which will be way more than the required params)Nikky
06/15/2023, 1:13 PMEnnio Visconti
06/15/2023, 1:16 PMCtrl
+ Shift
+ Space
does show you suggestions including extension functions in IntelliJ AFAIKNikky
06/15/2023, 1:17 PMEnnio Visconti
06/15/2023, 1:18 PMEnnio Visconti
06/15/2023, 1:18 PMEnnio Visconti
06/15/2023, 1:19 PMNikky
06/15/2023, 1:19 PMNikky
06/15/2023, 1:19 PMNikky
06/15/2023, 1:20 PMEnnio Visconti
06/15/2023, 1:20 PMEnnio Visconti
06/15/2023, 1:21 PMNikky
06/15/2023, 1:22 PMNikky
06/15/2023, 1:22 PMPiotr Krzemiński
06/15/2023, 1:26 PMPiotr Krzemiński
06/15/2023, 1:26 PMNikky
06/15/2023, 1:30 PMEnnio Visconti
06/15/2023, 1:35 PMNikky
06/15/2023, 1:35 PMNikky
06/15/2023, 1:36 PMNikky
06/15/2023, 1:37 PMDamien O'Hara
06/15/2023, 1:38 PMNikky
06/15/2023, 1:39 PMVampire
06/15/2023, 1:41 PMDamien O'Hara
06/15/2023, 1:41 PMNikky
06/15/2023, 1:44 PMDamien O'Hara
06/15/2023, 1:47 PMPiotr Krzemiński
06/15/2023, 1:50 PMPiotr Krzemiński
08/17/2023, 10:12 AMPiotr Krzemiński
01/04/2024, 8:41 PM