Skip to content

Commit

Permalink
Do not try to install sudo on kali-linux due to a bug in systemd package
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Oct 17, 2024
1 parent 942db88 commit b135bad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,24 @@ workflowWithCopyright(
)
executeActionStep = usesSelfAfterSuccess(
name = "Set wsl-bash wrapper to use user test by default",
// part of work-around for https://bugs.kali.org/view.php?id=8921
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
action = executeAction.copy(
additionalPackages = listOf("sudo"),
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\"""
)
)
verifyCommandResult(
name = "Test - wsl-bash should use test as default user",
// part of work-around for https://bugs.kali.org/view.php?id=8921
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
actualCommand = "whoami",
expected = "test"
)
executeActionStep = usesSelfAfterSuccess(
name = "Set wsl-bash wrapper to use user test by default with inline script usage",
// part of work-around for https://bugs.kali.org/view.php?id=8921
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
action = executeAction.copy(
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'""""
)
Expand Down Expand Up @@ -774,8 +780,8 @@ workflowWithCopyright(
// work-around for https://bugs.kali.org/view.php?id=6672
// and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555
condition = """
(matrix.distribution.user-id != 'kali-linux')
&& (matrix.distribution.user-id != 'Ubuntu-24.04')
(matrix.distribution.user-id != '${kali["user-id"]}')
&& (matrix.distribution.user-id != '${ubuntu2404["user-id"]}')
""".trimIndent()
)
executeActionStep = usesSelf(
Expand Down Expand Up @@ -861,7 +867,7 @@ workflowWithCopyright(
verifyInstalledDistribution(
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
conditionTransformer = if (distributions[i] == ubuntu2004) {
{ executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-20.04") }
{ executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2004["user-id"]!!) }
} else {
{ it }
},
Expand All @@ -873,7 +879,7 @@ workflowWithCopyright(
if (distributions[i] == ubuntu2004) {
verifyInstalledDistribution(
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-22.04") },
conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2204["user-id"]!!) },
shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"),
expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern"
)
Expand Down Expand Up @@ -941,11 +947,12 @@ fun JobBuilder<*>.commonTests() {

fun JobBuilder<*>.usesSelfAfterSuccess(
name: String = "Execute action",
conditionTransformer: (String) -> String = { it },
action: SetupWsl
) = usesSelf(
name = name,
action = action,
condition = executeActionStep.successCondition
condition = conditionTransformer(executeActionStep.successCondition).trimIndent()
)

fun JobBuilder<*>.usesSelf(
Expand Down Expand Up @@ -1078,14 +1085,21 @@ val Step<*>.successOnAlpineCondition
get() = """
always()
&& (${outcome.eq(Success)})
&& (matrix.distribution.user-id == 'Alpine')
&& (matrix.distribution.user-id == '${alpine["user-id"]}')
""".trimIndent()

val Step<*>.successNotOnKaliCondition
get() = """
always()
&& (${outcome.eq(Success)})
&& (matrix.distribution.user-id != '${kali["user-id"]}')
""".trimIndent()

val Step<*>.successNotOnUbuntu2404Condition
get() = """
always()
&& (${outcome.eq(Success)})
&& (matrix.distribution.user-id != 'Ubuntu-24.04')
&& (matrix.distribution.user-id != '${ubuntu2404["user-id"]}')
""".trimIndent()

fun Step<*>.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ jobs:
if: |-
always()
&& (steps.step-31.outcome == 'success')
&& (matrix.distribution.user-id != 'kali-linux')
- id: 'step-37'
name: 'Test - wsl-bash should use test as default user'
shell: 'wsl-bash {0}'
Expand All @@ -673,6 +674,7 @@ jobs:
if: |-
always()
&& (steps.step-36.outcome == 'success')
&& (matrix.distribution.user-id != 'kali-linux')
- id: 'step-38'
name: 'Set wsl-bash wrapper to use user test by default with inline script usage'
uses: './'
Expand All @@ -682,6 +684,7 @@ jobs:
if: |-
always()
&& (steps.step-36.outcome == 'success')
&& (matrix.distribution.user-id != 'kali-linux')
- id: 'step-39'
name: 'Test - wsl-bash should use test as default user with inline script usage'
shell: 'wsl-bash {0}'
Expand Down

0 comments on commit b135bad

Please sign in to comment.