Skip to content

Commit e86ecc6

Browse files
committed
Add support for windows-2025 runner images (#65)
1 parent 10b7b9a commit e86ecc6

File tree

3 files changed

+82
-12
lines changed

3 files changed

+82
-12
lines changed

.github/workflows/test.main.kts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import kotlin.math.min
5656
val environments = listOf(
5757
"windows-2019",
5858
"windows-2022",
59+
"windows-2025",
5960
"windows-latest"
6061
)
6162

.github/workflows/test.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
environment:
8787
- 'windows-2019'
8888
- 'windows-2022'
89+
- 'windows-2025'
8990
- 'windows-latest'
9091
distribution:
9192
- user-id: 'invalid'
@@ -127,6 +128,7 @@ jobs:
127128
environment:
128129
- 'windows-2019'
129130
- 'windows-2022'
131+
- 'windows-2025'
130132
- 'windows-latest'
131133
wsl-version:
132134
- '-1'
@@ -167,6 +169,7 @@ jobs:
167169
environment:
168170
- 'windows-2019'
169171
- 'windows-2022'
172+
- 'windows-2025'
170173
- 'windows-latest'
171174
distribution:
172175
- wsl-id: 'Debian'
@@ -372,6 +375,7 @@ jobs:
372375
environment:
373376
- 'windows-2019'
374377
- 'windows-2022'
378+
- 'windows-2025'
375379
- 'windows-latest'
376380
distribution:
377381
- wsl-id: 'Debian'
@@ -936,6 +940,7 @@ jobs:
936940
environment:
937941
- 'windows-2019'
938942
- 'windows-2022'
943+
- 'windows-2025'
939944
- 'windows-latest'
940945
distribution:
941946
- wsl-id: 'Debian'
@@ -1045,6 +1050,7 @@ jobs:
10451050
environment:
10461051
- 'windows-2019'
10471052
- 'windows-2022'
1053+
- 'windows-2025'
10481054
- 'windows-latest'
10491055
distribution:
10501056
- wsl-id: 'Debian'
@@ -1190,6 +1196,7 @@ jobs:
11901196
environment:
11911197
- 'windows-2019'
11921198
- 'windows-2022'
1199+
- 'windows-2025'
11931200
- 'windows-latest'
11941201
distribution:
11951202
- wsl-id: 'Debian'
@@ -1326,6 +1333,7 @@ jobs:
13261333
matrix:
13271334
environment:
13281335
- 'windows-2022'
1336+
- 'windows-2025'
13291337
- 'windows-latest'
13301338
distribution:
13311339
- wsl-id: 'Debian'
@@ -1407,6 +1415,7 @@ jobs:
14071415
matrix:
14081416
environment:
14091417
- 'windows-2022'
1418+
- 'windows-2025'
14101419
- 'windows-latest'
14111420
steps:
14121421
- id: 'step-0'
@@ -1457,6 +1466,7 @@ jobs:
14571466
environment:
14581467
- 'windows-2019'
14591468
- 'windows-2022'
1469+
- 'windows-2025'
14601470
- 'windows-latest'
14611471
distribution:
14621472
- wsl-id: 'Debian'
@@ -1538,6 +1548,7 @@ jobs:
15381548
environment:
15391549
- 'windows-2019'
15401550
- 'windows-2022'
1551+
- 'windows-2025'
15411552
- 'windows-latest'
15421553
distributions:
15431554
- distribution1:
@@ -1694,6 +1705,7 @@ jobs:
16941705
environment:
16951706
- 'windows-2019'
16961707
- 'windows-2022'
1708+
- 'windows-2025'
16971709
- 'windows-latest'
16981710
distribution:
16991711
- wsl-id: 'Debian'
@@ -1760,6 +1772,17 @@ jobs:
17601772
user-id: 'Debian'
17611773
match-pattern: '*Debian*'
17621774
default-absent-tool: 'dos2unix'
1775+
- environment: 'windows-2025'
1776+
distribution:
1777+
wsl-id: 'Debian'
1778+
user-id: 'Debian'
1779+
match-pattern: '*Debian*'
1780+
default-absent-tool: 'dos2unix'
1781+
distribution2:
1782+
wsl-id: 'Debian'
1783+
user-id: 'Debian'
1784+
match-pattern: '*Debian*'
1785+
default-absent-tool: 'dos2unix'
17631786
- environment: 'windows-latest'
17641787
distribution:
17651788
wsl-id: 'Debian'
@@ -1794,6 +1817,17 @@ jobs:
17941817
user-id: 'Ubuntu-20.04'
17951818
match-pattern: '*Ubuntu*20.04*'
17961819
default-absent-tool: 'dos2unix'
1820+
- environment: 'windows-2025'
1821+
distribution:
1822+
wsl-id: 'Debian'
1823+
user-id: 'Debian'
1824+
match-pattern: '*Debian*'
1825+
default-absent-tool: 'dos2unix'
1826+
distribution2:
1827+
wsl-id: 'Ubuntu'
1828+
user-id: 'Ubuntu-20.04'
1829+
match-pattern: '*Ubuntu*20.04*'
1830+
default-absent-tool: 'dos2unix'
17971831
- environment: 'windows-latest'
17981832
distribution:
17991833
wsl-id: 'Debian'
@@ -1981,6 +2015,7 @@ jobs:
19812015
environment:
19822016
- 'windows-2019'
19832017
- 'windows-2022'
2018+
- 'windows-2025'
19842019
- 'windows-latest'
19852020
distributions:
19862021
- incompatibleUbuntu: 'Ubuntu-22.04'

src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt

+46-12
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ val wslHelp = GlobalScope.async(start = LAZY) {
101101
wslOutput("--help")
102102
}
103103

104-
val wslStatus = GlobalScope.async(start = LAZY) {
105-
wslOutput("--status")
106-
}
107-
108104
val distribution by lazy {
109105
val distributionId = getInput("distribution", InputOptions(required = true))
110106

@@ -371,22 +367,51 @@ suspend fun verifyWindowsEnvironment() {
371367
}
372368

373369
suspend fun installDistribution() {
370+
// on windows-2025 WSL is not installed at all currently, so install it without distribution
371+
// work-around for https://github.com/actions/runner-images/issues/11265
372+
if (wslOutput("--status").contains("is not installed")) {
373+
retry(5) {
374+
exec(
375+
commandLine = "wsl",
376+
args = arrayOf("--status"),
377+
options = ExecOptions(ignoreReturnCode = true)
378+
)
379+
exec(
380+
commandLine = "wsl",
381+
args = arrayOf("--help"),
382+
options = ExecOptions(ignoreReturnCode = true)
383+
)
384+
// do not use executeWslCommand() here as `wsl --help` does not yet work
385+
exec(
386+
commandLine = "wsl",
387+
args = arrayOf("--install", "--no-distribution"),
388+
options = ExecOptions(ignoreReturnCode = true)
389+
).also { check(it != 0) }
390+
exec(
391+
commandLine = "wsl",
392+
args = arrayOf("--install", "--no-distribution"),
393+
options = ExecOptions(ignoreReturnCode = true, input = Buffer.from(""))
394+
).also { check(it != 0) }
395+
exec(
396+
commandLine = "wsl",
397+
args = arrayOf("--install"),
398+
options = ExecOptions(ignoreReturnCode = true, input = Buffer.from(""))
399+
).also { check(it != 0) }
400+
}
401+
waitForWslStatusNotContaining(" ", 5u)
402+
error("just because")
403+
}
404+
374405
executeWslCommand(
375406
wslArguments = arrayOf("--set-default-version", "${wslVersion()}")
376407
)
377408
if (wslVersion() != 1u) {
378-
retry(5) {
409+
retry(10) {
379410
executeWslCommand(
380411
wslArguments = arrayOf("--update")
381412
)
382413
}
383-
384-
(2..30)
385-
.asFlow()
386-
.onEach { delay(1.seconds) }
387-
.onStart { emit(1) }
388-
.map { wslStatus() }
389-
.firstOrNull { !it.contains("WSL is finishing an upgrade...") }
414+
waitForWslStatusNotContaining("WSL is finishing an upgrade...")
390415
}
391416
exec(
392417
commandLine = """"${path.join(distributionDirectory(), distribution.installerFile)}"""",
@@ -395,6 +420,15 @@ suspend fun installDistribution() {
395420
)
396421
}
397422

423+
suspend fun waitForWslStatusNotContaining(text: String, duration: UInt = 30u) {
424+
(2u..duration)
425+
.asFlow()
426+
.onEach { delay(1.seconds) }
427+
.onStart { emit(1u) }
428+
.map { warning("Querying WSL Status"); wslOutput("--status").also { warning(it) } }
429+
.firstOrNull { !it.contains(text) }
430+
}
431+
398432
suspend fun adjustWslConf() {
399433
exec(
400434
commandLine = "wsl",

0 commit comments

Comments
 (0)