diff --git a/.github/workflows/test.main.kts b/.github/workflows/test.main.kts index 7ad32ef8..49eaeab4 100755 --- a/.github/workflows/test.main.kts +++ b/.github/workflows/test.main.kts @@ -16,7 +16,9 @@ * limitations under the License. */ -@file:Import("workflow-with-copyright.main.kts") +@file:Repository("https://repo.maven.apache.org/maven2/") +@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.0") +//@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") @@ -24,6 +26,7 @@ @file:DependsOn("actions:setup-java:v4") @file:DependsOn("burrunan:gradle-cache-action:v1") @file:DependsOn("Vampire:setup-wsl:v3") +@file:DependsOn("mxschmitt:action-tmate:v3") import io.github.typesafegithub.workflows.actions.actions.CacheRestore import io.github.typesafegithub.workflows.actions.actions.CacheSave @@ -31,6 +34,7 @@ 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.mxschmitt.ActionTmate import io.github.typesafegithub.workflows.actions.vampire.SetupWsl import io.github.typesafegithub.workflows.actions.vampire.SetupWsl.Distribution.Debian import io.github.typesafegithub.workflows.actions.vampire.SetupWsl.Distribution.Ubuntu1604 @@ -51,11 +55,12 @@ import io.github.typesafegithub.workflows.domain.triggers.Schedule import io.github.typesafegithub.workflows.dsl.JobBuilder import io.github.typesafegithub.workflows.dsl.WorkflowBuilder import io.github.typesafegithub.workflows.dsl.expressions.expr -import kotlin.math.min +import io.github.typesafegithub.workflows.dsl.workflow val environments = listOf( "windows-2019", "windows-2022", + "windows-2025", "windows-latest" ) @@ -140,7 +145,8 @@ val wslSh = Shell.Custom("wsl-sh {0}") lateinit var executeActionStep: ActionStep -workflowWithCopyright( +//workflowWithCopyright( +workflow( name = "Build and Test", on = listOf( Push(), @@ -229,77 +235,77 @@ workflowWithCopyright( block() } - testJob( - id = "test_invalid_distribution", - name = """Test "${expr("matrix.distribution.label")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to listOf( - mapOf( - "user-id" to "invalid", - "label" to "invalid" - ), - mapOf( - "user-id" to "", - "label" to "" - ), - mapOf( - "user-id" to null, - "label" to "null" - ) - ) - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction, - continueOnError = true - ) - run( - name = "Test - action should fail if an invalid distribution is given", - shell = Cmd, - command = "if '${expr("${executeActionStep.outcome}")}' NEQ 'failure' exit 1" - ) - } - - testJob( - id = "test_invalid_wsl_version", - name = """Test requesting WSL version ${expr("matrix.wsl-version")} on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "wsl-version" to listOf("-1", "0"), - "include" to listOf( - mapOf( - "environment" to "windows-2019", - "wsl-version" to "2" - ) - ) - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - distribution = Debian, - _customInputs = mapOf( - "wsl-version" to expr("matrix.wsl-version") - ) - ), - continueOnError = true - ) - run( - name = "Test - action should fail if an invalid WSL version is given", - shell = Cmd, - command = "if '${expr("${executeActionStep.outcome}")}' NEQ 'failure' exit 1" - ) - } +// testJob( +// id = "test_invalid_distribution", +// name = """Test "${expr("matrix.distribution.label")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to listOf( +// mapOf( +// "user-id" to "invalid", +// "label" to "invalid" +// ), +// mapOf( +// "user-id" to "", +// "label" to "" +// ), +// mapOf( +// "user-id" to null, +// "label" to "null" +// ) +// ) +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction, +// continueOnError = true +// ) +// run( +// name = "Test - action should fail if an invalid distribution is given", +// shell = Cmd, +// command = "if '${expr("${executeActionStep.outcome}")}' NEQ 'failure' exit 1" +// ) +// } +// +// testJob( +// id = "test_invalid_wsl_version", +// name = """Test requesting WSL version ${expr("matrix.wsl-version")} on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "wsl-version" to listOf("-1", "0"), +// "include" to listOf( +// mapOf( +// "environment" to "windows-2019", +// "wsl-version" to "2" +// ) +// ) +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// distribution = Debian, +// _customInputs = mapOf( +// "wsl-version" to expr("matrix.wsl-version") +// ) +// ), +// continueOnError = true +// ) +// run( +// name = "Test - action should fail if an invalid WSL version is given", +// shell = Cmd, +// command = "if '${expr("${executeActionStep.outcome}")}' NEQ 'failure' exit 1" +// ) +// } testJob( id = "test_default_distribution", @@ -308,7 +314,11 @@ workflowWithCopyright( "strategy" to mapOf( "fail-fast" to false, "matrix" to mapOf( - "environment" to environments, + "environment" to listOf( + "windows-2019", + "windows-2022", + "windows-2025" + ), "distribution" to listOf(debian).map { it.asMap } ) ) @@ -343,914 +353,918 @@ workflowWithCopyright( name = "Test - wsl-bash should fail if given script file does not exist", provocationShell = Shell.Custom("wsl-bash -u user {0}foo") ) - } - - testJob( - id = "test", - name = """Test "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - useCache = false, - _customInputs = mapOf( - // part of work-around for https://bugs.kali.org/view.php?id=8921 - "wsl-version" to expr(getWslVersionExpression(kali)) - ) - ) - ) - verifyFailure( - name = "Test - wsl-bash should fail if bash is not present by default", - conditionTransformer = { executeActionStep.getSuccessOnDistributionCondition(alpine) }, - verificationShell = null, - verificationTransformer = { _, command -> - """wsl sh -euc "${command.replace("==", "=")}"""" - } - ) - deleteWslBashOnAlpine() - usesSelf( - name = "Install Bash on Alpine", - action = executeAction.copy( - additionalPackages = listOf("bash"), - _customInputs = emptyMap() - ), - condition = executeActionStep.getSuccessOnDistributionCondition(alpine) - ) - commonTests() - verifyFailure( - name = "Test - ${expr("matrix.distribution.default-absent-tool")} should not be installed by default", - provocationCommand = "${expr("matrix.distribution.default-absent-tool")} --version" - ) - runAfterSuccess( - name = "Test - bash should be installed by default", - command = "bash -c true" - ) - runAfterSuccess( - name = "Test - sh should be installed by default", - command = "sh -c true" - ) - verifyFailure( - name = "Test - wsl-sh should not be present", - provocationShell = wslSh - ) - val wslBashPath = executeActionStep.outputs.wslShellWrapperPath - executeActionStep = usesSelfAfterSuccess( - name = "Add wsl-sh wrapper", - action = executeAction.copy( - wslShellCommand = "sh -eu", - _customInputs = emptyMap() - ) - ) - runAfterSuccess( - name = "Test - wsl-sh should be present", - shell = wslSh - ) - runAfterSuccess( - name = "Test - wsl-bash should use bash", - command = """ - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] - """ - ) - runAfterSuccess( - name = "Test - wsl-sh should use sh", - shell = wslSh, - command = """ - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" = 'sh' ] - """ - ) - deleteWslBash( - wslBashPathExpression = wslBashPath - ) - verifyFailure( - name = "Test - wsl-bash should not be present", - verificationShell = wslSh, - verificationTransformer = { _, command -> - command.replace("==", "=") - } - ) - executeActionStep = usesSelfAfterSuccess( - name = "Re-add wsl-bash wrapper", - action = executeAction.copy( - _customInputs = emptyMap() - ) - ) - runAfterSuccess( - name = "Test - wsl-bash should be present" - ) - runAfterSuccess( - name = "Test - wsl-bash should use bash", - command = """ - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] - """ - ) - verifyCommandResult( - name = "Test - wsl-bash should use root as default user", - actualCommand = "whoami", - expected = "root" - ) - runAfterSuccess( - name = "Add user test", - command = "useradd -m -p 4qBD5NWD3IkbU test" - ) - 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 = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - }, - action = executeAction.copy( - additionalPackages = listOf("sudo"), - wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\""", - _customInputs = emptyMap() - ) - ) - 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 = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - }, - 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 = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - }, - action = executeAction.copy( - wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'"""", - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - wsl-bash should use test as default user with inline script usage", - actualCommand = "whoami", - expected = "test" - ) - deleteWslBash() - executeActionStep = usesSelfAfterSuccess( - name = "Set wsl-bash wrapper to use default user by default", - action = executeAction.copy( - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - wsl-bash should use root as default user", - actualCommand = "whoami", - expected = "root" - ) - runAfterSuccess( - name = "Test - test user does already exist", - command = "id -u test" - ) - deleteWslBash() - executeActionStep = usesSelfAfterSuccess( - name = "Set wsl-bash wrapper to use existing user test by default with extra parameter", - action = executeAction.copy( - wslShellUser = "test", - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - wsl-bash should use existing user test as default user with extra parameter", - actualCommand = "whoami", - expected = "test" - ) - runAfterSuccess( - name = "Test - test2 user does not exist", - command = "! id -u test2" - ) - deleteWslBash() - executeActionStep = usesSelfAfterSuccess( - name = "Set wsl-bash wrapper to use non-existing user test2 by default with extra parameter", - action = executeAction.copy( - wslShellUser = "test2", - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - wsl-bash should use auto-generated user test2 as default user", - actualCommand = "whoami", - expected = "test2" - ) - verifyCommandResult( - name = "Test - wsl-bash should use ad-hoc user test", - actualCommand = "whoami", - shell = Shell.Custom("wsl-bash -u test {0}"), - expected = "test" - ) - verifyCommandResult( - name = "Test - wsl-bash should use ad-hoc user root", - actualCommand = "whoami", - shell = Shell.Custom("wsl-bash -u root {0}"), - expected = "root" - ) - executeActionStep = usesSelfAfterSuccess( - name = "Make a no-op execution of the action", - action = executeAction.copy( - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - wsl-bash should still use test2 as default user", - actualCommand = "whoami", - expected = "test2" - ) - } - - testJob( - id = "test_wsl-conf_on_initial_execution", - name = """Test /etc/wsl.conf handling on initial execution for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - wslConf = """ - [automount] - options = uid=1000 - """.trimIndent() - ) - ) - deleteWslBashOnAlpine() - usesSelf( - name = "Install Bash on Alpine", - action = executeAction.copy( - additionalPackages = listOf("bash"), - _customInputs = emptyMap() - ), - condition = executeActionStep.getSuccessOnDistributionCondition(alpine) - ) - runAfterSuccess( - name = "Test - /etc/wsl.conf should exist", - command = """ - [ -f /etc/wsl.conf ] - cat /etc/wsl.conf - """ - ) - runAfterSuccess( - name = "Test - /mnt/c should be mounted with uid 1000", - command = """ - ls -alh /mnt - [[ "$(stat -c %u /mnt/c)" == 1000 ]] - """ - ) - } - - testJob( - id = "test_wsl-conf_on_subsequent_execution", - name = """Test /etc/wsl.conf handling on subsequent execution for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction - ) - deleteWslBashOnAlpine() - usesSelf( - name = "Install Bash on Alpine", - action = executeAction.copy( - additionalPackages = listOf("bash"), - _customInputs = emptyMap() - ), - condition = executeActionStep.getSuccessOnDistributionCondition(alpine) - ) - runAfterSuccess( - name = "Test - /etc/wsl.conf should not exist", - command = "[ ! -f /etc/wsl.conf ] || { cat /etc/wsl.conf; false; }", - conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2404) } - ) - runAfterSuccess( - name = "Test - C: should be mounted at /mnt/c", - command = """ - mount - mount | grep 'C:.* on /mnt/c' - """ - ) - runAfterSuccess( - name = "Test - /mnt/c should be mounted with uid 0", - command = """ - ls -alh /mnt - [[ "$(stat -c %u /mnt/c)" == 0 ]] - """ - ) - executeActionStep = usesSelfAfterSuccess( - action = executeAction.copy( - wslConf = """ - [automount] - root = / - """.trimIndent(), - _customInputs = emptyMap() - ) - ) - runAfterSuccess( - name = "Test - /etc/wsl.conf should exist", - command = """ - [ -f /etc/wsl.conf ] - cat /etc/wsl.conf - """ - ) - runAfterSuccess( - name = "Test - C: should be mounted at /c", - command = """ - mount - mount | grep 'C:.* on /c' - """ - ) - } - - testJob( - id = "test_additional_packages", - name = """Test additional packages for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - additionalPackages = listOf( - expr("matrix.distribution.default-absent-tool"), - "bash" - ), - _customInputs = mapOf( - // part of work-around for https://bugs.kali.org/view.php?id=8921 - "wsl-version" to expr(getWslVersionExpression(kali)) - ) - ), - // part of work-around for https://bugs.kali.org/view.php?id=8921 - condition = """ - |(matrix.distribution.user-id != '${kali.userId}') - ||| ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - |) - """.trimMargin() - ) - runAfterSuccess( - name = "Test - ${expr("matrix.distribution.default-absent-tool")} should be installed", - command = "${expr("matrix.distribution.default-absent-tool")} --version", - // part of work-around for https://bugs.kali.org/view.php?id=8921 - conditionTransformer = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - } - ) - runAfterSuccess( - name = "Test - bash should be installed", - command = "bash -c true", - // part of work-around for https://bugs.kali.org/view.php?id=8921 - conditionTransformer = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - } - ) - } - - testJob( - id = "test_installation_on_wsl_version", - name = """Test installation on WSLv${expr("matrix.wsl-version")} for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to (environments - "windows-2019"), - "distribution" to distributions, - "wsl-version" to (1..2).toList() - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - additionalPackages = listOf( - expr( - """ - (matrix.distribution.user-id == '${alpine.userId}') - && 'bash' - || '' - """.trimIndent() - ) - ), - _customInputs = mapOf( - "wsl-version" to expr("matrix.wsl-version") - ) - ) - ) - verifyCommandResult( - name = "Test - distribution should be running on WSLv${expr("matrix.wsl-version")}", - actualCommand = """ - cat - <(wsl.exe --list --verbose || true) - <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) - """.trimIndent().replace("\n", " "), - expectedPattern = """*${expr("matrix.distribution.wsl-id")}*\ ${expr("matrix.wsl-version")}*""" - ) - } - - testJob( - id = "test_switching_wsl_version_for_different_distributions", - name = """Test switching WSL version for different distributions on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to (environments - "windows-2019") - ) - ) - ) - ) { - usesSelf( - action = executeAction.copy( - distribution = Debian, - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - usesSelf( - action = executeAction.copy( - distribution = Ubuntu1604, - _customInputs = mapOf( - "wsl-version" to "2" - ) - ) - ) - executeActionStep = usesSelf( - action = executeAction.copy( - distribution = Ubuntu1804, - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - verifyCommandResult( - name = "Test - distributions should be running on their respective WSL version", - actualCommand = """ - cat - <(wsl.exe --list --verbose || true) - <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) - | sort -u - """.trimIndent().replace("\n", " "), - expectedPattern = """*${debian.wslId}*\ 1*${ubuntu1604.wslId}*\ 2*${ubuntu1804.wslId}*\ 1*""" - ) - } - - testJob( - id = "test_default_wsl_version", - name = """Test default WSL version for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions - ) - ) - ) - ) { - executeActionStep = usesSelf( - action = executeAction.copy( - additionalPackages = listOf( - expr( - """ - (matrix.distribution.user-id == '${alpine.userId}') - && 'bash' - || '' - """.trimIndent() - ) - ), - _customInputs = emptyMap() - ) - ) - verifyCommandResult( - name = "Test - default WSL version should be WSLv2", - // on windows-2019 the version is not printed but the wrong - // default (anything but WSLv1) would already make the action execution fail - conditionTransformer = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& (matrix.environment != 'windows-2019') - """.trimMargin() - }, - actualCommand = """ - cat - <(wsl.exe --list --verbose || true) - <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) - """.trimIndent().replace("\n", " "), - expectedPattern = """*${expr("matrix.distribution.wsl-id")}*\ 2*""" - ) - } - - testJob( - id = "test_multiple_usage_with_different_distributions", - name = """ - Test multiple usage with different distributions - ("${expr("matrix.distributions.distribution1.user-id")}" - / "${expr("matrix.distributions.distribution2.user-id")}" - / "${expr("matrix.distributions.distribution3.user-id")}") - on ${expr("matrix.environment")} - """.trimIndent().replace("\n", " "), - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distributions" to listOf( - mapOf( - "distribution1" to debian, - "distribution2" to ubuntu2004, - "distribution3" to ubuntu1804 - ), - mapOf( - "distribution1" to debian, - "distribution2" to ubuntu1804, - "distribution3" to ubuntu2004 - ), - mapOf( - "distribution1" to ubuntu2004, - "distribution2" to debian, - "distribution3" to ubuntu1804 - ), - mapOf( - "distribution1" to ubuntu2004, - "distribution2" to ubuntu1804, - "distribution3" to debian - ), - mapOf( - "distribution1" to ubuntu1804, - "distribution2" to debian, - "distribution3" to ubuntu2004 - ), - mapOf( - "distribution1" to ubuntu1804, - "distribution2" to ubuntu2004, - "distribution3" to debian - ) - ).map { - it.mapValues { (_, distribution) -> distribution.asMap } - } - ) - ) - ) - ) { - usesSelf( - name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")}", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution1.user-id")), - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - usesSelf( - name = "Execute action for ${expr("matrix.distributions.distribution2.user-id")}", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution2.user-id")), - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - usesSelf( - name = "Execute action for ${expr("matrix.distributions.distribution3.user-id")}", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution3.user-id")), - setAsDefault = false, - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - executeActionStep = usesSelf( - name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")} again", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution1.user-id")) - ) - ) - verifyCommandResult( - name = "Test - the default distribution should be the last installed distribution with set-as-default true", - actualCommand = """ - cat - <(wsl.exe --list || true) - <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) - <(wslconfig.exe /list || true) - <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8) - """.trimIndent().replace("\n", " "), - expectedPattern = """*${expr("matrix.distributions.distribution2.wsl-id")}\ \(Default\)*""" - ) - verifyInstalledDistribution( - name = "Test - wsl-bash should use the last installed distribution with set-as-default true", - expectedPatternExpression = "matrix.distributions.distribution2.match-pattern" - ) - } - - testJob( - id = "test_multiple_usage_with_same_distribution", - name = """Test multiple usage with "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - "distribution" to distributions, - "distribution2" to listOf(debian).map { it.asMap }, - "exclude" to environments.map { - mapOf( - "environment" to it, - "distribution" to debian.asMap, - "distribution2" to debian.asMap - ) - }, - "include" to environments.map { - mapOf( - "environment" to it, - "distribution" to debian.asMap, - "distribution2" to ubuntu2004.asMap - ) - } - ) - ) - ) - ) { - usesSelf( - action = executeAction.copy( - // part of work-around for https://bugs.kali.org/view.php?id=8921 - //additionalPackages = listOf("bash") - additionalPackages = listOf( - expr( - """ - |( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - |&& 'bash' - ||| '' - """.trimMargin() - ) - ), - _customInputs = mapOf( - // part of work-around for https://bugs.kali.org/view.php?id=8921 - // and https://bugs.kali.org/view.php?id=6672 - // and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555 - "wsl-version" to expr(getWslVersionExpression(kali, ubuntu2404)) - ) - ) - ) - usesSelf( - name = "Update distribution", - action = executeAction.copy( - update = true, - _customInputs = emptyMap() - ), - // part of 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.userId}') - | && (matrix.distribution.user-id != '${ubuntu2404.userId}') - |) - ||| ( - | ( - ${getWslVersionExpression(kali, ubuntu2404).prependIndent("| ")} - | ) == '2' - |) - """.trimMargin() - ) - executeActionStep = usesSelf( - name = "Install default absent tool", - action = executeAction.copy( - additionalPackages = listOf(expr("matrix.distribution.default-absent-tool")), - _customInputs = emptyMap() - ), - // part of work-around for https://bugs.kali.org/view.php?id=8921 - condition = """ - |(matrix.distribution.user-id != '${kali.userId}') - ||| ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - |) - """.trimMargin() - ) - runAfterSuccess( - name = "Test - ${expr("matrix.distribution.default-absent-tool")} should be installed", - command = "${expr("matrix.distribution.default-absent-tool")} --version", - // part of work-around for https://bugs.kali.org/view.php?id=8921 - conditionTransformer = { - """ - |( - ${it.prependIndent("| ")} - |) - |&& ( - | (matrix.distribution.user-id != '${kali.userId}') - | || ( - | ( - ${getWslVersionExpression(kali).prependIndent("| ")} - | ) == '2' - | ) - |) - """.trimMargin() - } - ) - executeActionStep = usesSelfAfterSuccess( - name = "Execute action for ${expr("matrix.distribution2.user-id")}", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distribution2.user-id")), - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - verifyInstalledDistribution( - name = """Test - "${expr("matrix.distribution2.user-id")}" should be the default distribution after installation""", - expectedPatternExpression = "matrix.distribution2.match-pattern" - ) - executeActionStep = usesSelfAfterSuccess( - name = "Re-execute action", - action = executeAction.copy( - _customInputs = emptyMap() - ) - ) - verifyInstalledDistribution( - name = """Test - "${expr("matrix.distribution2.user-id")}" should still be the default distribution after re-running for "${expr("matrix.distribution.user-id")}"""", - expectedPatternExpression = "matrix.distribution2.match-pattern" - ) - executeActionStep = usesSelfAfterSuccess( - name = "Set as default", - action = executeAction.copy( - setAsDefault = true, - _customInputs = emptyMap() - ) - ) - verifyInstalledDistribution( - name = """Test - "${expr("matrix.distribution.user-id")}" should be the default distribution after re-running with set-as-default true""" + uses( + action = ActionTmate(), + condition = expr { always() } ) } - testJob( - id = "test_distribution_specific_wsl_bash_scripts", - name = "Test distribution specific wsl-bash scripts on ${expr("matrix.environment")} (without ${expr("matrix.distributions.incompatibleUbuntu")})", - _customArguments = mapOf( - "strategy" to mapOf( - "fail-fast" to false, - "matrix" to mapOf( - "environment" to environments, - // ubuntu2004 and ubuntu2204 currently have the same wsl-id - // so their distribution specific wsl_bash scripts will clash - // and thus cannot be tested together - "distributions" to listOf(ubuntu2204, ubuntu2004) - .map { incompatibleUbuntu -> - distributions - .filter { it != incompatibleUbuntu.asMap } - .mapIndexed, Pair> { i, distribution -> - "distribution${i + 1}" to distribution - } - .toMutableList() - .apply { - add(0, "incompatibleUbuntu" to incompatibleUbuntu.userId) - } - .toMap() - } - ) - ) - ) - ) { - (1 until distributions.size) - .associateWith { - usesSelf( - name = "Execute action for ${expr("matrix.distributions.distribution$it.user-id")}", - action = SetupWsl( - distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution$it.user-id")), - additionalPackages = if (it == 2) listOf("bash") else null, - setAsDefault = if (it >= 3) false else null, - _customInputs = mapOf( - "wsl-version" to "1" - ) - ) - ) - } - .forEach { (i, localExecuteActionStep) -> - executeActionStep = localExecuteActionStep - verifyInstalledDistribution( - name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", - conditionTransformer = if (distributions[i] == ubuntu2004.asMap) { - { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2004, i) } - } else { - { it } - }, - // the formula adds 1 to the indices from ubuntu2004 on - // to mitigate the double entry for the previous index - shell = Shell.Custom("wsl-bash_${distributions[min(1, i / (distributions.indexOf(ubuntu2004.asMap) + 1)) + i - 1]["user-id"]} {0}"), - expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern" - ) - if (distributions[i] == ubuntu2004.asMap) { - verifyInstalledDistribution( - name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", - conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2204, i) }, - shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"), - expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern" - ) - } - } - } +// testJob( +// id = "test", +// name = """Test "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// useCache = false, +// _customInputs = mapOf( +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// "wsl-version" to expr(getWslVersionExpression(kali)) +// ) +// ) +// ) +// verifyFailure( +// name = "Test - wsl-bash should fail if bash is not present by default", +// conditionTransformer = { executeActionStep.getSuccessOnDistributionCondition(alpine) }, +// verificationShell = null, +// verificationTransformer = { _, command -> +// """wsl sh -euc "${command.replace("==", "=")}"""" +// } +// ) +// deleteWslBashOnAlpine() +// usesSelf( +// name = "Install Bash on Alpine", +// action = executeAction.copy( +// additionalPackages = listOf("bash"), +// _customInputs = emptyMap() +// ), +// condition = executeActionStep.getSuccessOnDistributionCondition(alpine) +// ) +// commonTests() +// verifyFailure( +// name = "Test - ${expr("matrix.distribution.default-absent-tool")} should not be installed by default", +// provocationCommand = "${expr("matrix.distribution.default-absent-tool")} --version" +// ) +// runAfterSuccess( +// name = "Test - bash should be installed by default", +// command = "bash -c true" +// ) +// runAfterSuccess( +// name = "Test - sh should be installed by default", +// command = "sh -c true" +// ) +// verifyFailure( +// name = "Test - wsl-sh should not be present", +// provocationShell = wslSh +// ) +// val wslBashPath = executeActionStep.outputs.wslShellWrapperPath +// executeActionStep = usesSelfAfterSuccess( +// name = "Add wsl-sh wrapper", +// action = executeAction.copy( +// wslShellCommand = "sh -eu", +// _customInputs = emptyMap() +// ) +// ) +// runAfterSuccess( +// name = "Test - wsl-sh should be present", +// shell = wslSh +// ) +// runAfterSuccess( +// name = "Test - wsl-bash should use bash", +// command = """ +// ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' +// [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] +// """ +// ) +// runAfterSuccess( +// name = "Test - wsl-sh should use sh", +// shell = wslSh, +// command = """ +// ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' +// [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" = 'sh' ] +// """ +// ) +// deleteWslBash( +// wslBashPathExpression = wslBashPath +// ) +// verifyFailure( +// name = "Test - wsl-bash should not be present", +// verificationShell = wslSh, +// verificationTransformer = { _, command -> +// command.replace("==", "=") +// } +// ) +// executeActionStep = usesSelfAfterSuccess( +// name = "Re-add wsl-bash wrapper", +// action = executeAction.copy( +// _customInputs = emptyMap() +// ) +// ) +// runAfterSuccess( +// name = "Test - wsl-bash should be present" +// ) +// runAfterSuccess( +// name = "Test - wsl-bash should use bash", +// command = """ +// ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' +// [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] +// """ +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use root as default user", +// actualCommand = "whoami", +// expected = "root" +// ) +// runAfterSuccess( +// name = "Add user test", +// command = "useradd -m -p 4qBD5NWD3IkbU test" +// ) +// 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 = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// }, +// action = executeAction.copy( +// additionalPackages = listOf("sudo"), +// wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\""", +// _customInputs = emptyMap() +// ) +// ) +// 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 = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// }, +// 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 = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// }, +// action = executeAction.copy( +// wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'"""", +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use test as default user with inline script usage", +// actualCommand = "whoami", +// expected = "test" +// ) +// deleteWslBash() +// executeActionStep = usesSelfAfterSuccess( +// name = "Set wsl-bash wrapper to use default user by default", +// action = executeAction.copy( +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use root as default user", +// actualCommand = "whoami", +// expected = "root" +// ) +// runAfterSuccess( +// name = "Test - test user does already exist", +// command = "id -u test" +// ) +// deleteWslBash() +// executeActionStep = usesSelfAfterSuccess( +// name = "Set wsl-bash wrapper to use existing user test by default with extra parameter", +// action = executeAction.copy( +// wslShellUser = "test", +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use existing user test as default user with extra parameter", +// actualCommand = "whoami", +// expected = "test" +// ) +// runAfterSuccess( +// name = "Test - test2 user does not exist", +// command = "! id -u test2" +// ) +// deleteWslBash() +// executeActionStep = usesSelfAfterSuccess( +// name = "Set wsl-bash wrapper to use non-existing user test2 by default with extra parameter", +// action = executeAction.copy( +// wslShellUser = "test2", +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use auto-generated user test2 as default user", +// actualCommand = "whoami", +// expected = "test2" +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use ad-hoc user test", +// actualCommand = "whoami", +// shell = Shell.Custom("wsl-bash -u test {0}"), +// expected = "test" +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should use ad-hoc user root", +// actualCommand = "whoami", +// shell = Shell.Custom("wsl-bash -u root {0}"), +// expected = "root" +// ) +// executeActionStep = usesSelfAfterSuccess( +// name = "Make a no-op execution of the action", +// action = executeAction.copy( +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - wsl-bash should still use test2 as default user", +// actualCommand = "whoami", +// expected = "test2" +// ) +// } +// +// testJob( +// id = "test_wsl-conf_on_initial_execution", +// name = """Test /etc/wsl.conf handling on initial execution for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// wslConf = """ +// [automount] +// options = uid=1000 +// """.trimIndent() +// ) +// ) +// deleteWslBashOnAlpine() +// usesSelf( +// name = "Install Bash on Alpine", +// action = executeAction.copy( +// additionalPackages = listOf("bash"), +// _customInputs = emptyMap() +// ), +// condition = executeActionStep.getSuccessOnDistributionCondition(alpine) +// ) +// runAfterSuccess( +// name = "Test - /etc/wsl.conf should exist", +// command = """ +// [ -f /etc/wsl.conf ] +// cat /etc/wsl.conf +// """ +// ) +// runAfterSuccess( +// name = "Test - /mnt/c should be mounted with uid 1000", +// command = """ +// ls -alh /mnt +// [[ "$(stat -c %u /mnt/c)" == 1000 ]] +// """ +// ) +// } +// +// testJob( +// id = "test_wsl-conf_on_subsequent_execution", +// name = """Test /etc/wsl.conf handling on subsequent execution for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction +// ) +// deleteWslBashOnAlpine() +// usesSelf( +// name = "Install Bash on Alpine", +// action = executeAction.copy( +// additionalPackages = listOf("bash"), +// _customInputs = emptyMap() +// ), +// condition = executeActionStep.getSuccessOnDistributionCondition(alpine) +// ) +// runAfterSuccess( +// name = "Test - /etc/wsl.conf should not exist", +// command = "[ ! -f /etc/wsl.conf ] || { cat /etc/wsl.conf; false; }", +// conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2404) } +// ) +// runAfterSuccess( +// name = "Test - C: should be mounted at /mnt/c", +// command = """ +// mount +// mount | grep 'C:.* on /mnt/c' +// """ +// ) +// runAfterSuccess( +// name = "Test - /mnt/c should be mounted with uid 0", +// command = """ +// ls -alh /mnt +// [[ "$(stat -c %u /mnt/c)" == 0 ]] +// """ +// ) +// executeActionStep = usesSelfAfterSuccess( +// action = executeAction.copy( +// wslConf = """ +// [automount] +// root = / +// """.trimIndent(), +// _customInputs = emptyMap() +// ) +// ) +// runAfterSuccess( +// name = "Test - /etc/wsl.conf should exist", +// command = """ +// [ -f /etc/wsl.conf ] +// cat /etc/wsl.conf +// """ +// ) +// runAfterSuccess( +// name = "Test - C: should be mounted at /c", +// command = """ +// mount +// mount | grep 'C:.* on /c' +// """ +// ) +// } +// +// testJob( +// id = "test_additional_packages", +// name = """Test additional packages for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// additionalPackages = listOf( +// expr("matrix.distribution.default-absent-tool"), +// "bash" +// ), +// _customInputs = mapOf( +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// "wsl-version" to expr(getWslVersionExpression(kali)) +// ) +// ), +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// condition = """ +// |(matrix.distribution.user-id != '${kali.userId}') +// ||| ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// |) +// """.trimMargin() +// ) +// runAfterSuccess( +// name = "Test - ${expr("matrix.distribution.default-absent-tool")} should be installed", +// command = "${expr("matrix.distribution.default-absent-tool")} --version", +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// conditionTransformer = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// } +// ) +// runAfterSuccess( +// name = "Test - bash should be installed", +// command = "bash -c true", +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// conditionTransformer = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// } +// ) +// } +// +// testJob( +// id = "test_installation_on_wsl_version", +// name = """Test installation on WSLv${expr("matrix.wsl-version")} for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to (environments - "windows-2019"), +// "distribution" to distributions, +// "wsl-version" to (1..2).toList() +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// additionalPackages = listOf( +// expr( +// """ +// (matrix.distribution.user-id == '${alpine.userId}') +// && 'bash' +// || '' +// """.trimIndent() +// ) +// ), +// _customInputs = mapOf( +// "wsl-version" to expr("matrix.wsl-version") +// ) +// ) +// ) +// verifyCommandResult( +// name = "Test - distribution should be running on WSLv${expr("matrix.wsl-version")}", +// actualCommand = """ +// cat +// <(wsl.exe --list --verbose || true) +// <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) +// """.trimIndent().replace("\n", " "), +// expectedPattern = """*${expr("matrix.distribution.wsl-id")}*\ ${expr("matrix.wsl-version")}*""" +// ) +// } +// +// testJob( +// id = "test_switching_wsl_version_for_different_distributions", +// name = """Test switching WSL version for different distributions on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to (environments - "windows-2019") +// ) +// ) +// ) +// ) { +// usesSelf( +// action = executeAction.copy( +// distribution = Debian, +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// usesSelf( +// action = executeAction.copy( +// distribution = Ubuntu1604, +// _customInputs = mapOf( +// "wsl-version" to "2" +// ) +// ) +// ) +// executeActionStep = usesSelf( +// action = executeAction.copy( +// distribution = Ubuntu1804, +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// verifyCommandResult( +// name = "Test - distributions should be running on their respective WSL version", +// actualCommand = """ +// cat +// <(wsl.exe --list --verbose || true) +// <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) +// | sort -u +// """.trimIndent().replace("\n", " "), +// expectedPattern = """*${debian.wslId}*\ 1*${ubuntu1604.wslId}*\ 2*${ubuntu1804.wslId}*\ 1*""" +// ) +// } +// +// testJob( +// id = "test_default_wsl_version", +// name = """Test default WSL version for "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions +// ) +// ) +// ) +// ) { +// executeActionStep = usesSelf( +// action = executeAction.copy( +// additionalPackages = listOf( +// expr( +// """ +// (matrix.distribution.user-id == '${alpine.userId}') +// && 'bash' +// || '' +// """.trimIndent() +// ) +// ), +// _customInputs = emptyMap() +// ) +// ) +// verifyCommandResult( +// name = "Test - default WSL version should be WSLv2", +// // on windows-2019 the version is not printed but the wrong +// // default (anything but WSLv1) would already make the action execution fail +// conditionTransformer = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& (matrix.environment != 'windows-2019') +// """.trimMargin() +// }, +// actualCommand = """ +// cat +// <(wsl.exe --list --verbose || true) +// <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) +// """.trimIndent().replace("\n", " "), +// expectedPattern = """*${expr("matrix.distribution.wsl-id")}*\ 2*""" +// ) +// } +// +// testJob( +// id = "test_multiple_usage_with_different_distributions", +// name = """ +// Test multiple usage with different distributions +// ("${expr("matrix.distributions.distribution1.user-id")}" +// / "${expr("matrix.distributions.distribution2.user-id")}" +// / "${expr("matrix.distributions.distribution3.user-id")}") +// on ${expr("matrix.environment")} +// """.trimIndent().replace("\n", " "), +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distributions" to listOf( +// mapOf( +// "distribution1" to debian, +// "distribution2" to ubuntu2004, +// "distribution3" to ubuntu1804 +// ), +// mapOf( +// "distribution1" to debian, +// "distribution2" to ubuntu1804, +// "distribution3" to ubuntu2004 +// ), +// mapOf( +// "distribution1" to ubuntu2004, +// "distribution2" to debian, +// "distribution3" to ubuntu1804 +// ), +// mapOf( +// "distribution1" to ubuntu2004, +// "distribution2" to ubuntu1804, +// "distribution3" to debian +// ), +// mapOf( +// "distribution1" to ubuntu1804, +// "distribution2" to debian, +// "distribution3" to ubuntu2004 +// ), +// mapOf( +// "distribution1" to ubuntu1804, +// "distribution2" to ubuntu2004, +// "distribution3" to debian +// ) +// ).map { +// it.mapValues { (_, distribution) -> distribution.asMap } +// } +// ) +// ) +// ) +// ) { +// usesSelf( +// name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")}", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution1.user-id")), +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// usesSelf( +// name = "Execute action for ${expr("matrix.distributions.distribution2.user-id")}", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution2.user-id")), +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// usesSelf( +// name = "Execute action for ${expr("matrix.distributions.distribution3.user-id")}", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution3.user-id")), +// setAsDefault = false, +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// executeActionStep = usesSelf( +// name = "Execute action for ${expr("matrix.distributions.distribution1.user-id")} again", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution1.user-id")) +// ) +// ) +// verifyCommandResult( +// name = "Test - the default distribution should be the last installed distribution with set-as-default true", +// actualCommand = """ +// cat +// <(wsl.exe --list || true) +// <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) +// <(wslconfig.exe /list || true) +// <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8) +// """.trimIndent().replace("\n", " "), +// expectedPattern = """*${expr("matrix.distributions.distribution2.wsl-id")}\ \(Default\)*""" +// ) +// verifyInstalledDistribution( +// name = "Test - wsl-bash should use the last installed distribution with set-as-default true", +// expectedPatternExpression = "matrix.distributions.distribution2.match-pattern" +// ) +// } +// +// testJob( +// id = "test_multiple_usage_with_same_distribution", +// name = """Test multiple usage with "${expr("matrix.distribution.user-id")}" distribution on ${expr("matrix.environment")}""", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// "distribution" to distributions, +// "distribution2" to listOf(debian).map { it.asMap }, +// "exclude" to environments.map { +// mapOf( +// "environment" to it, +// "distribution" to debian.asMap, +// "distribution2" to debian.asMap +// ) +// }, +// "include" to environments.map { +// mapOf( +// "environment" to it, +// "distribution" to debian.asMap, +// "distribution2" to ubuntu2004.asMap +// ) +// } +// ) +// ) +// ) +// ) { +// usesSelf( +// action = executeAction.copy( +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// //additionalPackages = listOf("bash") +// additionalPackages = listOf( +// expr( +// """ +// |( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// |&& 'bash' +// ||| '' +// """.trimMargin() +// ) +// ), +// _customInputs = mapOf( +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// // and https://bugs.kali.org/view.php?id=6672 +// // and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555 +// "wsl-version" to expr(getWslVersionExpression(kali, ubuntu2404)) +// ) +// ) +// ) +// usesSelf( +// name = "Update distribution", +// action = executeAction.copy( +// update = true, +// _customInputs = emptyMap() +// ), +// // part of 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.userId}') +// | && (matrix.distribution.user-id != '${ubuntu2404.userId}') +// |) +// ||| ( +// | ( +// ${getWslVersionExpression(kali, ubuntu2404).prependIndent("| ")} +// | ) == '2' +// |) +// """.trimMargin() +// ) +// executeActionStep = usesSelf( +// name = "Install default absent tool", +// action = executeAction.copy( +// additionalPackages = listOf(expr("matrix.distribution.default-absent-tool")), +// _customInputs = emptyMap() +// ), +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// condition = """ +// |(matrix.distribution.user-id != '${kali.userId}') +// ||| ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// |) +// """.trimMargin() +// ) +// runAfterSuccess( +// name = "Test - ${expr("matrix.distribution.default-absent-tool")} should be installed", +// command = "${expr("matrix.distribution.default-absent-tool")} --version", +// // part of work-around for https://bugs.kali.org/view.php?id=8921 +// conditionTransformer = { +// """ +// |( +// ${it.prependIndent("| ")} +// |) +// |&& ( +// | (matrix.distribution.user-id != '${kali.userId}') +// | || ( +// | ( +// ${getWslVersionExpression(kali).prependIndent("| ")} +// | ) == '2' +// | ) +// |) +// """.trimMargin() +// } +// ) +// executeActionStep = usesSelfAfterSuccess( +// name = "Execute action for ${expr("matrix.distribution2.user-id")}", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distribution2.user-id")), +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// verifyInstalledDistribution( +// name = """Test - "${expr("matrix.distribution2.user-id")}" should be the default distribution after installation""", +// expectedPatternExpression = "matrix.distribution2.match-pattern" +// ) +// executeActionStep = usesSelfAfterSuccess( +// name = "Re-execute action", +// action = executeAction.copy( +// _customInputs = emptyMap() +// ) +// ) +// verifyInstalledDistribution( +// name = """Test - "${expr("matrix.distribution2.user-id")}" should still be the default distribution after re-running for "${expr("matrix.distribution.user-id")}"""", +// expectedPatternExpression = "matrix.distribution2.match-pattern" +// ) +// executeActionStep = usesSelfAfterSuccess( +// name = "Set as default", +// action = executeAction.copy( +// setAsDefault = true, +// _customInputs = emptyMap() +// ) +// ) +// verifyInstalledDistribution( +// name = """Test - "${expr("matrix.distribution.user-id")}" should be the default distribution after re-running with set-as-default true""" +// ) +// } +// +// testJob( +// id = "test_distribution_specific_wsl_bash_scripts", +// name = "Test distribution specific wsl-bash scripts on ${expr("matrix.environment")} (without ${expr("matrix.distributions.incompatibleUbuntu")})", +// _customArguments = mapOf( +// "strategy" to mapOf( +// "fail-fast" to false, +// "matrix" to mapOf( +// "environment" to environments, +// // ubuntu2004 and ubuntu2204 currently have the same wsl-id +// // so their distribution specific wsl_bash scripts will clash +// // and thus cannot be tested together +// "distributions" to listOf(ubuntu2204, ubuntu2004) +// .map { incompatibleUbuntu -> +// distributions +// .filter { it != incompatibleUbuntu.asMap } +// .mapIndexed, Pair> { i, distribution -> +// "distribution${i + 1}" to distribution +// } +// .toMutableList() +// .apply { +// add(0, "incompatibleUbuntu" to incompatibleUbuntu.userId) +// } +// .toMap() +// } +// ) +// ) +// ) +// ) { +// (1 until distributions.size) +// .associateWith { +// usesSelf( +// name = "Execute action for ${expr("matrix.distributions.distribution$it.user-id")}", +// action = SetupWsl( +// distribution = SetupWsl.Distribution.Custom(expr("matrix.distributions.distribution$it.user-id")), +// additionalPackages = if (it == 2) listOf("bash") else null, +// setAsDefault = if (it >= 3) false else null, +// _customInputs = mapOf( +// "wsl-version" to "1" +// ) +// ) +// ) +// } +// .forEach { (i, localExecuteActionStep) -> +// executeActionStep = localExecuteActionStep +// verifyInstalledDistribution( +// name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", +// conditionTransformer = if (distributions[i] == ubuntu2004.asMap) { +// { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2004, i) } +// } else { +// { it } +// }, +// // the formula adds 1 to the indices from ubuntu2004 on +// // to mitigate the double entry for the previous index +// shell = Shell.Custom("wsl-bash_${distributions[min(1, i / (distributions.indexOf(ubuntu2004.asMap) + 1)) + i - 1]["user-id"]} {0}"), +// expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern" +// ) +// if (distributions[i] == ubuntu2004.asMap) { +// verifyInstalledDistribution( +// name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution", +// conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(ubuntu2204, i) }, +// shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"), +// expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern" +// ) +// } +// } +// } } fun JobBuilder<*>.commonTests() { diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7742c65a..489319e8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,17 +1,3 @@ -# 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. -# You may obtain a copy of the License at -# -# http://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. - # This file was generated using Kotlin DSL (.github/workflows/test.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 @@ -74,87 +60,6 @@ jobs: action.yml build/distributions/ key: '${{ github.run_id }}' - test_invalid_distribution: - name: 'Test "${{ matrix.distribution.label }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - user-id: 'invalid' - label: 'invalid' - - user-id: '' - label: '' - - user-id: null - label: 'null' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - continue-on-error: true - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-version: '1' - - id: 'step-2' - name: 'Test - action should fail if an invalid distribution is given' - shell: 'cmd' - run: 'if ''${{ steps.step-1.outcome }}'' NEQ ''failure'' exit 1' - test_invalid_wsl_version: - name: 'Test requesting WSL version ${{ matrix.wsl-version }} on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - wsl-version: - - '-1' - - '0' - include: - - environment: 'windows-2019' - wsl-version: '2' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - continue-on-error: true - uses: './' - with: - distribution: 'Debian' - wsl-version: '${{ matrix.wsl-version }}' - - id: 'step-2' - name: 'Test - action should fail if an invalid WSL version is given' - shell: 'cmd' - run: 'if ''${{ steps.step-1.outcome }}'' NEQ ''failure'' exit 1' test_default_distribution: name: 'Test default distribution on ${{ matrix.environment }}' runs-on: '${{ matrix.environment }}' @@ -167,7 +72,7 @@ jobs: environment: - 'windows-2019' - 'windows-2022' - - 'windows-latest' + - 'windows-2025' distribution: - wsl-id: 'Debian' user-id: 'Debian' @@ -360,1860 +265,6 @@ jobs: if: |- always() && (steps.step-1.outcome == 'success') - test: - name: 'Test "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - use-cache: 'false' - wsl-version: |- - ${{ ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' }} - - id: 'step-2' - name: 'Test - wsl-bash should fail if bash is not present by default (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: ':' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-3' - name: 'Test - wsl-bash should fail if bash is not present by default (verification)' - run: 'wsl sh -euc "[ ''${{ steps.step-2.outcome }}'' = ''failure'' ]"' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-4' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-1.outputs.wsl-shell-wrapper-path }}"' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-5' - name: 'Install Bash on Alpine' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: 'bash' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-6' - name: 'Test - wsl-bash should be available as custom shell' - shell: 'wsl-bash {0}' - run: ':' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-7' - name: 'Test - wsl-bash should fail if the script fails (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: 'false' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-8' - name: 'Test - wsl-bash should fail if the script fails (verification)' - shell: 'cmd' - run: 'IF ''${{ steps.step-7.outcome }}'' NEQ ''failure'' EXIT /B 1' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-9' - name: 'Test - wsl-bash should fail if one of the commands fails (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: |- - false - : - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-10' - name: 'Test - wsl-bash should fail if one of the commands fails (verification)' - shell: 'wsl-bash {0}' - run: '[ ''${{ steps.step-9.outcome }}'' == ''failure'' ] || exit 1' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-11' - name: 'Test - wsl-bash should fail if an undefined variable is used (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: '$foo' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-12' - name: 'Test - wsl-bash should fail if an undefined variable is used (verification)' - shell: 'wsl-bash {0}' - run: '[ ''${{ steps.step-11.outcome }}'' == ''failure'' ]' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-13' - name: 'Test - wsl-bash should fail if any command in a pipe fails (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: 'false | true' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-14' - name: 'Test - wsl-bash should fail if any command in a pipe fails (verification)' - shell: 'wsl-bash {0}' - run: '[ ''${{ steps.step-13.outcome }}'' == ''failure'' ]' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-15' - name: 'Test - the default distribution should be correct' - shell: 'wsl-bash {0}' - run: |- - cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8) - [[ "$(cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8))" == *${{ matrix.distribution.wsl-id }}\ \(Default\)* ]] - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-16' - name: 'Test - wsl-bash should use the correct distribution' - shell: 'wsl-bash {0}' - run: |- - 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) - [[ "$(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-1.outcome == 'success') - - id: 'step-17' - name: 'Test - multi-line commands should not be disturbed by CRLF line endings' - shell: 'wsl-bash {0}' - run: |- - : # this comment catches the CR if present - ! grep -q $'\r' "$0" # this comment catches the CR if present - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-18' - name: 'Test - ${{ matrix.distribution.default-absent-tool }} should not be installed by default (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: '${{ matrix.distribution.default-absent-tool }} --version' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-19' - name: 'Test - ${{ matrix.distribution.default-absent-tool }} should not be installed by default (verification)' - shell: 'wsl-bash {0}' - run: '[ ''${{ steps.step-18.outcome }}'' == ''failure'' ]' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-20' - name: 'Test - bash should be installed by default' - shell: 'wsl-bash {0}' - run: 'bash -c true' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-21' - name: 'Test - sh should be installed by default' - shell: 'wsl-bash {0}' - run: 'sh -c true' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-22' - name: 'Test - wsl-sh should not be present (provocation)' - continue-on-error: true - shell: 'wsl-sh {0}' - run: ':' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-23' - name: 'Test - wsl-sh should not be present (verification)' - shell: 'wsl-bash {0}' - run: '[ ''${{ steps.step-22.outcome }}'' == ''failure'' ]' - if: |- - always() - && (steps.step-1.outcome == 'success') - id: 'step-24' - name: 'Add wsl-sh wrapper' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-shell-command: 'sh -eu' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-25' - name: 'Test - wsl-sh should be present' - shell: 'wsl-sh {0}' - run: ':' - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-26' - name: 'Test - wsl-bash should use bash' - shell: 'wsl-bash {0}' - run: |- - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-27' - name: 'Test - wsl-sh should use sh' - shell: 'wsl-sh {0}' - run: |- - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" = 'sh' ] - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-28' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-1.outputs.wsl-shell-wrapper-path }}"' - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-29' - name: 'Test - wsl-bash should not be present (provocation)' - continue-on-error: true - shell: 'wsl-bash {0}' - run: ':' - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-30' - name: 'Test - wsl-bash should not be present (verification)' - shell: 'wsl-sh {0}' - run: '[ ''${{ steps.step-29.outcome }}'' = ''failure'' ]' - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-31' - name: 'Re-add wsl-bash wrapper' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - if: |- - always() - && (steps.step-24.outcome == 'success') - - id: 'step-32' - name: 'Test - wsl-bash should be present' - shell: 'wsl-bash {0}' - run: ':' - if: |- - always() - && (steps.step-31.outcome == 'success') - - id: 'step-33' - name: 'Test - wsl-bash should use bash' - shell: 'wsl-bash {0}' - run: |- - ps -o pid='' -o comm='' | grep "^\s\+$$\s\+" | grep -o '\S\+$' - [ "$(ps -o pid='' -o comm='' 2>/dev/null | grep "^\s\+$$\s\+" | grep -o '\S\+$')" == 'bash' ] - if: |- - always() - && (steps.step-31.outcome == 'success') - - id: 'step-34' - name: 'Test - wsl-bash should use root as default user' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'root' ] - if: |- - always() - && (steps.step-31.outcome == 'success') - - id: 'step-35' - name: 'Add user test' - shell: 'wsl-bash {0}' - run: 'useradd -m -p 4qBD5NWD3IkbU test' - if: |- - always() - && (steps.step-31.outcome == 'success') - - id: 'step-36' - name: 'Set wsl-bash wrapper to use user test by default' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: 'sudo' - wsl-shell-command: 'bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\' - if: |- - ( - always() - && (steps.step-31.outcome == 'success') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - - id: 'step-37' - name: 'Test - wsl-bash should use test as default user' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'test' ] - if: |- - ( - always() - && (steps.step-36.outcome == 'success') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - - id: 'step-38' - name: 'Set wsl-bash wrapper to use user test by default with inline script usage' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-shell-command: 'bash -c "sudo -u test bash --noprofile --norc -euo pipefail ''{0}''"' - if: |- - ( - always() - && (steps.step-36.outcome == 'success') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - - id: 'step-39' - name: 'Test - wsl-bash should use test as default user with inline script usage' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'test' ] - if: |- - always() - && (steps.step-38.outcome == 'success') - - id: 'step-40' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-38.outputs.wsl-shell-wrapper-path }}"' - if: |- - always() - && (steps.step-38.outcome == 'success') - - id: 'step-41' - name: 'Set wsl-bash wrapper to use default user by default' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - if: |- - always() - && (steps.step-38.outcome == 'success') - - id: 'step-42' - name: 'Test - wsl-bash should use root as default user' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'root' ] - if: |- - always() - && (steps.step-41.outcome == 'success') - - id: 'step-43' - name: 'Test - test user does already exist' - shell: 'wsl-bash {0}' - run: 'id -u test' - if: |- - always() - && (steps.step-41.outcome == 'success') - - id: 'step-44' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-41.outputs.wsl-shell-wrapper-path }}"' - if: |- - always() - && (steps.step-41.outcome == 'success') - - id: 'step-45' - name: 'Set wsl-bash wrapper to use existing user test by default with extra parameter' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-shell-user: 'test' - if: |- - always() - && (steps.step-41.outcome == 'success') - - id: 'step-46' - name: 'Test - wsl-bash should use existing user test as default user with extra parameter' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'test' ] - if: |- - always() - && (steps.step-45.outcome == 'success') - - id: 'step-47' - name: 'Test - test2 user does not exist' - shell: 'wsl-bash {0}' - run: '! id -u test2' - if: |- - always() - && (steps.step-45.outcome == 'success') - - id: 'step-48' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-45.outputs.wsl-shell-wrapper-path }}"' - if: |- - always() - && (steps.step-45.outcome == 'success') - - id: 'step-49' - name: 'Set wsl-bash wrapper to use non-existing user test2 by default with extra parameter' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-shell-user: 'test2' - if: |- - always() - && (steps.step-45.outcome == 'success') - - id: 'step-50' - name: 'Test - wsl-bash should use auto-generated user test2 as default user' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'test2' ] - if: |- - always() - && (steps.step-49.outcome == 'success') - - id: 'step-51' - name: 'Test - wsl-bash should use ad-hoc user test' - shell: 'wsl-bash -u test {0}' - run: |- - whoami - [ "$(whoami)" == 'test' ] - if: |- - always() - && (steps.step-49.outcome == 'success') - - id: 'step-52' - name: 'Test - wsl-bash should use ad-hoc user root' - shell: 'wsl-bash -u root {0}' - run: |- - whoami - [ "$(whoami)" == 'root' ] - if: |- - always() - && (steps.step-49.outcome == 'success') - - id: 'step-53' - name: 'Make a no-op execution of the action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - if: |- - always() - && (steps.step-49.outcome == 'success') - - id: 'step-54' - name: 'Test - wsl-bash should still use test2 as default user' - shell: 'wsl-bash {0}' - run: |- - whoami - [ "$(whoami)" == 'test2' ] - if: |- - always() - && (steps.step-53.outcome == 'success') - test_wsl-conf_on_initial_execution: - name: 'Test /etc/wsl.conf handling on initial execution for "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-conf: |- - [automount] - options = uid=1000 - wsl-version: '1' - - id: 'step-2' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-1.outputs.wsl-shell-wrapper-path }}"' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-3' - name: 'Install Bash on Alpine' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: 'bash' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-4' - name: 'Test - /etc/wsl.conf should exist' - shell: 'wsl-bash {0}' - run: |- - [ -f /etc/wsl.conf ] - cat /etc/wsl.conf - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-5' - name: 'Test - /mnt/c should be mounted with uid 1000' - shell: 'wsl-bash {0}' - run: |- - ls -alh /mnt - [[ "$(stat -c %u /mnt/c)" == 1000 ]] - if: |- - always() - && (steps.step-1.outcome == 'success') - test_wsl-conf_on_subsequent_execution: - name: 'Test /etc/wsl.conf handling on subsequent execution for "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-version: '1' - - id: 'step-2' - name: 'Delete wsl-bash' - shell: 'cmd' - run: 'DEL /F "${{ steps.step-1.outputs.wsl-shell-wrapper-path }}"' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-3' - name: 'Install Bash on Alpine' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: 'bash' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id == 'Alpine') - - id: 'step-4' - name: 'Test - /etc/wsl.conf should not exist' - shell: 'wsl-bash {0}' - run: '[ ! -f /etc/wsl.conf ] || { cat /etc/wsl.conf; false; }' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.distribution.user-id != 'Ubuntu-24.04') - - id: 'step-5' - name: 'Test - C: should be mounted at /mnt/c' - shell: 'wsl-bash {0}' - run: |- - mount - mount | grep 'C:.* on /mnt/c' - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-6' - name: 'Test - /mnt/c should be mounted with uid 0' - shell: 'wsl-bash {0}' - run: |- - ls -alh /mnt - [[ "$(stat -c %u /mnt/c)" == 0 ]] - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-7' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - wsl-conf: |- - [automount] - root = / - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-8' - name: 'Test - /etc/wsl.conf should exist' - shell: 'wsl-bash {0}' - run: |- - [ -f /etc/wsl.conf ] - cat /etc/wsl.conf - if: |- - always() - && (steps.step-7.outcome == 'success') - - id: 'step-9' - name: 'Test - C: should be mounted at /c' - shell: 'wsl-bash {0}' - run: |- - mount - mount | grep 'C:.* on /c' - if: |- - always() - && (steps.step-7.outcome == 'success') - test_additional_packages: - name: 'Test additional packages for "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: '${{ matrix.distribution.default-absent-tool }} bash' - wsl-version: |- - ${{ ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' }} - if: |- - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - - id: 'step-2' - 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-1.outcome == 'success') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - - id: 'step-3' - name: 'Test - bash should be installed' - shell: 'wsl-bash {0}' - run: 'bash -c true' - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - test_installation_on_wsl_version: - name: 'Test installation on WSLv${{ matrix.wsl-version }} for "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - wsl-version: - - 1 - - 2 - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: |- - ${{ (matrix.distribution.user-id == 'Alpine') - && 'bash' - || '' }} - wsl-version: '${{ matrix.wsl-version }}' - - id: 'step-2' - name: 'Test - distribution should be running on WSLv${{ matrix.wsl-version }}' - shell: 'wsl-bash {0}' - run: |- - cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) - [[ "$(cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8))" == *${{ matrix.distribution.wsl-id }}*\ ${{ matrix.wsl-version }}* ]] - if: |- - always() - && (steps.step-1.outcome == 'success') - test_switching_wsl_version_for_different_distributions: - name: 'Test switching WSL version for different distributions on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2022' - - 'windows-latest' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: 'Debian' - wsl-version: '1' - - id: 'step-2' - name: 'Execute action' - uses: './' - with: - distribution: 'Ubuntu-16.04' - wsl-version: '2' - - id: 'step-3' - name: 'Execute action' - uses: './' - with: - distribution: 'Ubuntu-18.04' - wsl-version: '1' - - id: 'step-4' - name: 'Test - distributions should be running on their respective WSL version' - shell: 'wsl-bash {0}' - run: |- - cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) | sort -u - [[ "$(cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) | sort -u)" == *Debian*\ 1*Ubuntu-16.04*\ 2*Ubuntu-18.04*\ 1* ]] - if: |- - always() - && (steps.step-3.outcome == 'success') - test_default_wsl_version: - name: 'Test default WSL version for "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: |- - ${{ (matrix.distribution.user-id == 'Alpine') - && 'bash' - || '' }} - - id: 'step-2' - name: 'Test - default WSL version should be WSLv2' - shell: 'wsl-bash {0}' - run: |- - cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8) - [[ "$(cat <(wsl.exe --list --verbose || true) <(wsl.exe --list --verbose || true | iconv -f UTF-16LE -t UTF-8))" == *${{ matrix.distribution.wsl-id }}*\ 2* ]] - if: |- - ( - always() - && (steps.step-1.outcome == 'success') - ) - && (matrix.environment != 'windows-2019') - test_multiple_usage_with_different_distributions: - name: 'Test multiple usage with different distributions ("${{ matrix.distributions.distribution1.user-id }}" / "${{ matrix.distributions.distribution2.user-id }}" / "${{ matrix.distributions.distribution3.user-id }}") on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distributions: - - distribution1: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - distribution1: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - distribution1: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - distribution1: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - distribution1: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - distribution1: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action for ${{ matrix.distributions.distribution1.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution1.user-id }}' - wsl-version: '1' - - id: 'step-2' - name: 'Execute action for ${{ matrix.distributions.distribution2.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution2.user-id }}' - wsl-version: '1' - - id: 'step-3' - name: 'Execute action for ${{ matrix.distributions.distribution3.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution3.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-4' - name: 'Execute action for ${{ matrix.distributions.distribution1.user-id }} again' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution1.user-id }}' - - id: 'step-5' - name: 'Test - the default distribution should be the last installed distribution with set-as-default true' - shell: 'wsl-bash {0}' - run: |- - cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8) - [[ "$(cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8))" == *${{ matrix.distributions.distribution2.wsl-id }}\ \(Default\)* ]] - if: |- - always() - && (steps.step-4.outcome == 'success') - - id: 'step-6' - name: 'Test - wsl-bash should use the last installed distribution with set-as-default true' - shell: 'wsl-bash {0}' - run: |- - 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) - [[ "$(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.distributions.distribution2.match-pattern }} ]] - if: |- - always() - && (steps.step-4.outcome == 'success') - test_multiple_usage_with_same_distribution: - name: 'Test multiple usage with "${{ matrix.distribution.user-id }}" distribution on ${{ matrix.environment }}' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distribution: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Alpine' - 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*' - default-absent-tool: 'which' - - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - distribution2: - - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - exclude: - - environment: 'windows-2019' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - environment: 'windows-2022' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - - environment: 'windows-latest' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - include: - - environment: 'windows-2019' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - environment: 'windows-2022' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - - environment: 'windows-latest' - distribution: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: |- - ${{ ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - && 'bash' - || '' }} - wsl-version: |- - ${{ ( - ( - (matrix.distribution.user-id == 'kali-linux') - || (matrix.distribution.user-id == 'Ubuntu-24.04') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' }} - - id: 'step-2' - name: 'Update distribution' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - update: 'true' - if: |- - ( - (matrix.distribution.user-id != 'kali-linux') - && (matrix.distribution.user-id != 'Ubuntu-24.04') - ) - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - || (matrix.distribution.user-id == 'Ubuntu-24.04') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - - id: 'step-3' - name: 'Install default absent tool' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - additional-packages: '${{ matrix.distribution.default-absent-tool }}' - if: |- - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - - id: 'step-4' - 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') - ) - && ( - (matrix.distribution.user-id != 'kali-linux') - || ( - ( - ( - ( - (matrix.distribution.user-id == 'kali-linux') - ) - && (matrix.environment != 'windows-2019') - ) - && '2' - || '1' - ) == '2' - ) - ) - - id: 'step-5' - name: 'Execute action for ${{ matrix.distribution2.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distribution2.user-id }}' - wsl-version: '1' - if: |- - always() - && (steps.step-3.outcome == 'success') - - id: 'step-6' - name: 'Test - "${{ matrix.distribution2.user-id }}" should be the default distribution after installation' - shell: 'wsl-bash {0}' - run: |- - 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) - [[ "$(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' - name: 'Re-execute action' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - if: |- - always() - && (steps.step-5.outcome == 'success') - - id: 'step-8' - 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: |- - 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) - [[ "$(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' - name: 'Set as default' - uses: './' - with: - distribution: '${{ matrix.distribution.user-id }}' - set-as-default: 'true' - if: |- - always() - && (steps.step-7.outcome == 'success') - - id: 'step-10' - name: 'Test - "${{ matrix.distribution.user-id }}" should be the default distribution after re-running with set-as-default true' - shell: 'wsl-bash {0}' - run: |- - 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) - [[ "$(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') - test_distribution_specific_wsl_bash_scripts: - name: 'Test distribution specific wsl-bash scripts on ${{ matrix.environment }} (without ${{ matrix.distributions.incompatibleUbuntu }})' - runs-on: '${{ matrix.environment }}' - needs: - - 'build' - - 'check_yaml_consistency' - strategy: - fail-fast: false - matrix: - environment: - - 'windows-2019' - - 'windows-2022' - - 'windows-latest' - distributions: - - incompatibleUbuntu: 'Ubuntu-22.04' - distribution1: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Alpine' - user-id: 'Alpine' - match-pattern: '*Alpine*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'kali-linux' - user-id: 'kali-linux' - match-pattern: '*Kali*' - default-absent-tool: 'dos2unix' - distribution4: - wsl-id: 'openSUSE-Leap-15.2' - user-id: 'openSUSE-Leap-15.2' - match-pattern: '*openSUSE*Leap*15.2*' - default-absent-tool: 'which' - distribution5: - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - distribution6: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-20.04' - match-pattern: '*Ubuntu*20.04*' - default-absent-tool: 'dos2unix' - distribution7: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution8: - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - - incompatibleUbuntu: 'Ubuntu-20.04' - distribution1: - wsl-id: 'Debian' - user-id: 'Debian' - match-pattern: '*Debian*' - default-absent-tool: 'dos2unix' - distribution2: - wsl-id: 'Alpine' - user-id: 'Alpine' - match-pattern: '*Alpine*' - default-absent-tool: 'dos2unix' - distribution3: - wsl-id: 'kali-linux' - user-id: 'kali-linux' - match-pattern: '*Kali*' - default-absent-tool: 'dos2unix' - distribution4: - wsl-id: 'openSUSE-Leap-15.2' - user-id: 'openSUSE-Leap-15.2' - match-pattern: '*openSUSE*Leap*15.2*' - default-absent-tool: 'which' - distribution5: - wsl-id: 'Ubuntu-24.04' - user-id: 'Ubuntu-24.04' - match-pattern: '*Ubuntu*24.04*' - default-absent-tool: 'dos2unix' - distribution6: - wsl-id: 'Ubuntu' - user-id: 'Ubuntu-22.04' - match-pattern: '*Ubuntu*22.04*' - default-absent-tool: 'dos2unix' - distribution7: - wsl-id: 'Ubuntu-18.04' - user-id: 'Ubuntu-18.04' - match-pattern: '*Ubuntu*18.04*' - default-absent-tool: 'dos2unix' - distribution8: - wsl-id: 'Ubuntu-16.04' - user-id: 'Ubuntu-16.04' - match-pattern: '*Ubuntu*16.04*' - default-absent-tool: 'dos2unix' - steps: - - id: 'step-0' - name: 'Restore built artifacts from cache' - uses: 'actions/cache/restore@v4' - with: - path: |- - action.yml - build/distributions/ - key: '${{ github.run_id }}' - fail-on-cache-miss: 'true' - - id: 'step-1' - name: 'Execute action for ${{ matrix.distributions.distribution1.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution1.user-id }}' - wsl-version: '1' - - id: 'step-2' - name: 'Execute action for ${{ matrix.distributions.distribution2.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution2.user-id }}' - additional-packages: 'bash' - wsl-version: '1' - - id: 'step-3' - name: 'Execute action for ${{ matrix.distributions.distribution3.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution3.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-4' - name: 'Execute action for ${{ matrix.distributions.distribution4.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution4.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-5' - name: 'Execute action for ${{ matrix.distributions.distribution5.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution5.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-6' - name: 'Execute action for ${{ matrix.distributions.distribution6.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution6.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-7' - name: 'Execute action for ${{ matrix.distributions.distribution7.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution7.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-8' - name: 'Execute action for ${{ matrix.distributions.distribution8.user-id }}' - uses: './' - with: - distribution: '${{ matrix.distributions.distribution8.user-id }}' - set-as-default: 'false' - wsl-version: '1' - - id: 'step-9' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution1.user-id }} should use the correct distribution' - shell: 'wsl-bash_Debian {0}' - run: |- - 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) - [[ "$(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.distributions.distribution1.match-pattern }} ]] - if: |- - always() - && (steps.step-1.outcome == 'success') - - id: 'step-10' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution2.user-id }} should use the correct distribution' - shell: 'wsl-bash_Alpine {0}' - run: |- - 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) - [[ "$(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.distributions.distribution2.match-pattern }} ]] - if: |- - always() - && (steps.step-2.outcome == 'success') - - id: 'step-11' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution3.user-id }} should use the correct distribution' - shell: 'wsl-bash_kali-linux {0}' - run: |- - 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) - [[ "$(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.distributions.distribution3.match-pattern }} ]] - if: |- - always() - && (steps.step-3.outcome == 'success') - - id: 'step-12' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution4.user-id }} should use the correct distribution' - shell: 'wsl-bash_openSUSE-Leap-15.2 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution4.match-pattern }} ]] - if: |- - always() - && (steps.step-4.outcome == 'success') - - id: 'step-13' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution5.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-24.04 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution5.match-pattern }} ]] - if: |- - always() - && (steps.step-5.outcome == 'success') - - id: 'step-14' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution6.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-22.04 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution6.match-pattern }} ]] - if: |- - ( - always() - && (steps.step-6.outcome == 'success') - ) - && (matrix.distributions.distribution6.user-id != 'Ubuntu-20.04') - - id: 'step-15' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution6.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-20.04 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution6.match-pattern }} ]] - if: |- - ( - always() - && (steps.step-6.outcome == 'success') - ) - && (matrix.distributions.distribution6.user-id != 'Ubuntu-22.04') - - id: 'step-16' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution7.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-18.04 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution7.match-pattern }} ]] - if: |- - always() - && (steps.step-7.outcome == 'success') - - id: 'step-17' - name: 'Test - wsl-bash_${{ matrix.distributions.distribution8.user-id }} should use the correct distribution' - shell: 'wsl-bash_Ubuntu-16.04 {0}' - run: |- - 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) - [[ "$(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.distributions.distribution8.match-pattern }} ]] - if: |- - always() - && (steps.step-8.outcome == 'success') + uses: 'mxschmitt/action-tmate@v3' + if: '${{ always() }}' diff --git a/src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt b/src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt index b89a785d..f2daaa7e 100644 --- a/src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt +++ b/src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt @@ -94,7 +94,7 @@ suspend fun wslOutput(vararg args: String): String { stdoutBuilder.append(stdoutBuilderUtf16Le) stdoutBuilder.append(stderrBuilder) stdoutBuilder.append(stderrBuilderUtf16Le) - return stdoutBuilder.toString() + return stdoutBuilder.toString().also { warning(it) } } val wslHelp = GlobalScope.async(start = LAZY) {