From 2c0326dc532f512c298a7ef490b1a307a517dd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 15 Aug 2024 13:18:51 +0200 Subject: [PATCH 1/7] Do not try to update Ubuntu 24.04 due to a bug in systemd package --- .github/workflows/test.main.kts | 6 +++++- .github/workflows/test.yaml | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index b3e80f1d..47e52d99 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -765,7 +765,11 @@ workflowWithCopyright( update = true ), // work-around for https://bugs.kali.org/view.php?id=6672 - condition = "matrix.distribution.user-id != 'kali-linux'" + // and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555 + condition = """ + (matrix.distribution.user-id != 'kali-linux') + && (matrix.distribution.user-id != 'Ubuntu-24.04') + """.trimIndent() ) executeActionStep = usesSelf( name = "Install default absent tool", diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8c1fec5f..ba85c461 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1434,7 +1434,9 @@ jobs: with: distribution: '${{ matrix.distribution.user-id }}' update: 'true' - if: 'matrix.distribution.user-id != ''kali-linux''' + if: |- + (matrix.distribution.user-id != 'kali-linux') + && (matrix.distribution.user-id != 'Ubuntu-24.04') - id: 'step-3' name: 'Install default absent tool' uses: './' From 9c1480acc438ab92d5ed5ac85a0f79cd029e58b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Sun, 16 Jun 2024 21:17:48 +0200 Subject: [PATCH 2/7] Use Maven-based bindings for GitHub Actions workflows DSL --- .../workflows/check-action-typing.main.kts | 13 +++-- .github/workflows/check-action-typing.yaml | 4 +- .../check-dependency-versions.main.kts | 20 ++++--- .../workflows/check-dependency-versions.yaml | 6 +- .github/workflows/test.main.kts | 57 +++++++++++-------- .github/workflows/test.yaml | 2 +- .../validate-gradle-wrapper.main.kts | 13 +++-- .../workflows/validate-gradle-wrapper.yaml | 4 +- .../workflow-with-copyright.main.kts | 7 ++- 9 files changed, 72 insertions(+), 54 deletions(-) diff --git a/.github/workflows/check-action-typing.main.kts b/.github/workflows/check-action-typing.main.kts index 2631d113..f9c0bdd8 100755 --- a/.github/workflows/check-action-typing.main.kts +++ b/.github/workflows/check-action-typing.main.kts @@ -1,7 +1,7 @@ #!/usr/bin/env kotlin /* - * Copyright 2020-2023 Björn Kautler + * Copyright 2020-2024 Björn Kautler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,12 @@ */ @file:Import("workflow-with-copyright.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("typesafegithub:github-actions-typing:v1") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 -import io.github.typesafegithub.workflows.actions.typesafegithub.GithubActionsTypingV1 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.typesafegithub.GithubActionsTyping import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest import io.github.typesafegithub.workflows.domain.triggers.PullRequest import io.github.typesafegithub.workflows.domain.triggers.Push @@ -43,11 +46,11 @@ workflowWithCopyright( ) uses( name = "Checkout", - action = CheckoutV3() + action = Checkout() ) uses( name = "Check Action Typing", - action = GithubActionsTypingV1() + action = GithubActionsTyping() ) } } diff --git a/.github/workflows/check-action-typing.yaml b/.github/workflows/check-action-typing.yaml index e8afd042..34ae96cd 100644 --- a/.github/workflows/check-action-typing.yaml +++ b/.github/workflows/check-action-typing.yaml @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Björn Kautler +# Copyright 2020-2024 Björn Kautler # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ jobs: run: 'git config --global core.autocrlf input' - id: 'step-1' name: 'Checkout' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-2' name: 'Check Action Typing' uses: 'typesafegithub/github-actions-typing@v1' diff --git a/.github/workflows/check-dependency-versions.main.kts b/.github/workflows/check-dependency-versions.main.kts index 27705d44..d915b01a 100755 --- a/.github/workflows/check-dependency-versions.main.kts +++ b/.github/workflows/check-dependency-versions.main.kts @@ -1,7 +1,7 @@ #!/usr/bin/env kotlin /* - * Copyright 2020-2023 Björn Kautler + * Copyright 2020-2024 Björn Kautler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,15 @@ */ @file:Import("workflow-with-copyright.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("actions:setup-java:v4") +@file:DependsOn("burrunan:gradle-cache-action:v1") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 -import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3 -import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3.Distribution.Temurin -import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheActionV1 +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.actions.SetupJava +import io.github.typesafegithub.workflows.actions.actions.SetupJava.Distribution.Temurin +import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheAction import io.github.typesafegithub.workflows.domain.RunnerType.WindowsLatest import io.github.typesafegithub.workflows.domain.triggers.Cron import io.github.typesafegithub.workflows.domain.triggers.Schedule @@ -52,18 +56,18 @@ workflowWithCopyright( ) uses( name = "Checkout", - action = CheckoutV3() + action = Checkout() ) uses( name = "Setup Java 11", - action = SetupJavaV3( + action = SetupJava( javaVersion = "11", distribution = Temurin ) ) uses( name = "Check Dependency Versions", - action = GradleCacheActionV1( + action = GradleCacheAction( arguments = listOf("--show-version", "dependencyUpdates"), debug = false, concurrent = true diff --git a/.github/workflows/check-dependency-versions.yaml b/.github/workflows/check-dependency-versions.yaml index 8704107e..081ed42f 100644 --- a/.github/workflows/check-dependency-versions.yaml +++ b/.github/workflows/check-dependency-versions.yaml @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Björn Kautler +# Copyright 2020-2024 Björn Kautler # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,10 +45,10 @@ jobs: run: 'git config --global core.autocrlf input' - id: 'step-1' name: 'Checkout' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-2' name: 'Setup Java 11' - uses: 'actions/setup-java@v3' + uses: 'actions/setup-java@v4' with: java-version: '11' distribution: 'temurin' diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index 47e52d99..4dafaa00 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -1,7 +1,7 @@ #!/usr/bin/env kotlin /* - * Copyright 2020-2023 Björn Kautler + * Copyright 2020-2024 Björn Kautler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,15 +17,22 @@ */ @file:Import("workflow-with-copyright.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:cache__restore:v4") +@file:DependsOn("actions:cache__save:v4") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("actions:setup-java:v4") +@file:DependsOn("burrunan:gradle-cache-action:v1") +@file:DependsOn("Vampire:setup-wsl:v3") -import io.github.typesafegithub.workflows.actions.actions.CacheRestoreV4 -import io.github.typesafegithub.workflows.actions.actions.CacheSaveV4 -import io.github.typesafegithub.workflows.actions.actions.CheckoutV4 -import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4 -import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4.Distribution.Temurin -import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheActionV1 -import io.github.typesafegithub.workflows.actions.vampire.SetupWslV3 -import io.github.typesafegithub.workflows.actions.vampire.SetupWslV3.Distribution +import io.github.typesafegithub.workflows.actions.actions.CacheRestore +import io.github.typesafegithub.workflows.actions.actions.CacheSave +import io.github.typesafegithub.workflows.actions.actions.Checkout +import io.github.typesafegithub.workflows.actions.actions.SetupJava +import io.github.typesafegithub.workflows.actions.actions.SetupJava.Distribution.Temurin +import io.github.typesafegithub.workflows.actions.burrunan.GradleCacheAction +import io.github.typesafegithub.workflows.actions.vampire.SetupWsl +import io.github.typesafegithub.workflows.actions.vampire.SetupWsl.Distribution import io.github.typesafegithub.workflows.domain.CommandStep import io.github.typesafegithub.workflows.domain.ActionStep import io.github.typesafegithub.workflows.domain.JobOutputs.EMPTY @@ -129,7 +136,7 @@ val wslBash = Shell.Custom("wsl-bash {0}") val wslSh = Shell.Custom("wsl-sh {0}") -lateinit var executeActionStep: ActionStep +lateinit var executeActionStep: ActionStep workflowWithCopyright( name = "Build and Test", @@ -145,7 +152,7 @@ workflowWithCopyright( "build/distributions/" ) - val executeAction = SetupWslV3( + val executeAction = SetupWsl( distribution = Distribution.Custom(expr("matrix.distribution.user-id")) ) @@ -160,18 +167,18 @@ workflowWithCopyright( ) uses( name = "Checkout", - action = CheckoutV4() + action = Checkout() ) uses( name = "Setup Java 11", - action = SetupJavaV4( + action = SetupJava( javaVersion = "11", distribution = Temurin ) ) uses( name = "Build", - action = GradleCacheActionV1( + action = GradleCacheAction( arguments = listOf( "--show-version", "build", @@ -185,7 +192,7 @@ workflowWithCopyright( ) uses( name = "Save built artifacts to cache", - action = CacheSaveV4( + action = CacheSave( path = builtArtifacts, key = expr { github.run_id } ) @@ -206,7 +213,7 @@ workflowWithCopyright( ) { uses( name = "Restore built artifacts from cache", - action = CacheRestoreV4( + action = CacheRestore( path = builtArtifacts, key = expr { github.run_id }, failOnCacheMiss = true @@ -266,7 +273,7 @@ workflowWithCopyright( ) ) { executeActionStep = usesSelf( - action = SetupWslV3( + action = SetupWsl( update = true ) ) @@ -686,26 +693,26 @@ workflowWithCopyright( ) { usesSelf( name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")}", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distributions.distribution1.user-id")) ) ) usesSelf( name = "Execute action for ${expr("matrix.distributions.distribution2.user-id")}", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distributions.distribution2.user-id")) ) ) usesSelf( name = "Execute action for ${expr("matrix.distributions.distribution3.user-id")}", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distributions.distribution3.user-id")), setAsDefault = false ) ) executeActionStep = usesSelf( name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")} again", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distributions.distribution1.user-id")) ) ) @@ -783,7 +790,7 @@ workflowWithCopyright( ) executeActionStep = usesSelfAfterSuccess( name = "Execute action for ${expr("matrix.distribution2.user-id")}", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distribution2.user-id")) ) ) @@ -842,7 +849,7 @@ workflowWithCopyright( .associateWith { usesSelf( name = "Execute action for ${expr("matrix.distributions.distribution$it.user-id")}", - action = SetupWslV3( + action = SetupWsl( distribution = Distribution.Custom(expr("matrix.distributions.distribution$it.user-id")), additionalPackages = if (it == 2) listOf("bash") else null, setAsDefault = if (it >= 3) false else null @@ -934,7 +941,7 @@ fun JobBuilder<*>.commonTests() { fun JobBuilder<*>.usesSelfAfterSuccess( name: String = "Execute action", - action: SetupWslV3 + action: SetupWsl ) = usesSelf( name = name, action = action, @@ -943,7 +950,7 @@ fun JobBuilder<*>.usesSelfAfterSuccess( fun JobBuilder<*>.usesSelf( name: String = "Execute action", - action: SetupWslV3, + action: SetupWsl, condition: String? = null, continueOnError: Boolean? = null ) = uses( diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ba85c461..96bbc800 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Björn Kautler +# Copyright 2020-2024 Björn Kautler # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/.github/workflows/validate-gradle-wrapper.main.kts b/.github/workflows/validate-gradle-wrapper.main.kts index 91fa1ad4..19862fc4 100755 --- a/.github/workflows/validate-gradle-wrapper.main.kts +++ b/.github/workflows/validate-gradle-wrapper.main.kts @@ -1,7 +1,7 @@ #!/usr/bin/env kotlin /* - * Copyright 2020-2023 Björn Kautler + * Copyright 2020-2024 Björn Kautler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,12 @@ */ @file:Import("workflow-with-copyright.main.kts") +@file:Repository("https://bindings.krzeminski.it/") +@file:DependsOn("actions:checkout:v4") +@file:DependsOn("gradle:wrapper-validation-action:v1") -import io.github.typesafegithub.workflows.actions.actions.CheckoutV3 -import io.github.typesafegithub.workflows.actions.gradle.WrapperValidationActionV1 +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 @@ -43,11 +46,11 @@ workflowWithCopyright( ) uses( name = "Checkout", - action = CheckoutV3() + action = Checkout() ) uses( name = "Validate Gradle Wrapper", - action = WrapperValidationActionV1() + action = WrapperValidationAction() ) } } diff --git a/.github/workflows/validate-gradle-wrapper.yaml b/.github/workflows/validate-gradle-wrapper.yaml index 9c956b95..50eb0e94 100644 --- a/.github/workflows/validate-gradle-wrapper.yaml +++ b/.github/workflows/validate-gradle-wrapper.yaml @@ -1,4 +1,4 @@ -# Copyright 2020-2023 Björn Kautler +# Copyright 2020-2024 Björn Kautler # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ jobs: run: 'git config --global core.autocrlf input' - id: 'step-1' name: 'Checkout' - uses: 'actions/checkout@v3' + uses: 'actions/checkout@v4' - id: 'step-2' name: 'Validate Gradle Wrapper' uses: 'gradle/wrapper-validation-action@v1' diff --git a/.github/workflows/workflow-with-copyright.main.kts b/.github/workflows/workflow-with-copyright.main.kts index b636366e..4cc7a533 100644 --- a/.github/workflows/workflow-with-copyright.main.kts +++ b/.github/workflows/workflow-with-copyright.main.kts @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Björn Kautler + * Copyright 2020-2024 Björn Kautler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,8 @@ * limitations under the License. */ -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.0.0") +@file:Repository("https://repo.maven.apache.org/maven2/") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.3.0") import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.triggers.Trigger @@ -39,7 +40,7 @@ fun workflowWithCopyright( concurrency = concurrency, preamble = WithOriginalAfter( """ - Copyright 2020-2023 Björn Kautler + Copyright 2020-2024 Björn Kautler Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From c2c53582e063b211f78cbaee01b87f6dbe1bb64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= <3110813+krzema12@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:01:05 +0200 Subject: [PATCH 3/7] Update references to github-workflows-kt and github-actions-typing --- README.md | 5 ++--- action-types.yml | 2 +- readme/README.md.sha256 | 2 +- readme/README_template.md | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index adff93c5..ea1b1beb 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,8 @@ runner with a sufficient setup for this action to use or need changes for suppor With a proper test environment (self-hosted runner) that will stay available, I would also add proper official support where you can select the WSL version in your workflow files. -This action is natively supported by https://github.com/krzema12/github-actions-kotlin-dsl which allows writing -workflow files using a type-safe Kotlin DSL. There is a built-in wrapper for this action that you can use to -conveniently configure it. +Thanks to the provided [typings](action-types.yml), it is possible to use this action in a type-safe way using +https://github.com/typesafegithub/github-workflows-kt which allows writing workflow files using a type-safe Kotlin DSL. Table of Contents ----------------- diff --git a/action-types.yml b/action-types.yml index cafaa218..751abf41 100644 --- a/action-types.yml +++ b/action-types.yml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# See https://github.com/krzema12/github-actions-typing/ +# See https://github.com/typesafegithub/github-actions-typing/ inputs: distribution: type: enum diff --git a/readme/README.md.sha256 b/readme/README.md.sha256 index 8446bf06..7e044c6c 100644 --- a/readme/README.md.sha256 +++ b/readme/README.md.sha256 @@ -1 +1 @@ -3a263470375829dab5cb24d9363132ccaffcf93ab2333d04f144c02a376ce7f5 \ No newline at end of file +304a1feee9b09c7bac92296b06aea82659038cc4245a8e91e48b43d154c511ae \ No newline at end of file diff --git a/readme/README_template.md b/readme/README_template.md index b222d06b..a2e3cd79 100644 --- a/readme/README_template.md +++ b/readme/README_template.md @@ -22,9 +22,8 @@ runner with a sufficient setup for this action to use or need changes for suppor With a proper test environment (self-hosted runner) that will stay available, I would also add proper official support where you can select the WSL version in your workflow files. -This action is natively supported by https://github.com/krzema12/github-actions-kotlin-dsl which allows writing -workflow files using a type-safe Kotlin DSL. There is a built-in wrapper for this action that you can use to -conveniently configure it. +Thanks to the provided [typings](action-types.yml), it is possible to use this action in a type-safe way using +https://github.com/typesafegithub/github-workflows-kt which allows writing workflow files using a type-safe Kotlin DSL. Table of Contents ----------------- From f1b7dd4a7442faf33c1fbf60b2f7da972c7ce63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 4 Sep 2024 03:37:07 +0200 Subject: [PATCH 4/7] Update github-workflows-kt to 3.0.0 --- .github/workflows/test.main.kts | 8 ++++---- .github/workflows/workflow-with-copyright.main.kts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index 4dafaa00..a1c34906 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -1068,27 +1068,27 @@ fun JobBuilder<*>.verifyCommandResult( ) } -val Step.successCondition +val Step<*>.successCondition get() = """ always() && (${outcome.eq(Success)}) """.trimIndent() -val Step.successOnAlpineCondition +val Step<*>.successOnAlpineCondition get() = """ always() && (${outcome.eq(Success)}) && (matrix.distribution.user-id == 'Alpine') """.trimIndent() -val Step.successNotOnUbuntu2404Condition +val Step<*>.successNotOnUbuntu2404Condition get() = """ always() && (${outcome.eq(Success)}) && (matrix.distribution.user-id != 'Ubuntu-24.04') """.trimIndent() -fun Step.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """ +fun Step<*>.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """ always() && (${outcome.eq(Success)}) && (matrix.distributions.distribution$i.user-id != '$distribution') diff --git a/.github/workflows/workflow-with-copyright.main.kts b/.github/workflows/workflow-with-copyright.main.kts index 4cc7a533..8b550b0c 100644 --- a/.github/workflows/workflow-with-copyright.main.kts +++ b/.github/workflows/workflow-with-copyright.main.kts @@ -15,7 +15,7 @@ */ @file:Repository("https://repo.maven.apache.org/maven2/") -@file:DependsOn("io.github.typesafegithub:github-workflows-kt:2.3.0") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.0") import io.github.typesafegithub.workflows.domain.Concurrency import io.github.typesafegithub.workflows.domain.triggers.Trigger From 942db883f796a3ffb1ee68090c4a1ae7c26ebf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 9 Oct 2024 19:31:26 +0200 Subject: [PATCH 5/7] Use static download link for Ubuntu 24.04 --- .../kotlin/net/kautler/github/action/setup_wsl/Distribution.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt b/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt index 4e90526f..29cbb972 100644 --- a/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt +++ b/src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt @@ -253,7 +253,7 @@ object Ubuntu2404 : AptGetBasedDistribution( version = SemVer("24.4.0", jso()), // work-around for missing shortlink on https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions //downloadUrl = URL("https://aka.ms/wslubuntu2404"), - productId = "9nz3klhxdjp5", + downloadUrl = URL("https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2404-240425.AppxBundle"), installerFile = "ubuntu2404.exe" ) From b135bad1dc23450f099fadf8d40898a967d2dfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 17 Oct 2024 18:01:44 +0200 Subject: [PATCH 6/7] Do not try to install sudo on kali-linux due to a bug in systemd package --- .github/workflows/test.main.kts | 28 +++++++++++++++++++++------- .github/workflows/test.yaml | 3 +++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index a1c34906..be0b086d 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -412,6 +412,8 @@ workflowWithCopyright( ) executeActionStep = usesSelfAfterSuccess( name = "Set wsl-bash wrapper to use user test by default", + // part of work-around for https://bugs.kali.org/view.php?id=8921 + conditionTransformer = { executeActionStep.successNotOnKaliCondition }, action = executeAction.copy( additionalPackages = listOf("sudo"), wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\""" @@ -419,11 +421,15 @@ workflowWithCopyright( ) verifyCommandResult( name = "Test - wsl-bash should use test as default user", + // part of work-around for https://bugs.kali.org/view.php?id=8921 + conditionTransformer = { executeActionStep.successNotOnKaliCondition }, actualCommand = "whoami", expected = "test" ) executeActionStep = usesSelfAfterSuccess( name = "Set wsl-bash wrapper to use user test by default with inline script usage", + // part of work-around for https://bugs.kali.org/view.php?id=8921 + conditionTransformer = { executeActionStep.successNotOnKaliCondition }, action = executeAction.copy( wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'"""" ) @@ -774,8 +780,8 @@ workflowWithCopyright( // work-around for https://bugs.kali.org/view.php?id=6672 // and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555 condition = """ - (matrix.distribution.user-id != 'kali-linux') - && (matrix.distribution.user-id != 'Ubuntu-24.04') + (matrix.distribution.user-id != '${kali["user-id"]}') + && (matrix.distribution.user-id != '${ubuntu2404["user-id"]}') """.trimIndent() ) executeActionStep = usesSelf( @@ -861,7 +867,7 @@ workflowWithCopyright( verifyInstalledDistribution( name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", conditionTransformer = if (distributions[i] == ubuntu2004) { - { executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-20.04") } + { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2004["user-id"]!!) } } else { { it } }, @@ -873,7 +879,7 @@ workflowWithCopyright( if (distributions[i] == ubuntu2004) { verifyInstalledDistribution( name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", - conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-22.04") }, + conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2204["user-id"]!!) }, shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"), expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern" ) @@ -941,11 +947,12 @@ fun JobBuilder<*>.commonTests() { fun JobBuilder<*>.usesSelfAfterSuccess( name: String = "Execute action", + conditionTransformer: (String) -> String = { it }, action: SetupWsl ) = usesSelf( name = name, action = action, - condition = executeActionStep.successCondition + condition = conditionTransformer(executeActionStep.successCondition).trimIndent() ) fun JobBuilder<*>.usesSelf( @@ -1078,14 +1085,21 @@ val Step<*>.successOnAlpineCondition get() = """ always() && (${outcome.eq(Success)}) - && (matrix.distribution.user-id == 'Alpine') + && (matrix.distribution.user-id == '${alpine["user-id"]}') + """.trimIndent() + +val Step<*>.successNotOnKaliCondition + get() = """ + always() + && (${outcome.eq(Success)}) + && (matrix.distribution.user-id != '${kali["user-id"]}') """.trimIndent() val Step<*>.successNotOnUbuntu2404Condition get() = """ always() && (${outcome.eq(Success)}) - && (matrix.distribution.user-id != 'Ubuntu-24.04') + && (matrix.distribution.user-id != '${ubuntu2404["user-id"]}') """.trimIndent() fun Step<*>.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """ diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 96bbc800..ae3f50ca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -664,6 +664,7 @@ jobs: if: |- always() && (steps.step-31.outcome == 'success') + && (matrix.distribution.user-id != 'kali-linux') - id: 'step-37' name: 'Test - wsl-bash should use test as default user' shell: 'wsl-bash {0}' @@ -673,6 +674,7 @@ jobs: if: |- always() && (steps.step-36.outcome == 'success') + && (matrix.distribution.user-id != 'kali-linux') - id: 'step-38' name: 'Set wsl-bash wrapper to use user test by default with inline script usage' uses: './' @@ -682,6 +684,7 @@ jobs: if: |- always() && (steps.step-36.outcome == 'success') + && (matrix.distribution.user-id != 'kali-linux') - id: 'step-39' name: 'Test - wsl-bash should use test as default user with inline script usage' shell: 'wsl-bash {0}' From 9114dfc08f458681713347a916371d685bfcb3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 17 Oct 2024 18:24:45 +0200 Subject: [PATCH 7/7] Do not try to install dos2unix on kali-linux due to a bug in systemd package --- .github/workflows/test.main.kts | 23 +++++++++++++++--- .github/workflows/test.yaml | 43 ++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index be0b086d..c1cbb471 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -624,7 +624,11 @@ workflowWithCopyright( "fail-fast" to false, "matrix" to mapOf( "environment" to environments, - "distribution" to distributions + "distribution" to ( + distributions + // part of work-around for https://bugs.kali.org/view.php?id=8921 + - kali + ) ) ) ) @@ -770,7 +774,14 @@ workflowWithCopyright( usesSelf( action = executeAction.copy( additionalPackages = listOf("bash") - ) + ), + // part of work-around for https://bugs.kali.org/view.php?id=8921 + condition = "matrix.distribution.user-id != '${kali["user-id"]}'" + ) + // part of work-around for https://bugs.kali.org/view.php?id=8921 + usesSelf( + action = executeAction, + condition = "matrix.distribution.user-id == '${kali["user-id"]}'" ) usesSelf( name = "Update distribution", @@ -788,11 +799,15 @@ workflowWithCopyright( name = "Install default absent tool", action = executeAction.copy( additionalPackages = listOf(expr("matrix.distribution.default-absent-tool")) - ) + ), + // part of work-around for https://bugs.kali.org/view.php?id=8921 + condition = "matrix.distribution.user-id != '${kali["user-id"]}'" ) runAfterSuccess( name = "Test - ${expr("matrix.distribution.default-absent-tool")} should be installed", - command = "${expr("matrix.distribution.default-absent-tool")} --version" + command = "${expr("matrix.distribution.default-absent-tool")} --version", + // part of work-around for https://bugs.kali.org/view.php?id=8921 + conditionTransformer = { executeActionStep.successNotOnKaliCondition } ) executeActionStep = usesSelfAfterSuccess( name = "Execute action for ${expr("matrix.distribution2.user-id")}", diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ae3f50ca..20b1c135 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1081,10 +1081,6 @@ jobs: user-id: 'Alpine' match-pattern: '*Alpine*' default-absent-tool: 'dos2unix' - - wsl-id: 'kali-linux' - user-id: 'kali-linux' - match-pattern: '*Kali*' - default-absent-tool: 'dos2unix' - wsl-id: 'openSUSE-Leap-15.2' user-id: 'openSUSE-Leap-15.2' match-pattern: '*openSUSE*Leap*15.2*' @@ -1431,7 +1427,14 @@ jobs: with: distribution: '${{ matrix.distribution.user-id }}' additional-packages: 'bash' + if: 'matrix.distribution.user-id != ''kali-linux''' - id: 'step-2' + name: 'Execute action' + uses: './' + with: + distribution: '${{ matrix.distribution.user-id }}' + if: 'matrix.distribution.user-id == ''kali-linux''' + - id: 'step-3' name: 'Update distribution' uses: './' with: @@ -1440,28 +1443,30 @@ jobs: if: |- (matrix.distribution.user-id != 'kali-linux') && (matrix.distribution.user-id != 'Ubuntu-24.04') - - id: 'step-3' + - id: 'step-4' name: 'Install default absent tool' uses: './' with: distribution: '${{ matrix.distribution.user-id }}' additional-packages: '${{ matrix.distribution.default-absent-tool }}' - - id: 'step-4' + if: 'matrix.distribution.user-id != ''kali-linux''' + - id: 'step-5' name: 'Test - ${{ matrix.distribution.default-absent-tool }} should be installed' shell: 'wsl-bash {0}' run: '${{ matrix.distribution.default-absent-tool }} --version' if: |- always() - && (steps.step-3.outcome == 'success') - - id: 'step-5' + && (steps.step-4.outcome == 'success') + && (matrix.distribution.user-id != 'kali-linux') + - id: 'step-6' name: 'Execute action for ${{ matrix.distribution2.user-id }}' uses: './' with: distribution: '${{ matrix.distribution2.user-id }}' if: |- always() - && (steps.step-3.outcome == 'success') - - id: 'step-6' + && (steps.step-4.outcome == 'success') + - id: 'step-7' name: 'Test - "${{ matrix.distribution2.user-id }}" should be the default distribution after installation' shell: 'wsl-bash {0}' run: |- @@ -1469,16 +1474,16 @@ jobs: [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distribution2.match-pattern }} ]] if: |- always() - && (steps.step-5.outcome == 'success') - - id: 'step-7' + && (steps.step-6.outcome == 'success') + - id: 'step-8' name: 'Re-execute action' uses: './' with: distribution: '${{ matrix.distribution.user-id }}' if: |- always() - && (steps.step-5.outcome == 'success') - - id: 'step-8' + && (steps.step-6.outcome == 'success') + - id: 'step-9' name: 'Test - "${{ matrix.distribution2.user-id }}" should still be the default distribution after re-running for "${{ matrix.distribution.user-id }}"' shell: 'wsl-bash {0}' run: |- @@ -1486,8 +1491,8 @@ jobs: [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distribution2.match-pattern }} ]] if: |- always() - && (steps.step-7.outcome == 'success') - - id: 'step-9' + && (steps.step-8.outcome == 'success') + - id: 'step-10' name: 'Set as default' uses: './' with: @@ -1495,8 +1500,8 @@ jobs: set-as-default: 'true' if: |- always() - && (steps.step-7.outcome == 'success') - - id: 'step-10' + && (steps.step-8.outcome == 'success') + - id: 'step-11' name: 'Test - "${{ matrix.distribution.user-id }}" should be the default distribution after re-running with set-as-default true' shell: 'wsl-bash {0}' run: |- @@ -1504,7 +1509,7 @@ jobs: [[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distribution.match-pattern }} ]] if: |- always() - && (steps.step-9.outcome == 'success') + && (steps.step-10.outcome == 'success') test_distribution_specific_wsl_bash_scripts: name: 'Test distribution specific wsl-bash scripts on ${{ matrix.environment }} (without ${{ matrix.distributions.incompatibleUbuntu }})' runs-on: '${{ matrix.environment }}'