Skip to content

Commit b135bad

Browse files
committed
Do not try to install sudo on kali-linux due to a bug in systemd package
1 parent 942db88 commit b135bad

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

.github/workflows/test.main.kts

+21-7
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,24 @@ workflowWithCopyright(
412412
)
413413
executeActionStep = usesSelfAfterSuccess(
414414
name = "Set wsl-bash wrapper to use user test by default",
415+
// part of work-around for https://bugs.kali.org/view.php?id=8921
416+
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
415417
action = executeAction.copy(
416418
additionalPackages = listOf("sudo"),
417419
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail "\"""
418420
)
419421
)
420422
verifyCommandResult(
421423
name = "Test - wsl-bash should use test as default user",
424+
// part of work-around for https://bugs.kali.org/view.php?id=8921
425+
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
422426
actualCommand = "whoami",
423427
expected = "test"
424428
)
425429
executeActionStep = usesSelfAfterSuccess(
426430
name = "Set wsl-bash wrapper to use user test by default with inline script usage",
431+
// part of work-around for https://bugs.kali.org/view.php?id=8921
432+
conditionTransformer = { executeActionStep.successNotOnKaliCondition },
427433
action = executeAction.copy(
428434
wslShellCommand = """bash -c "sudo -u test bash --noprofile --norc -euo pipefail '{0}'""""
429435
)
@@ -774,8 +780,8 @@ workflowWithCopyright(
774780
// work-around for https://bugs.kali.org/view.php?id=6672
775781
// and https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555
776782
condition = """
777-
(matrix.distribution.user-id != 'kali-linux')
778-
&& (matrix.distribution.user-id != 'Ubuntu-24.04')
783+
(matrix.distribution.user-id != '${kali["user-id"]}')
784+
&& (matrix.distribution.user-id != '${ubuntu2404["user-id"]}')
779785
""".trimIndent()
780786
)
781787
executeActionStep = usesSelf(
@@ -861,7 +867,7 @@ workflowWithCopyright(
861867
verifyInstalledDistribution(
862868
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
863869
conditionTransformer = if (distributions[i] == ubuntu2004) {
864-
{ executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-20.04") }
870+
{ executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2004["user-id"]!!) }
865871
} else {
866872
{ it }
867873
},
@@ -873,7 +879,7 @@ workflowWithCopyright(
873879
if (distributions[i] == ubuntu2004) {
874880
verifyInstalledDistribution(
875881
name = "Test - wsl-bash_${expr("matrix.distributions.distribution$i.user-id")} should use the correct distribution",
876-
conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, "Ubuntu-22.04") },
882+
conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2204["user-id"]!!) },
877883
shell = Shell.Custom("wsl-bash_${distributions[i]["user-id"]} {0}"),
878884
expectedPatternExpression = "matrix.distributions.distribution$i.match-pattern"
879885
)
@@ -941,11 +947,12 @@ fun JobBuilder<*>.commonTests() {
941947

942948
fun JobBuilder<*>.usesSelfAfterSuccess(
943949
name: String = "Execute action",
950+
conditionTransformer: (String) -> String = { it },
944951
action: SetupWsl
945952
) = usesSelf(
946953
name = name,
947954
action = action,
948-
condition = executeActionStep.successCondition
955+
condition = conditionTransformer(executeActionStep.successCondition).trimIndent()
949956
)
950957

951958
fun JobBuilder<*>.usesSelf(
@@ -1078,14 +1085,21 @@ val Step<*>.successOnAlpineCondition
10781085
get() = """
10791086
always()
10801087
&& (${outcome.eq(Success)})
1081-
&& (matrix.distribution.user-id == 'Alpine')
1088+
&& (matrix.distribution.user-id == '${alpine["user-id"]}')
1089+
""".trimIndent()
1090+
1091+
val Step<*>.successNotOnKaliCondition
1092+
get() = """
1093+
always()
1094+
&& (${outcome.eq(Success)})
1095+
&& (matrix.distribution.user-id != '${kali["user-id"]}')
10821096
""".trimIndent()
10831097

10841098
val Step<*>.successNotOnUbuntu2404Condition
10851099
get() = """
10861100
always()
10871101
&& (${outcome.eq(Success)})
1088-
&& (matrix.distribution.user-id != 'Ubuntu-24.04')
1102+
&& (matrix.distribution.user-id != '${ubuntu2404["user-id"]}')
10891103
""".trimIndent()
10901104

10911105
fun Step<*>.getSuccessNotOnDistributionCondition(i: Int, distribution: String) = """

.github/workflows/test.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ jobs:
664664
if: |-
665665
always()
666666
&& (steps.step-31.outcome == 'success')
667+
&& (matrix.distribution.user-id != 'kali-linux')
667668
- id: 'step-37'
668669
name: 'Test - wsl-bash should use test as default user'
669670
shell: 'wsl-bash {0}'
@@ -673,6 +674,7 @@ jobs:
673674
if: |-
674675
always()
675676
&& (steps.step-36.outcome == 'success')
677+
&& (matrix.distribution.user-id != 'kali-linux')
676678
- id: 'step-38'
677679
name: 'Set wsl-bash wrapper to use user test by default with inline script usage'
678680
uses: './'
@@ -682,6 +684,7 @@ jobs:
682684
if: |-
683685
always()
684686
&& (steps.step-36.outcome == 'success')
687+
&& (matrix.distribution.user-id != 'kali-linux')
685688
- id: 'step-39'
686689
name: 'Test - wsl-bash should use test as default user with inline script usage'
687690
shell: 'wsl-bash {0}'

0 commit comments

Comments
 (0)