Skip to content

Commit

Permalink
Use latest action API in test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jan 3, 2025
1 parent 37c005c commit 233ed8b
Showing 1 changed file with 43 additions and 68 deletions.
111 changes: 43 additions & 68 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@file:DependsOn("actions:checkout:v4")
@file:DependsOn("actions:setup-java:v4")
@file:DependsOn("burrunan:gradle-cache-action:v1")
@file:DependsOn("Vampire:setup-wsl:v3")
@file:DependsOn("Vampire:setup-wsl:RELEASE")

import io.github.typesafegithub.workflows.actions.actions.CacheRestore
import io.github.typesafegithub.workflows.actions.actions.CacheSave
Expand Down Expand Up @@ -157,9 +157,7 @@ workflowWithCopyright(

val executeAction = SetupWsl(
distribution = SetupWsl.Distribution.Custom(expr("matrix.distribution.user-id")),
_customInputs = mapOf(
"wsl-version" to "1"
)
wslVersion = 1
)

val build = job(
Expand Down Expand Up @@ -289,9 +287,8 @@ workflowWithCopyright(
executeActionStep = usesSelf(
action = executeAction.copy(
distribution = Debian,
_customInputs = mapOf(
"wsl-version" to expr("matrix.wsl-version")
)
wslVersion = null,
wslVersion_Untyped = expr("matrix.wsl-version")
),
continueOnError = true
)
Expand All @@ -318,9 +315,7 @@ workflowWithCopyright(
executeActionStep = usesSelf(
action = SetupWsl(
update = true,
_customInputs = mapOf(
"wsl-version" to "1"
)
wslVersion = 1
)
)
commonTests()
Expand Down Expand Up @@ -362,10 +357,9 @@ workflowWithCopyright(
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))
)
// part of work-around for https://bugs.kali.org/view.php?id=8921
wslVersion = null,
wslVersion_Untyped = expr(getWslVersionExpression(kali))
)
)
verifyFailure(
Expand All @@ -381,7 +375,7 @@ workflowWithCopyright(
name = "Install Bash on Alpine",
action = executeAction.copy(
additionalPackages = listOf("bash"),
_customInputs = emptyMap()
wslVersion = null
),
condition = executeActionStep.getSuccessOnDistributionCondition(alpine)
)
Expand All @@ -407,7 +401,7 @@ workflowWithCopyright(
name = "Add wsl-sh wrapper",
action = executeAction.copy(
wslShellCommand = "sh -eu",
_customInputs = emptyMap()
wslVersion = null
)
)
runAfterSuccess(
Expand Down Expand Up @@ -442,7 +436,7 @@ workflowWithCopyright(
executeActionStep = usesSelfAfterSuccess(
name = "Re-add wsl-bash wrapper",
action = executeAction.copy(
_customInputs = emptyMap()
wslVersion = null
)
)
runAfterSuccess(
Expand Down Expand Up @@ -485,7 +479,7 @@ workflowWithCopyright(
action = executeAction.copy(
additionalPackages = listOf("sudo"),
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\""",
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand Down Expand Up @@ -529,7 +523,7 @@ workflowWithCopyright(
},
action = executeAction.copy(
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'"""",
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand All @@ -541,7 +535,7 @@ workflowWithCopyright(
executeActionStep = usesSelfAfterSuccess(
name = "Set wsl-bash wrapper to use default user by default",
action = executeAction.copy(
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand All @@ -558,7 +552,7 @@ workflowWithCopyright(
name = "Set wsl-bash wrapper to use existing user test by default with extra parameter",
action = executeAction.copy(
wslShellUser = "test",
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand All @@ -575,7 +569,7 @@ workflowWithCopyright(
name = "Set wsl-bash wrapper to use non-existing user test2 by default with extra parameter",
action = executeAction.copy(
wslShellUser = "test2",
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand All @@ -598,7 +592,7 @@ workflowWithCopyright(
executeActionStep = usesSelfAfterSuccess(
name = "Make a no-op execution of the action",
action = executeAction.copy(
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand Down Expand Up @@ -634,7 +628,7 @@ workflowWithCopyright(
name = "Install Bash on Alpine",
action = executeAction.copy(
additionalPackages = listOf("bash"),
_customInputs = emptyMap()
wslVersion = null
),
condition = executeActionStep.getSuccessOnDistributionCondition(alpine)
)
Expand Down Expand Up @@ -675,7 +669,7 @@ workflowWithCopyright(
name = "Install Bash on Alpine",
action = executeAction.copy(
additionalPackages = listOf("bash"),
_customInputs = emptyMap()
wslVersion = null
),
condition = executeActionStep.getSuccessOnDistributionCondition(alpine)
)
Expand Down Expand Up @@ -704,7 +698,7 @@ workflowWithCopyright(
[automount]
root = /
""".trimIndent(),
_customInputs = emptyMap()
wslVersion = null
)
)
runAfterSuccess(
Expand Down Expand Up @@ -742,10 +736,9 @@ workflowWithCopyright(
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
wslVersion = null,
wslVersion_Untyped = expr(getWslVersionExpression(kali))
),
// part of work-around for https://bugs.kali.org/view.php?id=8921
condition = """
Expand Down Expand Up @@ -824,9 +817,8 @@ workflowWithCopyright(
""".trimIndent()
)
),
_customInputs = mapOf(
"wsl-version" to expr("matrix.wsl-version")
)
wslVersion = null,
wslVersion_Untyped = expr("matrix.wsl-version")
)
)
verifyCommandResult(
Expand Down Expand Up @@ -855,25 +847,19 @@ workflowWithCopyright(
usesSelf(
action = executeAction.copy(
distribution = Debian,
_customInputs = mapOf(
"wsl-version" to "1"
)
wslVersion = 1
)
)
usesSelf(
action = executeAction.copy(
distribution = Ubuntu1604,
_customInputs = mapOf(
"wsl-version" to "2"
)
wslVersion = 2
)
)
executeActionStep = usesSelf(
action = executeAction.copy(
distribution = Ubuntu1804,
_customInputs = mapOf(
"wsl-version" to "1"
)
wslVersion = 1
)
)
verifyCommandResult(
Expand Down Expand Up @@ -912,7 +898,7 @@ workflowWithCopyright(
""".trimIndent()
)
),
_customInputs = emptyMap()
wslVersion = null
)
)
verifyCommandResult(
Expand Down Expand Up @@ -992,28 +978,22 @@ workflowWithCopyright(
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"
)
wslVersion = 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"
)
wslVersion = 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"
)
wslVersion = 1
)
)
executeActionStep = usesSelf(
Expand Down Expand Up @@ -1087,19 +1067,18 @@ workflowWithCopyright(
""".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))
)
// 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
wslVersion = null,
wslVersion_Untyped = expr(getWslVersionExpression(kali, ubuntu2404))
)
)
usesSelf(
name = "Update distribution",
action = executeAction.copy(
update = true,
_customInputs = emptyMap()
wslVersion = null
),
// part of work-around for https://bugs.kali.org/view.php?id=6672
// and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555
Expand All @@ -1119,7 +1098,7 @@ workflowWithCopyright(
name = "Install default absent tool",
action = executeAction.copy(
additionalPackages = listOf(expr("matrix.distribution.default-absent-tool")),
_customInputs = emptyMap()
wslVersion = null
),
// part of work-around for https://bugs.kali.org/view.php?id=8921
condition = """
Expand Down Expand Up @@ -1155,9 +1134,7 @@ workflowWithCopyright(
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"
)
wslVersion = 1
)
)
verifyInstalledDistribution(
Expand All @@ -1167,7 +1144,7 @@ workflowWithCopyright(
executeActionStep = usesSelfAfterSuccess(
name = "Re-execute action",
action = executeAction.copy(
_customInputs = emptyMap()
wslVersion = null
)
)
verifyInstalledDistribution(
Expand All @@ -1178,7 +1155,7 @@ workflowWithCopyright(
name = "Set as default",
action = executeAction.copy(
setAsDefault = true,
_customInputs = emptyMap()
wslVersion = null
)
)
verifyInstalledDistribution(
Expand Down Expand Up @@ -1222,9 +1199,7 @@ workflowWithCopyright(
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"
)
wslVersion = 1
)
)
}
Expand Down

0 comments on commit 233ed8b

Please sign in to comment.