diff --git a/.github/workflows/build.main.kts b/.github/workflows/build.main.kts index 5e0a696c3..803f4bdb1 100755 --- a/.github/workflows/build.main.kts +++ b/.github/workflows/build.main.kts @@ -71,4 +71,46 @@ workflow( ) } } + + job( + id = "build_kotlin_scripts", + name = "Build Kotlin scripts", + runsOn = UbuntuLatest, + ) { + uses(action = Checkout()) + run( + command = """ + find -name *.main.kts -print0 | while read -d ${'$'}'\0' file + do + echo "Compiling ${'$'}file..." + kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "${'$'}file" + done + """.trimIndent() + ) + } + + job( + id = "workflows_consistency_check", + name = "Run consistency check on all GitHub workflows", + runsOn = UbuntuLatest, + ) { + uses(action = Checkout()) + run(command = "cd .github/workflows") + run( + name = "Regenerate all workflow YAMLs", + command = """ + find -name "*.main.kts" -print0 | while read -d ${'$'}'\0' file + do + if [ -x "${'$'}file" ]; then + echo "Regenerating ${'$'}file..." + (${'$'}file) + fi + done + """.trimIndent(), + ) + run( + name = "Check if some file is different after regeneration", + command = "git diff --exit-code .", + ) + } } diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f1e8871b6..07e22196e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -109,3 +109,41 @@ jobs: - id: 'step-4' name: 'Build' run: './gradlew build --stacktrace' + build_kotlin_scripts: + name: 'Build Kotlin scripts' + runs-on: 'ubuntu-latest' + needs: + - 'check_yaml_consistency' + steps: + - id: 'step-0' + uses: 'actions/checkout@v4' + - id: 'step-1' + run: |- + find -name *.main.kts -print0 | while read -d $'\0' file + do + echo "Compiling $file..." + kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "$file" + done + workflows_consistency_check: + name: 'Run consistency check on all GitHub workflows' + runs-on: 'ubuntu-latest' + needs: + - 'check_yaml_consistency' + steps: + - id: 'step-0' + uses: 'actions/checkout@v4' + - id: 'step-1' + run: 'cd .github/workflows' + - id: 'step-2' + name: 'Regenerate all workflow YAMLs' + run: |- + find -name "*.main.kts" -print0 | while read -d $'\0' file + do + if [ -x "$file" ]; then + echo "Regenerating $file..." + ($file) + fi + done + - id: 'step-3' + name: 'Check if some file is different after regeneration' + run: 'git diff --exit-code .'