Thread
#github-actions-kotlin-dsl
    s

    Starr

    3 months ago
    Hi! I recently heard of this project, and it looks really cool! A while ago I wrote https://github.com/Starlight220/ActionsKtLib: a small library for writing (Docker-based) GH Actions in Kotlin. I think there might be room for some integrations or something, and I'm open to cooperation!
    Piotr Krzemiński

    Piotr Krzemiński

    3 months ago
    Hi, looks really cool! Just a few days ago I created my first GH action - indeed in Kotlin and Docker-based: https://github.com/krzema12/github-actions-typing. The action has just one input, but if it ever grows, I'll consider using your library 😃
    BTW, if you own some action (I saw at least one: https://github.com/krzema12/github-actions-typing), maybe you could consider introducing typing for your action's API? See the README in https://github.com/krzema12/github-actions-typing and let me know how it looks. As maintainers of the Kotlin GH workflows DSL we would really love if each action owner would maintain the typings themselves. You can help us start this movement 😃
    If be happy to use your library as well, for the sake of just trying it out and sharing feedback
    s

    Starr

    3 months ago
    thanks, and I'd be happy to get some feedback. The lib started from a Action I wrote, I saw that I had a lot of boilerplate for interacting with inputs/outputs/etc so I decided to split it out.
    the aforementioned action will probably need some cleanup and polishing before being transferred to a org, so I'll try to add the typing spec then. when I get to it, I'll share any feedback I have
    Piotr Krzemiński

    Piotr Krzemiński

    3 months ago
    Regarding inputs reading, did you consider returning
    null
    or some other value instead of throwing an exception if a given input is not set? I prefer such exceptionless APIs for the sake of FP approach, sometimes for performance. I suggest having two variants in the library, like Kotlin's stdlib does sometimes
    s

    Starr

    3 months ago
    I also prefer FP, but I didn't think of it at the time. Now that you mention it, it's a great idea, only that delegates aren't very friendly to nullable or
    Result
    types. I think I'll migrate the low-level function to return
    null
    (or add an
    *OrNull
    variant), and pull the exception up to the delegate syntax sugar.
    Piotr Krzemiński

    Piotr Krzemiński

    3 months ago
    only that delegates aren't very friendly to nullable or
    Result
    types
    See e. g. https://ajalt.github.io/clikt/ - this library allows reading a CLI option that's optional, then the delegate's returned type is nullable. Unless I don't understand the problem 😃
    v

    Vampire

    3 months ago
    indeed in Kotlin and Docker-based
    May I ask why you did it Docker-based? They are slower than JavaScript based and are only running on Linux runners and only if Docker is installed while the JavaScript actions should run on any valid runner. And thanks to Kotlin/JS you can still write them in Kotlin unless you need some JVM-only dependencies. https://github.com/Vampire/setup-wsl is an example of how to do it. 😃
    s

    Starr

    3 months ago
    I considered using Kotlin/JS (and there's a library for that, I linked to it in the comparison section of the README), but the original action I wrote used was a lot of regexes and file io, and I was more comfortable/knowledgable with the JVM APIs for that stuff
    Piotr Krzemiński

    Piotr Krzemiński

    3 months ago
    I also started my action as a Node-based, with Kotlin/JS, but the multiplatform YAML library i tried wasn't mature enough and lacked key features. Then I switched to JVM
    s

    Starr

    3 months ago
    And isnt there an action or something to setup docker on any platform?
    v

    Vampire

    3 months ago
    Even if there is, wouldn't change a thing. GitHub Actions defines that docker actions are only usable on Linux runners with docker installed. So even if you have a custom mac or windows runner with docker installed, it will not work.
    s

    Starr

    3 months ago
    Source?
    v

    Vampire

    3 months ago
    GitHub documentation as of 45 minutes ago
    https://docs.github.com/en/actions/creating-actions/about-custom-actions:
    Type | Operating system
    Docker container | Linux
    JavaScript | Linux, macOS, Windows
    Composite Actions | Linux, macOS, Windows
    and
    Docker container actions can only execute on runners with a Linux operating system. Self-hosted runners must use a Linux operating system and have Docker installed to run Docker container actions.
    https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action:
    Self-hosted runners must use a Linux operating system and have Docker installed to run Docker container actions.
    s

    Starr

    3 months ago
    I see.