Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/actions/install-pinned-kotlin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Install pinned Kotlin
description: >
Installs a pinned Kotlin version and prepends it to the PATH.
Kotlin 2.3.20 and newer cannot execute the workflow scripts with the `kotlin` CLI,
because resolving extension functions from imported scripts is broken there,
see https://youtrack.jetbrains.com/issue/KT-86352.
As the GitHub runner images ship an affected version, this action puts an
unaffected version on the PATH before any workflow script is executed on a runner.

runs:
using: "composite"
steps:
- name: 'Install Kotlin 2.3.10 (work-around for KT-86352)'
run: |
curl --fail --silent --show-error --location --output "$RUNNER_TEMP/kotlin-compiler.zip" "https://github.com/JetBrains/kotlin/releases/download/v2.3.10/kotlin-compiler-2.3.10.zip"
echo "c8d546f9ff433b529fb0ad43feceb39831040cae2ca8d17e7df46364368c9a9e $RUNNER_TEMP/kotlin-compiler.zip" | sha256sum --check
unzip -q "$RUNNER_TEMP/kotlin-compiler.zip" -d "$RUNNER_TEMP/pinned-kotlin"
echo "$RUNNER_TEMP/pinned-kotlin/kotlinc/bin" >> "$GITHUB_PATH"
shell: bash
7 changes: 2 additions & 5 deletions .github/workflows/branches-and-prs.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource.InferFromClasspath
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG

workflow(
name = "Verify Branches and PRs",
Expand All @@ -61,9 +59,7 @@ workflow(
group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}",
cancelInProgress = true
),
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = InferFromClasspath()
)
consistencyCheckJobConfig = commonConsistencyCheckJobConfig
) {
job(
id = "check_all_workflow_yaml_consistency",
Expand All @@ -74,6 +70,7 @@ workflow(
name = "Checkout Repository",
action = Checkout()
)
installPinnedKotlin()
run(
name = "Regenerate all Workflow YAMLs",
command = """find .github/workflows -mindepth 1 -maxdepth 1 -name '*.main.kts' -exec {} \;"""
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/branches-and-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ jobs:
name: 'Check out'
uses: 'actions/checkout@v6'
- id: 'step-1'
name: 'Install pinned Kotlin (work-around for KT-86352)'
uses: './.github/actions/install-pinned-kotlin'
- id: 'step-2'
name: 'Execute script'
run: 'rm ''.github/workflows/branches-and-prs.yaml'' && ''.github/workflows/branches-and-prs.main.kts'''
- id: 'step-2'
- id: 'step-3'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/branches-and-prs.yaml'''
check_all_workflow_yaml_consistency:
Expand All @@ -37,9 +40,12 @@ jobs:
name: 'Checkout Repository'
uses: 'actions/checkout@v6'
- id: 'step-1'
name: 'Install pinned Kotlin (work-around for KT-86352)'
uses: './.github/actions/install-pinned-kotlin'
- id: 'step-2'
name: 'Regenerate all Workflow YAMLs'
run: 'find .github/workflows -mindepth 1 -maxdepth 1 -name ''*.main.kts'' -exec {} \;'
- id: 'step-2'
- id: 'step-3'
name: 'Check for Modifications'
run: |-
git add --intent-to-add .
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/codeql-analysis.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import io.github.typesafegithub.workflows.domain.triggers.*
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource.InferFromClasspath
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG

workflow(
name = "Code scanning - action",
Expand All @@ -63,9 +61,7 @@ workflow(
group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}",
cancelInProgress = true
),
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = InferFromClasspath()
)
consistencyCheckJobConfig = commonConsistencyCheckJobConfig
) {
job(
id = "codeql-build",
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ jobs:
name: 'Check out'
uses: 'actions/checkout@v6'
- id: 'step-1'
name: 'Install pinned Kotlin (work-around for KT-86352)'
uses: './.github/actions/install-pinned-kotlin'
- id: 'step-2'
name: 'Execute script'
run: 'rm ''.github/workflows/codeql-analysis.yaml'' && ''.github/workflows/codeql-analysis.main.kts'''
- id: 'step-2'
- id: 'step-3'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/codeql-analysis.yaml'''
codeql-build:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/common.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import io.github.typesafegithub.workflows.dsl.JobBuilder
import io.github.typesafegithub.workflows.dsl.WorkflowBuilder
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource.InferFromClasspath
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG
import java.util.Properties

val GRADLE_ENTERPRISE_ACCESS_KEY by secrets
Expand All @@ -36,6 +38,26 @@ val commonCredentials = mapOf(
"DEVELOCITY_ACCESS_KEY" to expr(GRADLE_ENTERPRISE_ACCESS_KEY)
)

// Work-around for https://youtrack.jetbrains.com/issue/KT-86352,
// see the action definition for details.
object InstallPinnedKotlin : LocalAction<Outputs>("./.github/actions/install-pinned-kotlin") {
override fun toYamlArguments() = linkedMapOf<String, String>()

override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)
}

fun JobBuilder<*>.installPinnedKotlin() {
uses(
name = "Install pinned Kotlin (work-around for KT-86352)",
action = InstallPinnedKotlin
)
}

val commonConsistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = InferFromClasspath(),
additionalSteps = { installPinnedKotlin() }
)

data class Strategy(
val failFast: Boolean? = false,
val matrix: Matrix? = null
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/docs-pr.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource.InferFromClasspath
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG

workflow(
name = "Verify Docs",
Expand All @@ -58,9 +56,7 @@ workflow(
group = "${expr { github.workflow }}-${expr("${github.eventPullRequest.pull_request.number} || ${github.ref}")}",
cancelInProgress = true
),
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = InferFromClasspath()
)
consistencyCheckJobConfig = commonConsistencyCheckJobConfig
) {
job(
id = "docs-and-javadoc",
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docs-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ jobs:
name: 'Check out'
uses: 'actions/checkout@v6'
- id: 'step-1'
name: 'Install pinned Kotlin (work-around for KT-86352)'
uses: './.github/actions/install-pinned-kotlin'
- id: 'step-2'
name: 'Execute script'
run: 'rm ''.github/workflows/docs-pr.yaml'' && ''.github/workflows/docs-pr.main.kts'''
- id: 'step-2'
- id: 'step-3'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/docs-pr.yaml'''
docs-and-javadoc:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/release.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import io.github.typesafegithub.workflows.dsl.expressions.Contexts.github
import io.github.typesafegithub.workflows.dsl.expressions.Contexts.secrets
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.CheckoutActionVersionSource.InferFromClasspath
import io.github.typesafegithub.workflows.yaml.DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG

workflow(
name = "Build and Release Spock",
Expand All @@ -47,9 +45,7 @@ workflow(
)
),
sourceFile = __FILE__,
consistencyCheckJobConfig = DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
checkoutActionVersion = InferFromClasspath()
)
consistencyCheckJobConfig = commonConsistencyCheckJobConfig
) {
val GITHUB_TOKEN by secrets
val SONATYPE_OSS_USER by secrets
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
name: 'Check out'
uses: 'actions/checkout@v6'
- id: 'step-1'
name: 'Install pinned Kotlin (work-around for KT-86352)'
uses: './.github/actions/install-pinned-kotlin'
- id: 'step-2'
name: 'Execute script'
run: 'rm ''.github/workflows/release.yaml'' && ''.github/workflows/release.main.kts'''
- id: 'step-2'
- id: 'step-3'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/release.yaml'''
build-and-verify:
Expand Down
Loading