diff --git a/.github/workflows/_shared.main.kts b/.github/workflows/_shared.main.kts deleted file mode 100644 index cf337b06a..000000000 --- a/.github/workflows/_shared.main.kts +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env kotlin -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -import io.github.typesafegithub.workflows.dsl.expressions.expr - -val disableScheduledJobInForks = - expr { "${github.repository_owner} == 'typesafegithub' || ${github.event_name} != 'schedule'" } - -// The order is deliberate here. First, libraries with no dependencies are published. -// Then, libraries that depend on already published libraries, and so on. Thanks to -// such order, newly released artifacts already have their dependencies in place and -// are ready to be used. -val libraries = listOf( - ":shared-internal", - ":github-workflows-kt", - ":action-binding-generator", - ":action-updates-checker", -) diff --git a/.github/workflows/bindings-server.main.kts b/.github/workflows/bindings-server.main.kts deleted file mode 100755 index 83da1db3b..000000000 --- a/.github/workflows/bindings-server.main.kts +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:checkout:v4") -@file:DependsOn("gradle:actions__setup-gradle:v4") -@file:DependsOn("fwilhe2:setup-kotlin:0.11.0") - -import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.fwilhe2.SetupKotlin -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicStep -import io.github.typesafegithub.workflows.domain.Environment -import io.github.typesafegithub.workflows.domain.JobOutputs -import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.triggers.* -import io.github.typesafegithub.workflows.dsl.JobBuilder -import io.github.typesafegithub.workflows.dsl.expressions.Contexts -import io.github.typesafegithub.workflows.dsl.expressions.expr -import io.github.typesafegithub.workflows.dsl.workflow -import java.net.URI -import java.net.ConnectException -import java.net.http.HttpClient -import java.net.http.HttpRequest -import java.net.http.HttpResponse.BodyHandlers -import kotlin.time.Duration.Companion.minutes -import kotlin.time.TimeSource - -val DOCKERHUB_USERNAME by Contexts.secrets -val DOCKERHUB_PASSWORD by Contexts.secrets -val TRIGGER_IMAGE_PULL by Contexts.secrets -val GITHUB_TOKEN by Contexts.secrets - -@OptIn(ExperimentalKotlinLogicStep::class) -workflow( - name = "Bindings server", - on = listOf( - Push(branches = listOf("main")), - PullRequest(), - Schedule(triggers = listOf(Cron(minute = "0", hour = "0", dayWeek = "SUN"))), - WorkflowDispatch(), - ), - sourceFile = __FILE__, -) { - val endToEndTest = job( - id = "end-to-end-test", - name = "End-to-end test", - runsOn = UbuntuLatest, - env = mapOf( - "GITHUB_TOKEN" to expr { GITHUB_TOKEN }, - ), - ) { - uses(action = Checkout()) - uses(action = ActionsSetupGradle()) - - run( - name = "Start the server", - command = "./gradlew :jit-binding-server:run &", - ) - - run(name = "Wait for the server to respond") { - val timeSource = TimeSource.Monotonic - val waitStart = timeSource.markNow() - val timeout = 3.minutes - - while (timeSource.markNow() - waitStart < timeout) { - try { - HttpClient.newHttpClient().send( - HttpRequest - .newBuilder(URI("http://0.0.0.0:8080/status")) - .GET() - .build(), BodyHandlers.ofString() - ) - println("The server is alive!") - break - } catch (_: ConnectException) { - Thread.sleep(5000) - println("The server is still starting...") - } - } - } - - cleanMavenLocal() - - run( - name = "Execute the script using the bindings from the server", - command = """ - mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts - .github/workflows/test-script-consuming-jit-bindings.main.kts - """.trimIndent(), - ) - - cleanMavenLocal() - - run( - name = "Execute the script using bindings but without dependency on library", - command = """ - mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - .github/workflows/test-served-bindings-depend-on-library.main.kts - """.trimIndent(), - ) - - // There should be a difference of one (mostly minor) version between these two, - // to be able to see the newest non-working and oldest working version. - val newestNotCompatibleVersion = "1.9.0" - val oldestCompatibleVersion = "2.0.0" - - runWithSpecificKotlinVersion( - kotlinVersion = newestNotCompatibleVersion, - command = """ - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts - ${failsWithPhraseInLogs( - command = ".github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts", - // This test depicts the current behavior that the served bindings aren't - // compatible with some older Kotlin version. We may want to address it one day. - // For more info, see https://github.com/typesafegithub/github-workflows-kt/issues/1756 - phrase = "was compiled with an incompatible version of Kotlin", - )} - """.trimIndent(), - ) - runWithSpecificKotlinVersion( - kotlinVersion = oldestCompatibleVersion, - command = """ - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - """.trimIndent(), - ) - - run( - name = "Compile a Gradle project using the bindings from the server", - command = """ - cd .github/workflows/test-gradle-project-using-bindings-server - ./gradlew build - """.trimIndent(), - ) - - run( - name = "Fetch maven-metadata.xml for top-level action", - command = "curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep 'v4'", - ) - run( - name = "Fetch maven-metadata.xml for nested action", - command = "curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep 'v4'", - ) - } - - job( - id = "deploy", - name = "Deploy to DockerHub", - runsOn = UbuntuLatest, - `if` = expr { "${github.event_name} == 'workflow_dispatch' || ${github.event_name} == 'schedule'" }, - needs = listOf(endToEndTest), - env = mapOf( - "DOCKERHUB_USERNAME" to expr { DOCKERHUB_USERNAME }, - "DOCKERHUB_PASSWORD" to expr { DOCKERHUB_PASSWORD }, - ), - environment = Environment(name = "DockerHub"), - ) { - uses(action = Checkout()) - uses(action = ActionsSetupGradle()) - run( - name = "Build and publish image", - command = "./gradlew :jit-binding-server:publishImage", - ) - run( - name = "Use newest image on the server", - command = "curl -X POST ${expr { TRIGGER_IMAGE_PULL }} --insecure", - ) - } -} - -fun JobBuilder.cleanMavenLocal() { - run( - name = "Clean Maven Local to fetch required POMs again", - command = "rm -rf ~/.m2/repository/" - ) -} - -fun JobBuilder.runWithSpecificKotlinVersion(kotlinVersion: String, command: String) { - uses( - name = "Install Kotlin $kotlinVersion", - action = SetupKotlin( - version = kotlinVersion, - ), - ) - cleanMavenLocal() - run( - name = "Execute the script using the bindings from the server, using older Kotlin ($kotlinVersion) as consumer", - command = command, - ) -} - -fun failsWithPhraseInLogs( - command: String, - phrase: String, -): String = - """ - ($command || true) >> output.txt 2>&1 - grep "$phrase" output.txt - """.trimIndent() diff --git a/.github/workflows/bindings-server.yaml b/.github/workflows/bindings-server.yaml deleted file mode 100644 index 1593adcda..000000000 --- a/.github/workflows/bindings-server.yaml +++ /dev/null @@ -1,124 +0,0 @@ -# This file was generated using Kotlin DSL (.github/workflows/bindings-server.main.kts). -# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. -# Generated with https://github.com/typesafegithub/github-workflows-kt - -name: 'Bindings server' -on: - push: - branches: - - 'main' - pull_request: {} - schedule: - - cron: '0 0 * * SUN' - workflow_dispatch: {} -jobs: - check_yaml_consistency: - name: 'Check YAML consistency' - runs-on: 'ubuntu-latest' - steps: - - id: 'step-0' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Execute script' - run: 'rm ''.github/workflows/bindings-server.yaml'' && ''.github/workflows/bindings-server.main.kts''' - - id: 'step-2' - name: 'Consistency check' - run: 'git diff --exit-code ''.github/workflows/bindings-server.yaml''' - end-to-end-test: - name: 'End-to-end test' - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-2' - name: 'Start the server' - run: './gradlew :jit-binding-server:run &' - - id: 'step-3' - name: 'Wait for the server to respond' - env: - GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' - run: 'GHWKT_RUN_STEP=''end-to-end-test:step-3'' ''.github/workflows/bindings-server.main.kts''' - - id: 'step-4' - name: 'Clean Maven Local to fetch required POMs again' - run: 'rm -rf ~/.m2/repository/' - - id: 'step-5' - name: 'Execute the script using the bindings from the server' - run: |- - mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts - .github/workflows/test-script-consuming-jit-bindings.main.kts - - id: 'step-6' - name: 'Clean Maven Local to fetch required POMs again' - run: 'rm -rf ~/.m2/repository/' - - id: 'step-7' - name: 'Execute the script using bindings but without dependency on library' - run: |- - mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts - .github/workflows/test-served-bindings-depend-on-library.main.kts - - id: 'step-8' - name: 'Install Kotlin 1.9.0' - uses: 'fwilhe2/setup-kotlin@0.11.0' - with: - version: '1.9.0' - - id: 'step-9' - name: 'Clean Maven Local to fetch required POMs again' - run: 'rm -rf ~/.m2/repository/' - - id: 'step-10' - name: 'Execute the script using the bindings from the server, using older Kotlin (1.9.0) as consumer' - run: |2- - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts - (.github/workflows/test-script-consuming-jit-bindings-too-old-kotlin.main.kts || true) >> output.txt 2>&1 - grep "was compiled with an incompatible version of Kotlin" output.txt - - id: 'step-11' - name: 'Install Kotlin 2.0.0' - uses: 'fwilhe2/setup-kotlin@0.11.0' - with: - version: '2.0.0' - - id: 'step-12' - name: 'Clean Maven Local to fetch required POMs again' - run: 'rm -rf ~/.m2/repository/' - - id: 'step-13' - name: 'Execute the script using the bindings from the server, using older Kotlin (2.0.0) as consumer' - run: |- - cp .github/workflows/test-script-consuming-jit-bindings.main.kts .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - .github/workflows/test-script-consuming-jit-bindings-older-kotlin.main.kts - - id: 'step-14' - name: 'Compile a Gradle project using the bindings from the server' - run: |- - cd .github/workflows/test-gradle-project-using-bindings-server - ./gradlew build - - id: 'step-15' - name: 'Fetch maven-metadata.xml for top-level action' - run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''v4''' - - id: 'step-16' - name: 'Fetch maven-metadata.xml for nested action' - run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''v4''' - deploy: - name: 'Deploy to DockerHub' - runs-on: 'ubuntu-latest' - needs: - - 'end-to-end-test' - - 'check_yaml_consistency' - env: - DOCKERHUB_USERNAME: '${{ secrets.DOCKERHUB_USERNAME }}' - DOCKERHUB_PASSWORD: '${{ secrets.DOCKERHUB_PASSWORD }}' - if: '${{ github.event_name == ''workflow_dispatch'' || github.event_name == ''schedule'' }}' - environment: - name: 'DockerHub' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-2' - name: 'Build and publish image' - run: './gradlew :jit-binding-server:publishImage' - - id: 'step-3' - name: 'Use newest image on the server' - run: 'curl -X POST ${{ secrets.TRIGGER_IMAGE_PULL }} --insecure' diff --git a/.github/workflows/build.main.kts b/.github/workflows/build.main.kts deleted file mode 100755 index 81cb423fa..000000000 --- a/.github/workflows/build.main.kts +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:cache:v4") -@file:DependsOn("actions:checkout:v4") -@file:DependsOn("actions:setup-java:v4") -@file:DependsOn("gradle:actions__setup-gradle:v4") - -@file:Import("_shared.main.kts") -@file:Import("setup-java.main.kts") -@file:Import("setup-python.main.kts") - -import io.github.typesafegithub.workflows.actions.actions.Cache -import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.actions.SetupJava -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.RunnerType.Windows2022 -import io.github.typesafegithub.workflows.domain.triggers.PullRequest -import io.github.typesafegithub.workflows.domain.triggers.Push -import io.github.typesafegithub.workflows.dsl.expressions.Contexts -import io.github.typesafegithub.workflows.dsl.expressions.expr -import io.github.typesafegithub.workflows.dsl.workflow - -val GRADLE_ENCRYPTION_KEY by Contexts.secrets - -workflow( - name = "Build", - on = listOf( - Push(branches = listOf("main")), - PullRequest(), - ), - sourceFile = __FILE__, -) { - listOf(UbuntuLatest, Windows2022).forEach { runnerType -> - job( - id = "build-for-${runnerType::class.simpleName}", - runsOn = runnerType, - ) { - uses(action = Checkout()) - // Workaround for https://github.com/gradle/gradle/issues/21265 - uses(action = Cache( - path = listOf("buildSrc/build"), - key = "gradle-buildSrc-build-dir-" + expr { runner.os }, - )) - setupJava() - uses(action = ActionsSetupGradle( - cacheEncryptionKey = expr { GRADLE_ENCRYPTION_KEY }, - )) - run( - name = "Build", - command = "./gradlew build", - env = - mapOf( - "GITHUB_TOKEN" to expr("secrets.GITHUB_TOKEN"), - ), - ) - } - } - - job( - id = "publish-snapshot", - name = "Publish snapshot", - runsOn = UbuntuLatest, - condition = expr { "${github.ref} == 'refs/heads/main'" }, - env = mapOf( - "ORG_GRADLE_PROJECT_sonatypeUsername" to expr("secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME"), - "ORG_GRADLE_PROJECT_sonatypePassword" to expr("secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD"), - ), - ) { - uses(action = Checkout()) - setupJava() - uses(action = ActionsSetupGradle()) - val setIsSnapshotVersionFlag = run( - name = "Check if snapshot version is set", - command = "./gradlew setIsSnapshotFlagInGithubOutput", - ) - - libraries.forEach { library -> - run( - name = "Publish '$library' to Sonatype", - condition = expr("steps.${setIsSnapshotVersionFlag.id}.outputs.is-snapshot == 'true'"), - command = "./gradlew $library:publishToSonatype --no-configuration-cache", - ) - } - } - - job( - id = "build_docs", - name = "Build docs", - runsOn = UbuntuLatest, - ) { - uses(action = Checkout()) - setupPython() - run(command = "pip install -r docs/requirements.txt") - run(command = "mkdocs build --site-dir public") - } - - - 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 - # This script requires extra steps before it can be compiled, i.e. publishing - # the library to Maven Local. It's handled by the consistency check in this workflow. - if [ "${'$'}file" = "./.github/workflows/end-to-end-tests.main.kts" ]; then - continue - fi - - 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()) - uses( - name = "Set up Java in proper version", - action = SetupJava( - javaVersion = "17", - distribution = SetupJava.Distribution.Zulu, - cache = SetupJava.BuildPlatform.Gradle, - ), - ) - run(command = "cd .github/workflows") - run( - name = "Regenerate all workflow YAMLs", - command = """ - find -name "*.main.kts" -print0 | while read -d ${'$'}'\0' file - do - # This script requires extra steps before it can be compiled, i.e. publishing - # the library to Maven Local. It's handled by the consistency check in this workflow. - if [ "${'$'}file" = "./.github/workflows/end-to-end-tests.main.kts" ]; then - continue - fi - - 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 deleted file mode 100644 index 0ab807dc6..000000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,190 +0,0 @@ -# This file was generated using Kotlin DSL (.github/workflows/build.main.kts). -# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. -# Generated with https://github.com/typesafegithub/github-workflows-kt - -name: 'Build' -on: - push: - branches: - - 'main' - pull_request: {} -jobs: - check_yaml_consistency: - name: 'Check YAML consistency' - runs-on: 'ubuntu-latest' - steps: - - id: 'step-0' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Execute script' - run: 'rm ''.github/workflows/build.yaml'' && ''.github/workflows/build.main.kts''' - - id: 'step-2' - name: 'Consistency check' - run: 'git diff --exit-code ''.github/workflows/build.yaml''' - build-for-UbuntuLatest: - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - uses: 'actions/cache@v4' - with: - path: 'buildSrc/build' - key: 'gradle-buildSrc-build-dir-${{ runner.os }}' - - id: 'step-2' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-3' - uses: 'gradle/actions/setup-gradle@v4' - with: - cache-encryption-key: '${{ secrets.GRADLE_ENCRYPTION_KEY }}' - - id: 'step-4' - name: 'Build' - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - run: './gradlew build' - build-for-Windows2022: - runs-on: 'windows-2022' - needs: - - 'check_yaml_consistency' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - uses: 'actions/cache@v4' - with: - path: 'buildSrc/build' - key: 'gradle-buildSrc-build-dir-${{ runner.os }}' - - id: 'step-2' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-3' - uses: 'gradle/actions/setup-gradle@v4' - with: - cache-encryption-key: '${{ secrets.GRADLE_ENCRYPTION_KEY }}' - - id: 'step-4' - name: 'Build' - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - run: './gradlew build' - publish-snapshot: - name: 'Publish snapshot' - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - env: - ORG_GRADLE_PROJECT_sonatypeUsername: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }}' - ORG_GRADLE_PROJECT_sonatypePassword: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }}' - if: '${{ github.ref == ''refs/heads/main'' }}' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-2' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-3' - name: 'Check if snapshot version is set' - run: './gradlew setIsSnapshotFlagInGithubOutput' - - id: 'step-4' - name: 'Publish '':shared-internal'' to Sonatype' - run: './gradlew :shared-internal:publishToSonatype --no-configuration-cache' - if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}' - - id: 'step-5' - name: 'Publish '':github-workflows-kt'' to Sonatype' - run: './gradlew :github-workflows-kt:publishToSonatype --no-configuration-cache' - if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}' - - id: 'step-6' - name: 'Publish '':action-binding-generator'' to Sonatype' - run: './gradlew :action-binding-generator:publishToSonatype --no-configuration-cache' - if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}' - - id: 'step-7' - name: 'Publish '':action-updates-checker'' to Sonatype' - run: './gradlew :action-updates-checker:publishToSonatype --no-configuration-cache' - if: '${{ steps.step-3.outputs.is-snapshot == ''true'' }}' - build_docs: - name: 'Build docs' - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - uses: 'actions/setup-python@v5' - with: - python-version: '3.8' - - id: 'step-2' - run: 'pip install -r docs/requirements.txt' - - id: 'step-3' - run: 'mkdocs build --site-dir public' - 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 - # This script requires extra steps before it can be compiled, i.e. publishing - # the library to Maven Local. It's handled by the consistency check in this workflow. - if [ "$file" = "./.github/workflows/end-to-end-tests.main.kts" ]; then - continue - fi - - 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' - name: 'Set up Java in proper version' - uses: 'actions/setup-java@v4' - with: - java-version: '17' - distribution: 'zulu' - cache: 'gradle' - - id: 'step-2' - run: 'cd .github/workflows' - - id: 'step-3' - name: 'Regenerate all workflow YAMLs' - run: |- - find -name "*.main.kts" -print0 | while read -d $'\0' file - do - # This script requires extra steps before it can be compiled, i.e. publishing - # the library to Maven Local. It's handled by the consistency check in this workflow. - if [ "$file" = "./.github/workflows/end-to-end-tests.main.kts" ]; then - continue - fi - - if [ -x "$file" ]; then - echo "Regenerating $file..." - ($file) - fi - done - - id: 'step-4' - name: 'Check if some file is different after regeneration' - run: 'git diff --exit-code .' diff --git a/.github/workflows/end-to-end-tests.main.kts b/.github/workflows/end-to-end-tests.main.kts deleted file mode 100755 index 98618433a..000000000 --- a/.github/workflows/end-to-end-tests.main.kts +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("file://~/.m2/repository/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.3-SNAPSHOT") -@file:DependsOn("io.github.typesafegithub:action-updates-checker:3.0.3-SNAPSHOT") -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:checkout:v4") -@file:DependsOn("actions:github-script:v7") -@file:DependsOn("actions:setup-java:v4") -@file:DependsOn("actions:setup-python:v5") -@file:DependsOn("gradle:actions__setup-gradle:v4") -@file:DependsOn("Wandalen:wretry.action:v3") -@file:OptIn(ExperimentalKotlinLogicStep::class) - -import io.github.typesafegithub.workflows.actions.actions.* -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.actions.wandalen.WretryAction -import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicStep -import io.github.typesafegithub.workflows.domain.JobOutputs -import io.github.typesafegithub.workflows.domain.Mode -import io.github.typesafegithub.workflows.domain.Permission -import io.github.typesafegithub.workflows.domain.RunnerType -import io.github.typesafegithub.workflows.domain.actions.* -import io.github.typesafegithub.workflows.domain.triggers.PullRequest -import io.github.typesafegithub.workflows.domain.triggers.Push -import io.github.typesafegithub.workflows.dsl.JobBuilder -import io.github.typesafegithub.workflows.dsl.expressions.Contexts -import io.github.typesafegithub.workflows.dsl.expressions.expr -import io.github.typesafegithub.workflows.dsl.workflow -import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG -import io.github.typesafegithub.workflows.updates.reportAvailableUpdates -import java.time.Instant - -fun JobBuilder<*>.publishToMavenLocal() { - uses( - name = "Set up JDK", - action = SetupJava( - javaVersion = "11", - distribution = SetupJava.Distribution.Zulu, - ), - ) - uses(action = ActionsSetupGradle()) - run( - name = "Publish to Maven local", - command = "./gradlew publishToMavenLocal", - ) -} - -workflow( - name = "End-to-end tests", - on = listOf( - Push(branches = listOf("main")), - PullRequest(), - ), - consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy( - env = mapOf( - "GITHUB_TOKEN" to expr("secrets.GITHUB_TOKEN") - ), - additionalSteps = { - publishToMavenLocal() - }, - ), - useWorkflow = { it.reportAvailableUpdates() }, - sourceFile = __FILE__, -) { - val GREETING by Contexts.env - val FIRST_NAME by Contexts.env - val SECRET by Contexts.env - val TOKEN by Contexts.env - val SUPER_SECRET by Contexts.secrets - - val testJob1 = - job( - id = "test_job_1", - runsOn = RunnerType.UbuntuLatest, - env = mapOf( - GREETING to "World", - ), - permissions = mapOf( - Permission.Actions to Mode.Read, - Permission.Checks to Mode.Write, - Permission.Contents to Mode.None, - ), - outputs = object : JobOutputs() { - var scriptKey by output() - var scriptKey2 by output() - var scriptResult by output() - }, - ) { - run( - name = "Hello world!", - command = "echo 'hello!'", - ) - - run( - name = "Hello world! Multiline command with pipes", - command = """ - less test.txt \ - | grep -P "foobar" \ - | sort \ - > result.txt - """.trimIndent(), - ) - - uses( - name = "Check out", - action = CustomAction( - actionOwner = "actions", - actionName = "checkout", - actionVersion = "v4", - ), - ) - - uses( - name = "Run local action", - action = CustomLocalAction( - actionPath = "./.github/workflows/test-local-action", - inputs = mapOf( - "name" to "Rocky", - ), - ), - ) - - uses( - name = "Run alpine", - action = CustomDockerAction( - actionImage = "alpine", - actionTag = "latest", - ), - ) - - uses( - name = "Check out again", - action = object : RegularAction( - actionOwner = "actions", - actionName = "checkout", - actionVersion = "v4", - ) { - override fun toYamlArguments() = - linkedMapOf( - "repository" to "actions/checkout", - "ref" to "v3", - "path" to "./.github/actions/checkout", - "clean" to "false", - ) - - override fun buildOutputObject(stepId: String) = Action.Outputs(stepId) - }, - ) - - uses( - name = "Run local action", - action = object : LocalAction( - actionPath = "./.github/workflows/test-local-action", - ) { - override fun toYamlArguments() = - linkedMapOf( - "name" to "Balboa", - ) - - override fun buildOutputObject(stepId: String) = Action.Outputs(stepId) - }, - ) - - uses( - name = "Run alpine", - action = object : DockerAction( - actionImage = "alpine", - actionTag = "latest", - ) { - override fun toYamlArguments() = linkedMapOf() - - override fun buildOutputObject(stepId: String) = Action.Outputs(stepId) - }, - ) - - val addAndCommit = uses(action = SetupPython()) - - uses( - name = "Some step consuming other step's output", - action = Checkout( - sshKey = expr(addAndCommit.outputs.pythonVersion), - path = expr(addAndCommit.outputs["my-unsafe-output"]), - ), - ) - - run( - name = "Custom environment variable", - env = mapOf( - FIRST_NAME to "Patrick", - ), - command = "echo $GREETING $FIRST_NAME", - ) - run( - name = "Encrypted secret", - env = mapOf( - SECRET to expr { SUPER_SECRET }, - TOKEN to expr { secrets.GITHUB_TOKEN }, - ), - command = "echo secret=$SECRET token=$TOKEN", - ) - run( - name = "RunnerContext create temp directory", - command = "mkdir " + expr { runner.temp } + "/build_logs", - ) - run( - name = "GitHubContext echo sha", - command = "echo " + expr { github.sha } + " ev " + expr { github.eventRelease.release.url }, - ) - run( - name = "Default environment variable", - command = "action=${Contexts.env.GITHUB_ACTION} repo=${Contexts.env.GITHUB_REPOSITORY}", - condition = expr { always() }, - ) - - publishToMavenLocal() - - run( - name = "Step with a Kotlin-based logic", - ifKotlin = { Instant.now() > Instant.parse("2022-03-04T12:34:56.00Z") }, - ) { - println("Hello from Kotlin! Now it's ${Instant.now()}") - println("Running for commit ${github.sha}, branch ${github.ref}") - } - - val scriptStep = - uses( - action = GithubScript( - script = """ - core.setOutput("key", "value") - core.setOutput("key2", "value2") - return "return" - """.trimIndent(), - ), - ) - jobOutputs.scriptKey = scriptStep.outputs["key"] - jobOutputs.scriptKey2 = scriptStep.outputs["key2"] - jobOutputs.scriptResult = scriptStep.outputs.result - } - - job( - id = "test_job_2", - runsOn = RunnerType.UbuntuLatest, - condition = "\${{ always() }}", - needs = listOf(testJob1), - ) { - run( - name = "Hello world, again!", - command = "echo 'hello again!'", - ) - run( - name = "use output of script", - command = """ - echo ${expr { testJob1.outputs.scriptKey }} - echo ${expr { testJob1.outputs.scriptKey2 }} - echo ${expr { testJob1.outputs.scriptResult }} - """.trimIndent(), - ) - - val setupJava11And20 = SetupJava( - javaVersion = """ - 11 - 20 - """.trimIndent(), - distribution = SetupJava.Distribution.Temurin, - ) - - uses( - name = "Setup Java 11 and 20", - action = WretryAction( - action = setupJava11And20.usesString, - with = setupJava11And20.yamlArgumentsString, - ) - ) - } -} diff --git a/.github/workflows/end-to-end-tests.yaml b/.github/workflows/end-to-end-tests.yaml deleted file mode 100644 index cd27fb4fd..000000000 --- a/.github/workflows/end-to-end-tests.yaml +++ /dev/null @@ -1,173 +0,0 @@ -# This file was generated using Kotlin DSL (.github/workflows/end-to-end-tests.main.kts). -# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. -# Generated with https://github.com/typesafegithub/github-workflows-kt - -name: 'End-to-end tests' -on: - push: - branches: - - 'main' - pull_request: {} -jobs: - check_yaml_consistency: - name: 'Check YAML consistency' - runs-on: 'ubuntu-latest' - env: - GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - steps: - - id: 'step-0' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-2' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-3' - name: 'Publish to Maven local' - run: './gradlew publishToMavenLocal' - - id: 'step-4' - name: 'Execute script' - run: 'rm ''.github/workflows/end-to-end-tests.yaml'' && ''.github/workflows/end-to-end-tests.main.kts''' - - id: 'step-5' - name: 'Consistency check' - run: 'git diff --exit-code ''.github/workflows/end-to-end-tests.yaml''' - test_job_1: - runs-on: 'ubuntu-latest' - permissions: - actions: 'read' - checks: 'write' - contents: 'none' - needs: - - 'check_yaml_consistency' - env: - $GREETING: 'World' - outputs: - scriptKey: '${{ steps.step-20.outputs.key }}' - scriptKey2: '${{ steps.step-20.outputs.key2 }}' - scriptResult: '${{ steps.step-20.outputs.result }}' - steps: - - id: 'step-0' - name: 'Hello world!' - run: 'echo ''hello!''' - - id: 'step-1' - name: 'Hello world! Multiline command with pipes' - run: |- - less test.txt \ - | grep -P "foobar" \ - | sort \ - > result.txt - - id: 'step-2' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-3' - name: 'Run local action' - uses: './.github/workflows/test-local-action' - with: - name: 'Rocky' - - id: 'step-4' - name: 'Run alpine' - uses: 'docker://alpine:latest' - - id: 'step-5' - name: 'Check out again' - uses: 'actions/checkout@v4' - with: - repository: 'actions/checkout' - ref: 'v3' - path: './.github/actions/checkout' - clean: 'false' - - id: 'step-6' - name: 'Run local action' - uses: './.github/workflows/test-local-action' - with: - name: 'Balboa' - - id: 'step-7' - name: 'Run alpine' - uses: 'docker://alpine:latest' - - id: 'step-8' - uses: 'actions/setup-python@v5' - - id: 'step-9' - name: 'Some step consuming other step''s output' - uses: 'actions/checkout@v4' - with: - ssh-key: '${{ steps.step-8.outputs.python-version }}' - path: '${{ steps.step-8.outputs.my-unsafe-output }}' - - id: 'step-10' - name: 'Custom environment variable' - env: - $FIRST_NAME: 'Patrick' - run: 'echo $GREETING $FIRST_NAME' - - id: 'step-11' - name: 'Encrypted secret' - env: - $SECRET: '${{ secrets.SUPER_SECRET }}' - $TOKEN: '${{ secrets.GITHUB_TOKEN }}' - run: 'echo secret=$SECRET token=$TOKEN' - - id: 'step-12' - name: 'RunnerContext create temp directory' - run: 'mkdir ${{ runner.temp }}/build_logs' - - id: 'step-13' - name: 'GitHubContext echo sha' - run: 'echo ${{ github.sha }} ev ${{ github.event.release.url }}' - - id: 'step-14' - name: 'Default environment variable' - run: 'action=$GITHUB_ACTION repo=$GITHUB_REPOSITORY' - if: '${{ always() }}' - - id: 'step-15' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-16' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-17' - name: 'Publish to Maven local' - run: './gradlew publishToMavenLocal' - - id: 'step-18' - name: 'Evaluating condition for ''Step with a Kotlin-based logic''' - env: - GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' - run: 'GHWKT_RUN_STEP=''test_job_1:step-18'' ''.github/workflows/end-to-end-tests.main.kts''' - - id: 'step-19' - name: 'Step with a Kotlin-based logic' - env: - GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}' - run: 'GHWKT_RUN_STEP=''test_job_1:step-19'' ''.github/workflows/end-to-end-tests.main.kts''' - if: '${{ steps.step-18.outputs.evaluation-result }}' - - id: 'step-20' - uses: 'actions/github-script@v7' - with: - script: |- - core.setOutput("key", "value") - core.setOutput("key2", "value2") - return "return" - test_job_2: - runs-on: 'ubuntu-latest' - needs: - - 'test_job_1' - - 'check_yaml_consistency' - if: '${{ always() }}' - steps: - - id: 'step-0' - name: 'Hello world, again!' - run: 'echo ''hello again!''' - - id: 'step-1' - name: 'use output of script' - run: |- - echo ${{ needs.test_job_1.outputs.scriptKey }} - echo ${{ needs.test_job_1.outputs.scriptKey2 }} - echo ${{ needs.test_job_1.outputs.scriptResult }} - - id: 'step-2' - name: 'Setup Java 11 and 20' - uses: 'Wandalen/wretry.action@v3' - with: - action: 'actions/setup-java@v4' - with: | - java-version: |- - 11 - 20 - distribution: 'temurin' diff --git a/.github/workflows/gradle-wrapper-validation.yaml b/.github/workflows/gradle-wrapper-validation.yaml deleted file mode 100644 index 99567ab44..000000000 --- a/.github/workflows/gradle-wrapper-validation.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# This file was generated using Kotlin DSL (.github/workflows/gradle-wrapper-validation.main.kts). -# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. -# Generated with https://github.com/typesafegithub/github-workflows-kt - -name: 'Validate Gradle wrapper' -on: - push: - branches: - - 'main' - paths: - - 'gradle/wrapper/gradle-wrapper.jar' - pull_request: - paths: - - 'gradle/wrapper/gradle-wrapper.jar' -jobs: - check_yaml_consistency: - name: 'Check YAML consistency' - runs-on: 'ubuntu-latest' - steps: - - id: 'step-0' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Execute script' - run: 'rm ''.github/workflows/gradle-wrapper-validation.yaml'' && ''.github/workflows/gradle-wrapper-validation.main.kts''' - - id: 'step-2' - name: 'Consistency check' - run: 'git diff --exit-code ''.github/workflows/gradle-wrapper-validation.yaml''' - validation: - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Validate wrapper' - uses: 'gradle/wrapper-validation-action@v3' diff --git a/.github/workflows/release.main.kts b/.github/workflows/release.main.kts deleted file mode 100755 index 048b9fcff..000000000 --- a/.github/workflows/release.main.kts +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:checkout:v4") -@file:DependsOn("gradle:actions__setup-gradle:v4") -@file:DependsOn("JamesIves:github-pages-deploy-action:v4") - -@file:Import("_shared.main.kts") -@file:Import("setup-java.main.kts") -@file:Import("setup-python.main.kts") - -import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.actions.jamesives.GithubPagesDeployAction -import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest -import io.github.typesafegithub.workflows.domain.triggers.Push -import io.github.typesafegithub.workflows.dsl.JobBuilder -import io.github.typesafegithub.workflows.dsl.expressions.expr -import io.github.typesafegithub.workflows.dsl.workflow - -workflow( - name = "Release", - on = listOf(Push(tags = listOf("v*.*.*"))), - sourceFile = __FILE__, - env = mapOf( - "SIGNING_KEY" to expr("secrets.SIGNING_KEY"), - "SIGNING_PASSWORD" to expr("secrets.SIGNING_PASSWORD"), - "ORG_GRADLE_PROJECT_sonatypeUsername" to expr("secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME"), - "ORG_GRADLE_PROJECT_sonatypePassword" to expr("secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD"), - ), -) { - job( - id = "release", - runsOn = UbuntuLatest, - ) { - uses(action = Checkout()) - setupJava() - uses(action = ActionsSetupGradle()) - run( - name = "Build", - command = "./gradlew build", - ) - - setupPython() - - // From here, there are steps performing deployments. Before, it's only about building and testing. - - libraries.forEach { library -> - run( - name = "Publish '$library' to Sonatype", - command = "./gradlew $library:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache", - ) - } - - libraries.forEach { library -> - run( - name = "Wait until '$library' present in Maven Central", - command = "./gradlew $library:waitUntilLibraryPresentInMavenCentral", - ) - } - - deployDocs() - } -} - -private fun JobBuilder<*>.deployDocs() { - run(command = "pip install -r docs/requirements.txt") - - val directoryToDeploy = "to-gh-pages" - run( - name = "Build Mkdocs docs", - command = "mkdocs build --site-dir $directoryToDeploy", - ) - uses(action = ActionsSetupGradle()) - run( - name = "Generate API docs", - command = "./gradlew :github-workflows-kt:dokkaHtml --no-configuration-cache", - ) - run( - name = "Prepare target directory for API docs", - command = "mkdir -p $directoryToDeploy/api-docs", - ) - run( - name = "Copy Dokka output to Mkdocs output", - command = "cp -r github-workflows-kt/build/dokka/html/* $directoryToDeploy/api-docs", - ) - run( - name = "Copy teaser image", - command = "cp images/teaser-with-newest-version.svg $directoryToDeploy" - ) - uses( - name = "Deploy merged docs to GitHub Pages", - action = GithubPagesDeployAction( - folder = "$directoryToDeploy", - ), - ) -} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index d4f950035..000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,98 +0,0 @@ -# This file was generated using Kotlin DSL (.github/workflows/release.main.kts). -# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. -# Generated with https://github.com/typesafegithub/github-workflows-kt - -name: 'Release' -on: - push: - tags: - - 'v*.*.*' -env: - SIGNING_KEY: '${{ secrets.SIGNING_KEY }}' - SIGNING_PASSWORD: '${{ secrets.SIGNING_PASSWORD }}' - ORG_GRADLE_PROJECT_sonatypeUsername: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }}' - ORG_GRADLE_PROJECT_sonatypePassword: '${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }}' -jobs: - check_yaml_consistency: - name: 'Check YAML consistency' - runs-on: 'ubuntu-latest' - steps: - - id: 'step-0' - name: 'Check out' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Execute script' - run: 'rm ''.github/workflows/release.yaml'' && ''.github/workflows/release.main.kts''' - - id: 'step-2' - name: 'Consistency check' - run: 'git diff --exit-code ''.github/workflows/release.yaml''' - release: - runs-on: 'ubuntu-latest' - needs: - - 'check_yaml_consistency' - steps: - - id: 'step-0' - uses: 'actions/checkout@v4' - - id: 'step-1' - name: 'Set up JDK' - uses: 'actions/setup-java@v4' - with: - java-version: '11' - distribution: 'zulu' - - id: 'step-2' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-3' - name: 'Build' - run: './gradlew build' - - id: 'step-4' - uses: 'actions/setup-python@v5' - with: - python-version: '3.8' - - id: 'step-5' - name: 'Publish '':shared-internal'' to Sonatype' - run: './gradlew :shared-internal:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache' - - id: 'step-6' - name: 'Publish '':github-workflows-kt'' to Sonatype' - run: './gradlew :github-workflows-kt:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache' - - id: 'step-7' - name: 'Publish '':action-binding-generator'' to Sonatype' - run: './gradlew :action-binding-generator:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache' - - id: 'step-8' - name: 'Publish '':action-updates-checker'' to Sonatype' - run: './gradlew :action-updates-checker:publishToSonatype closeAndReleaseSonatypeStagingRepository --no-configuration-cache' - - id: 'step-9' - name: 'Wait until '':shared-internal'' present in Maven Central' - run: './gradlew :shared-internal:waitUntilLibraryPresentInMavenCentral' - - id: 'step-10' - name: 'Wait until '':github-workflows-kt'' present in Maven Central' - run: './gradlew :github-workflows-kt:waitUntilLibraryPresentInMavenCentral' - - id: 'step-11' - name: 'Wait until '':action-binding-generator'' present in Maven Central' - run: './gradlew :action-binding-generator:waitUntilLibraryPresentInMavenCentral' - - id: 'step-12' - name: 'Wait until '':action-updates-checker'' present in Maven Central' - run: './gradlew :action-updates-checker:waitUntilLibraryPresentInMavenCentral' - - id: 'step-13' - run: 'pip install -r docs/requirements.txt' - - id: 'step-14' - name: 'Build Mkdocs docs' - run: 'mkdocs build --site-dir to-gh-pages' - - id: 'step-15' - uses: 'gradle/actions/setup-gradle@v4' - - id: 'step-16' - name: 'Generate API docs' - run: './gradlew :github-workflows-kt:dokkaHtml --no-configuration-cache' - - id: 'step-17' - name: 'Prepare target directory for API docs' - run: 'mkdir -p to-gh-pages/api-docs' - - id: 'step-18' - name: 'Copy Dokka output to Mkdocs output' - run: 'cp -r github-workflows-kt/build/dokka/html/* to-gh-pages/api-docs' - - id: 'step-19' - name: 'Copy teaser image' - run: 'cp images/teaser-with-newest-version.svg to-gh-pages' - - id: 'step-20' - name: 'Deploy merged docs to GitHub Pages' - uses: 'JamesIves/github-pages-deploy-action@v4' - with: - folder: 'to-gh-pages' diff --git a/.github/workflows/setup-java.main.kts b/.github/workflows/setup-java.main.kts deleted file mode 100644 index 0334a3473..000000000 --- a/.github/workflows/setup-java.main.kts +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:setup-java:v4") - -import io.github.typesafegithub.workflows.actions.actions.SetupJava -import io.github.typesafegithub.workflows.dsl.JobBuilder - -fun JobBuilder<*>.setupJava() = - uses( - name = "Set up JDK", - action = SetupJava( - javaVersion = "11", - distribution = SetupJava.Distribution.Zulu, - ) - ) diff --git a/.github/workflows/setup-python.main.kts b/.github/workflows/setup-python.main.kts deleted file mode 100644 index 34d319247..000000000 --- a/.github/workflows/setup-python.main.kts +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") - -@file:Repository("https://bindings.krzeminski.it") -@file:DependsOn("actions:setup-python:v5") - -import io.github.typesafegithub.workflows.actions.actions.SetupPython -import io.github.typesafegithub.workflows.dsl.JobBuilder - -fun JobBuilder<*>.setupPython() = - uses(action = SetupPython(pythonVersion = "3.8")) diff --git a/.github/workflows/test-gradle-project-using-bindings-server/build.gradle.kts b/.github/workflows/test-gradle-project-using-bindings-server/build.gradle.kts deleted file mode 100644 index 6c652ad26..000000000 --- a/.github/workflows/test-gradle-project-using-bindings-server/build.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -import java.net.URI - -plugins { - kotlin("jvm") version "2.1.0" -} - -repositories { - mavenCentral() - maven { - url = URI("http://localhost:8080/") - isAllowInsecureProtocol = true - } -} - -dependencies { - // Regular, top-level action. - implementation("actions:checkout:v4") - - // Nested action. - implementation("gradle:actions__setup-gradle:v3") - - // Using specific version. - implementation("actions:cache:v3.3.3") - - // Always untyped action. - implementation("typesafegithub:always-untyped-action-for-tests:v1") -} diff --git a/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.jar b/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a4b76b953..000000000 Binary files a/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.properties b/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e1b837a19..000000000 --- a/.github/workflows/test-gradle-project-using-bindings-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,8 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/.github/workflows/test-gradle-project-using-bindings-server/gradlew b/.github/workflows/test-gradle-project-using-bindings-server/gradlew deleted file mode 100755 index f3b75f3b0..000000000 --- a/.github/workflows/test-gradle-project-using-bindings-server/gradlew +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/.github/workflows/test-gradle-project-using-bindings-server/settings.gradle.kts b/.github/workflows/test-gradle-project-using-bindings-server/settings.gradle.kts deleted file mode 100644 index 2d08d7249..000000000 --- a/.github/workflows/test-gradle-project-using-bindings-server/settings.gradle.kts +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "test-gradle-project-using-bindings-server" - diff --git a/.github/workflows/test-gradle-project-using-bindings-server/src/main/kotlin/Main.kt b/.github/workflows/test-gradle-project-using-bindings-server/src/main/kotlin/Main.kt deleted file mode 100644 index 8457a4dff..000000000 --- a/.github/workflows/test-gradle-project-using-bindings-server/src/main/kotlin/Main.kt +++ /dev/null @@ -1,14 +0,0 @@ -import io.github.typesafegithub.workflows.actions.actions.Cache -import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.actions.Checkout_Untyped -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.actions.typesafegithub.AlwaysUntypedActionForTests_Untyped - -fun main() { - println(Checkout_Untyped(fetchTags_Untyped = "false")) - println(Checkout(fetchTags = false)) - println(Checkout(fetchTags_Untyped = "false")) - println(AlwaysUntypedActionForTests_Untyped(foobar_Untyped = "baz")) - println(ActionsSetupGradle()) - println(Cache(path = listOf("some-path"), key = "some-key")) -} diff --git a/.github/workflows/test-local-action/action.yml b/.github/workflows/test-local-action/action.yml deleted file mode 100644 index 3e3cd0ef4..000000000 --- a/.github/workflows/test-local-action/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Test local action -description: I'm a simple local action used in integration tests! -inputs: - name: - description: Name to be used in the greeting. - required: true -runs: - using: "composite" - steps: - - name: Print greeting - shell: bash - run: echo 'Hello ${{ inputs.name }}!' diff --git a/.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts b/.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts deleted file mode 100755 index 92fe96947..000000000 --- a/.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.13.0") - -@file:Repository("http://localhost:8080") - -// Regular, top-level action. -@file:DependsOn("actions:checkout:v4") - -// Nested action. -@file:DependsOn("gradle:actions__setup-gradle:v3") - -// Using specific version. -@file:DependsOn("actions:cache:v3.3.3") - -// Always untyped action. -@file:DependsOn("typesafegithub:always-untyped-action-for-tests:v1") - -import io.github.typesafegithub.workflows.actions.actions.Cache -import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.actions.Checkout_Untyped -import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle -import io.github.typesafegithub.workflows.actions.typesafegithub.AlwaysUntypedActionForTests_Untyped - -println(Checkout_Untyped(fetchTags_Untyped = "false")) -println(Checkout(fetchTags = false)) -println(Checkout(fetchTags_Untyped = "false")) -println(AlwaysUntypedActionForTests_Untyped(foobar_Untyped = "baz")) -println(ActionsSetupGradle()) -println(Cache(path = listOf("some-path"), key = "some-key")) - -// Ensure that 'copy(...)' method is exposed. -Checkout(fetchTags = false).copy(fetchTags = true) diff --git a/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts b/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts deleted file mode 100755 index 4161a79d2..000000000 --- a/.github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env kotlin -@file:Repository("https://repo.maven.apache.org/maven2/") -@file:Repository("http://localhost:8080") -@file:DependsOn("actions:checkout:v4") - -import io.github.typesafegithub.workflows.actions.actions.Checkout - -Checkout() diff --git a/.github/workflows/gradle-wrapper-validation.main.kts b/.github/workflows/test-workflow.main.kts similarity index 53% rename from .github/workflows/gradle-wrapper-validation.main.kts rename to .github/workflows/test-workflow.main.kts index 130f6b3b3..bc0478eae 100755 --- a/.github/workflows/gradle-wrapper-validation.main.kts +++ b/.github/workflows/test-workflow.main.kts @@ -2,38 +2,29 @@ @file:Repository("https://repo.maven.apache.org/maven2/") @file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.2") -@file:Repository("https://bindings.krzeminski.it") +@file:Repository("https://bindings.krzeminski.itt") @file:DependsOn("actions:checkout:v4") -@file:DependsOn("gradle:wrapper-validation-action:v3") import io.github.typesafegithub.workflows.actions.actions.Checkout -import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationAction import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push import io.github.typesafegithub.workflows.dsl.workflow workflow( - name = "Validate Gradle wrapper", + name = "Test workflow", on = listOf( - Push( - branches = listOf("main"), - paths = listOf("gradle/wrapper/gradle-wrapper.jar"), - ), - PullRequest( - paths = listOf("gradle/wrapper/gradle-wrapper.jar"), - ), + Push(branches = listOf("main")), + PullRequest(), ), sourceFile = __FILE__, ) { job( - id = "validation", + id = "test_job", + name = "Test job", runsOn = UbuntuLatest, ) { uses(action = Checkout()) - uses( - name = "Validate wrapper", - action = WrapperValidationAction(), - ) + run(command = "echo 'Hello world!'") } } diff --git a/.github/workflows/test-workflow.yaml b/.github/workflows/test-workflow.yaml new file mode 100644 index 000000000..2918db951 --- /dev/null +++ b/.github/workflows/test-workflow.yaml @@ -0,0 +1,47 @@ +# This file was generated using Kotlin DSL (.github/workflows/test-workflow.main.kts). +# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file. +# Generated with https://github.com/typesafegithub/github-workflows-kt + +name: 'Test workflow' +on: + push: + branches: + - 'main' + pull_request: {} +jobs: + check_yaml_consistency: + name: 'Check YAML consistency' + runs-on: 'ubuntu-latest' + steps: + - id: 'step-0' + name: 'Check out' + uses: 'actions/checkout@v4' + - id: 'step-1' + name: 'Execute script' + run: 'rm ''.github/workflows/test-workflow.yaml'' && ''.github/workflows/test-workflow.main.kts''' + continue-on-error: true + - id: 'start-server' + if: ${{ steps.step-1.outcome != 'success' }} + run: 'docker run -p 8080:8080 krzema12/github-workflows-kt-jit-binding-server &' + - id: 'wait-for-server' + if: ${{ steps.step-1.outcome != 'success' }} + run: 'curl --head -X GET --retry 60 --retry-all-errors --retry-delay 1 http://localhost:8080/status' + - id: 'replace-server-url-in-script' + if: ${{ steps.step-1.outcome != 'success' }} + run: sed -i -e 's/https:\/\/bindings.krzeminski.itt/http:\/\/localhost:8080/g' .github/workflows/test-workflow.main.kts + - id: 'execute-script-again' + if: ${{ steps.step-1.outcome != 'success' }} + run: 'rm -f ''.github/workflows/test-workflow.yaml'' && ''.github/workflows/test-workflow.main.kts''' + - id: 'step-2' + name: 'Consistency check' + run: 'git diff --exit-code ''.github/workflows/test-workflow.yaml''' + test_job: + name: 'Test job' + runs-on: 'ubuntu-latest' + needs: + - 'check_yaml_consistency' + steps: + - id: 'step-0' + uses: 'actions/checkout@v4' + - id: 'step-1' + run: 'echo ''Hello world!'''