Skip to content

Commit

Permalink
Refactor test workflow script
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed May 27, 2024
1 parent e5717e2 commit 00dc521
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ workflowWithCopyright(
verifyInstalledDistribution(
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
conditionTransformer = if (distributions[i] == ubuntu2004) {
{ executeActionStep.getSuccessNotOnUbuntu2004Condition(i) }
{ executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-20.04") }
} else {
{ it }
},
Expand All @@ -849,7 +849,7 @@ workflowWithCopyright(
if (distributions[i] == ubuntu2004) {
verifyInstalledDistribution(
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
conditionTransformer = { executeActionStep.getSuccessNotOnUbuntu2204Condition(i) },
conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-22.04") },
shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"),
expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern"
)
Expand Down Expand Up @@ -1057,14 +1057,8 @@ val Step.successOnAlpineCondition
&& (matrix.distribution.user-id == 'Alpine')
""".trimIndent()

fun Step.getSuccessNotOnUbuntu2004Condition(i: Int) = """
fun Step.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """
always()
&& (${outcome.eq(Success)})
&& (matrix.distributions.distribution$i.user-id != 'Ubuntu-20.04')
""".trimIndent()

fun Step.getSuccessNotOnUbuntu2204Condition(i: Int) = """
always()
&& ($outcome == 'success')
&& (matrix.distributions.distribution$i.user-id != 'Ubuntu-22.04')
&& (matrix.distributions.distribution$i.user-id != '$distribution')
""".trimIndent()

0 comments on commit 00dc521

Please sign in to comment.