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

Create a Kotlin CLI to improve overall developer workflow #464

Open
jmfayard opened this issue Sep 28, 2022 · 6 comments
Open

Create a Kotlin CLI to improve overall developer workflow #464

jmfayard opened this issue Sep 28, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@jmfayard
Copy link
Contributor

What feature do you need?

An executable, let's calll it gakd for now, (not an actual good name), to make it easier to get started with the library and with the manual boring tasks.

See discussion at https://kotlinlang.slack.com/archives/C02UUATR7RC/p1664388882767549

Do you have an example usage?

$ gakd
Authoring GitHub Actions workflows in Kotlin.

gakd init         Bootstrap your repository
gakd sync         Sync all YAML files
gakd convert      Convert your YAML files to a Kotlin script
gakd doctor       trouble shooting
gakd docs         Open https://krzema12.github.io/github-actions-kotlin-dsl
gakd github       Open https://github.com/krzema12/github-actions-kotlin-dsl

Is there a workaround for not having this feature? If yes, please describe it.

Writing some ugly bash script

@jmfayard jmfayard added the enhancement New feature or request label Sep 28, 2022
@jmfayard jmfayard added this to the v1 (stable) milestone Sep 28, 2022
@jmfayard
Copy link
Contributor Author

Some note on the Slack thread on what the executable could do

  • detekt if Kotlin is already installed, else tels you to open https://kotlinlang.org/docs/command-line.html
  • list all .github/workflows/*.kts available
  • maybe automatically chmod +x because this shit is boring
  • check which input and output files have changed
  • runs the one that needs to be modified
  • maybe suggest to install a git-prepush hook? (I'm not a fan)

@jmfayard
Copy link
Contributor Author

Some note on how to build the CLI tool

I have some experience with it due to https://github.com/jmfayard/kotlin-cli-starter

And my suggestion will sounds surprising but I would recommend to implement the script with Kotlin/JS

Why? Because distribution on native and on the JVM sucks.
On the other hand everything is in place with node.js/npm

@jmfayard jmfayard changed the title Create a Kotlin executable to improve overallall developer workflow Create a Kotlin CLI to improve overallall developer workflow Sep 28, 2022
@jmfayard jmfayard changed the title Create a Kotlin CLI to improve overallall developer workflow Create a Kotlin CLI to improve overall developer workflow Sep 28, 2022
@JavierSegoviaCordoba
Copy link

JavierSegoviaCordoba commented Sep 30, 2022

I haven't thought about this in a more profound way, but integration with Gradle should be great.

I don't know the current implementation details and names so I will create some ones.

For example, if the API exposed is similar to how Gradle tasks work, I.E. an interface has to be implemented to create a workflow file, I would expect something like:

fun interface GitHubActionKotlinDSL {
    fun GitHubDSL.run()
}

Implemented in an included build:

val fooWorkflow = GitHubActionKotlinDSL {
  // implement the foo workflow with the DSL here
}

val barWorkflow = GitHubActionKotlinDSL {
  // implement the bar workflow with the DSL here
}

And the Kotlin Plugin applied (root project):

plugins {
    id("gha-dsl-gradle-plugin") // whatever name
}

gitHubActionsKotlinDSL {
    workflows.set(listOf(fooWorkflow, barWorkflow))
	// or
    workflows(fooWorkflow, barWorkflow)
}

A Gradle task with whatever generateGhaDsl name will be attached to the assemble task.

Another advantage is, those foo/bar workflows can be published to MavenCentral and added to any Gradle project too.

@jmfayard
Copy link
Contributor Author

@JavierSegoviaCordoba writing a Gradle plugin is possible
the issue I see is that if github-actions.kts becomes popular enough,
we will have people using lots of different build systems.
Could be maven.
Could be a guy doing TypeScript or Rust at the moment but who also knows a bit of Kotlin and prefer it over YAML
etc.

@krzema12
Copy link
Member

krzema12 commented Jun 2, 2023

It would be nice to have this, but I guess it's not needed for v1.

@krzema12 krzema12 removed this from the v1 (stable) milestone Jun 2, 2023
@jmfayard
Copy link
Contributor Author

jmfayard commented Jun 3, 2023

For https://github.com/typesafegithub/yaml2kotlin I'm entirely focused on the web app solution, not on the CLI

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

3 participants