Create a Kotlin CLI to improve overall developer workflow · Issue #464 · typesafegithub/github-workflows-kt · GitHub
Skip to content

Create a Kotlin CLI to improve overall developer workflow #464

Open

Description

@jmfayard

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

Activity

  1. added this to the v1 (stable) milestone on Sep 28, 2022
  2. jmfayard commented on Sep 28, 2022

    @jmfayard
    ContributorAuthor

    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)
  3. jmfayard commented on Sep 28, 2022

    @jmfayard
    ContributorAuthor

    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

  4. changed the title [-]Create a Kotlin executable to improve overallall developer workflow[/-] [+]Create a Kotlin CLI to improve overallall developer workflow[/+] on Sep 28, 2022
  5. changed the title [-]Create a Kotlin CLI to improve overallall developer workflow[/-] [+]Create a Kotlin CLI to improve overall developer workflow[/+] on Sep 28, 2022
  6. JavierSegoviaCordoba commented on Sep 30, 2022

    @JavierSegoviaCordoba

    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.

  7. jmfayard commented on Sep 30, 2022

    @jmfayard
    ContributorAuthor

    @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.

  8. krzema12 commented on Jun 2, 2023

    @krzema12
    Member

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

  9. removed this from the v1 (stable) milestone on Jun 2, 2023
  10. jmfayard commented on Jun 3, 2023

    @jmfayard
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions