I plan on migrating our large project to use this ...
# github-workflows-kt
a
I plan on migrating our large project to use this library today. Fingers crossed
đŸ€ž 1
p
good luck! I hope there won't be missing core features, at most some missing wrappers 🙂
is the project open-source? could you share it here?
a
sadly it is not open source
👍 1
Hi, I am having some issues a bit Consistency Check fails with
Copy code
Run diff -u '.github/workflows/commit.yml' <('.github/workflows/commit.main.kts')
  diff -u '.github/workflows/commit.yml' <('.github/workflows/commit.main.kts')
  shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/9258ee6d-1a1e-4263-aeca-4f82f632d5a5.sh: line 1: .github/workflows/commit.main.kts: Permission denied
--- .github/workflows/commit.yml	2022-02-17 02:42:39.000422023 +0000
+++ /dev/fd/63	2022-02-17 02:43:00.416754247 +0000
@@ -1,44 +0,0 @@
p
your Kotlin script needs to be executable:
Copy code
chmod +x .github/workflows/commit.main.kts
a
it is already executable. What am I missing here?
Copy code
ls -al ./commit.main.kts
-rwxrwxrwx 1 root root 1758 Feb 17 09:39 ./commit.main.kts
p
could you paste the piece of your Kotlin code where you define the workflow (call to
workflow(...)
)?
and what's the name of your Kotlin file and desired YAML file? I sometimes mix .yml and .yaml 😄
a
file:
.github/workflows/commit_tests.main.kts
Copy code
#!/usr/bin/env kotlin

@file:DependsOn("it.krzeminski:github-actions-kotlin-dsl:0.8.0")

import it.krzeminski.githubactions.actions.actions.CheckoutV2
import it.krzeminski.githubactions.actions.actions.SetupJavaV2
import it.krzeminski.githubactions.domain.RunnerType.UbuntuLatest
import it.krzeminski.githubactions.domain.triggers.Push
import it.krzeminski.githubactions.dsl.workflow
import it.krzeminski.githubactions.yaml.toYaml
import java.nio.file.Paths

val commit = workflow(
    name = "Commit Test",
    on = listOf(Push(branches = listOf("master-dev-*"))),
    sourceFile = Paths.get(".github/workflows/commit_tests.main.kts"),
    targetFile = Paths.get(".github/workflows/commit_tests.yml")
) {
    job(name = "testing", runsOn = UbuntuLatest) {
        uses(name = "Check out", action = CheckoutV2())
        uses(
            name = "Set up JDK 17",
            action = SetupJavaV2(
                distribution = SetupJavaV2.Distribution.Zulu,
                javaVersion = "17",
                cache = SetupJavaV2.BuildPlatform.Gradle
            )
        )
        run(
            name = "Make gradle executable",
            command = "chmod +x ./gradlew"
        )
        run(
            name = "Downloading gradle",
            command = "./gradle jvmTest"
        )
        run(
            name = "Running jvm tests",
            command = "./gradlew jvmTest"
        )
        run(
            name = "Run pimonitor-app-server tests",
            command = "./gradlew :pimonitor-app-server:test"
        )
        run(
            name = "Running js tests",
            command = "./gradlew jsTest"
        )
        run(
            name = "Build project",
            command = "./gradlew build"
        )
    }
}

println(commit.toYaml())
The generate yml file is even valid. It just happens to fail in CI with
permission denied
p
to further debug it, I'd try calling these commands separately in GH workflow: ‱
.github/workflows/commit_tests.main.kts
- calling the script, it should print out the YAML ‱ if the above works, let's check if there's permission issue with writing to file
echo 'hello' > .github/workflows/commit_tests.yml
as a workaround if you want to disable the consistency check, you can use
addConsistencyCheck = false
, but it would be cool to understand why it doesn't work, may be a bug in the library
l
Could it be a JDK version issue?
a
Trying now with
addConsistencyCheck=false
@louiscad which JDK are you referring to? the one I set in my actions?
p
IMO it's related solely to shell
l
@andylamax Not sure, it was just a random thought, related to the fact that the JDK has been increasingly adding restrictions since Java 9
a
addConsistencyCheck=false
worked. Coz that whole job (which was failing) is not being created now
p
but then please be careful to keep both files in sync, until we clarify what happens
I'll try to reproduce it later
if you have a moment, would be cool if you could prepare a repo with a reproducer
a
sure thing. I'll try to do so
p
feel free to create a bug if you manage to reproduce it in an open-source repo