Skip to content

Commit 2ce3bbd

Browse files
authored
Add consistency check and compilation for Kotlin CI scripts (#14)
1 parent 7e45aa1 commit 2ce3bbd

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/build.main.kts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,47 @@ workflow(
2929
uses(action = ActionsSetupGradle())
3030
run(command = "./gradlew build")
3131
}
32+
33+
job(
34+
id = "build_kotlin_scripts",
35+
name = "Build Kotlin scripts",
36+
runsOn = RunnerType.UbuntuLatest,
37+
) {
38+
uses(action = Checkout())
39+
run(
40+
command = """
41+
find -name *.main.kts -print0 | while read -d ${'$'}'\0' file
42+
do
43+
echo "Compiling ${'$'}file..."
44+
kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "${'$'}file"
45+
done
46+
""".trimIndent()
47+
)
48+
}
49+
50+
51+
job(
52+
id = "workflows_consistency_check",
53+
name = "Run consistency check on all GitHub workflows",
54+
runsOn = RunnerType.UbuntuLatest,
55+
) {
56+
uses(action = Checkout())
57+
run(command = "cd .github/workflows")
58+
run(
59+
name = "Regenerate all workflow YAMLs",
60+
command = """
61+
find -name "*.main.kts" -print0 | while read -d ${'$'}'\0' file
62+
do
63+
if [ -x "${'$'}file" ]; then
64+
echo "Regenerating ${'$'}file..."
65+
(${'$'}file)
66+
fi
67+
done
68+
""".trimIndent(),
69+
)
70+
run(
71+
name = "Check if some file is different after regeneration",
72+
command = "git diff --exit-code .",
73+
)
74+
}
3275
}

.github/workflows/build.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,41 @@ jobs:
3333
uses: 'gradle/actions/setup-gradle@v3'
3434
- id: 'step-2'
3535
run: './gradlew build'
36+
build_kotlin_scripts:
37+
name: 'Build Kotlin scripts'
38+
runs-on: 'ubuntu-latest'
39+
needs:
40+
- 'check_yaml_consistency'
41+
steps:
42+
- id: 'step-0'
43+
uses: 'actions/checkout@v4'
44+
- id: 'step-1'
45+
run: |-
46+
find -name *.main.kts -print0 | while read -d $'\0' file
47+
do
48+
echo "Compiling $file..."
49+
kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "$file"
50+
done
51+
workflows_consistency_check:
52+
name: 'Run consistency check on all GitHub workflows'
53+
runs-on: 'ubuntu-latest'
54+
needs:
55+
- 'check_yaml_consistency'
56+
steps:
57+
- id: 'step-0'
58+
uses: 'actions/checkout@v4'
59+
- id: 'step-1'
60+
run: 'cd .github/workflows'
61+
- id: 'step-2'
62+
name: 'Regenerate all workflow YAMLs'
63+
run: |-
64+
find -name "*.main.kts" -print0 | while read -d $'\0' file
65+
do
66+
if [ -x "$file" ]; then
67+
echo "Regenerating $file..."
68+
($file)
69+
fi
70+
done
71+
- id: 'step-3'
72+
name: 'Check if some file is different after regeneration'
73+
run: 'git diff --exit-code .'

0 commit comments

Comments
 (0)