Skip to content

Commit

Permalink
Add support for windows-2025 runner images (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jan 3, 2025
1 parent b2fcdb9 commit c8f2540
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import kotlin.math.min
val environments = listOf(
"windows-2019",
"windows-2022",
"windows-2025",
"windows-latest"
)

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- user-id: 'invalid'
Expand Down Expand Up @@ -127,6 +128,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
wsl-version:
- '-1'
Expand Down Expand Up @@ -167,6 +169,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -372,6 +375,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -936,6 +940,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1045,6 +1050,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1190,6 +1196,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1326,6 +1333,7 @@ jobs:
matrix:
environment:
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1407,6 +1415,7 @@ jobs:
matrix:
environment:
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
steps:
- id: 'step-0'
Expand Down Expand Up @@ -1457,6 +1466,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1538,6 +1548,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distributions:
- distribution1:
Expand Down Expand Up @@ -1694,6 +1705,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distribution:
- wsl-id: 'Debian'
Expand Down Expand Up @@ -1760,6 +1772,17 @@ jobs:
user-id: 'Debian'
match-pattern: '*Debian*'
default-absent-tool: 'dos2unix'
- environment: 'windows-2025'
distribution:
wsl-id: 'Debian'
user-id: 'Debian'
match-pattern: '*Debian*'
default-absent-tool: 'dos2unix'
distribution2:
wsl-id: 'Debian'
user-id: 'Debian'
match-pattern: '*Debian*'
default-absent-tool: 'dos2unix'
- environment: 'windows-latest'
distribution:
wsl-id: 'Debian'
Expand Down Expand Up @@ -1794,6 +1817,17 @@ jobs:
user-id: 'Ubuntu-20.04'
match-pattern: '*Ubuntu*20.04*'
default-absent-tool: 'dos2unix'
- environment: 'windows-2025'
distribution:
wsl-id: 'Debian'
user-id: 'Debian'
match-pattern: '*Debian*'
default-absent-tool: 'dos2unix'
distribution2:
wsl-id: 'Ubuntu'
user-id: 'Ubuntu-20.04'
match-pattern: '*Ubuntu*20.04*'
default-absent-tool: 'dos2unix'
- environment: 'windows-latest'
distribution:
wsl-id: 'Debian'
Expand Down Expand Up @@ -1981,6 +2015,7 @@ jobs:
environment:
- 'windows-2019'
- 'windows-2022'
- 'windows-2025'
- 'windows-latest'
distributions:
- incompatibleUbuntu: 'Ubuntu-22.04'
Expand Down
44 changes: 32 additions & 12 deletions src/jsMain/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ import node.process.Platform
import node.process.process
import nullwritable.NullWritable
import org.w3c.dom.url.URL
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
import actions.tool.cache.extractZip as toolCacheExtractZip

Expand Down Expand Up @@ -101,10 +103,6 @@ val wslHelp = GlobalScope.async(start = LAZY) {
wslOutput("--help")
}

val wslStatus = GlobalScope.async(start = LAZY) {
wslOutput("--status")
}

val distribution by lazy {
val distributionId = getInput("distribution", InputOptions(required = true))

Expand All @@ -125,6 +123,10 @@ val wslId = GlobalScope.async(start = LAZY) {
distribution.wslId
}

val wslInstallationNeeded = GlobalScope.async(start = LAZY) {
wslOutput("--status").contains("is not installed")
}

val installationNeeded = GlobalScope.async(start = LAZY) {
exec(
commandLine = "wsl",
Expand Down Expand Up @@ -292,6 +294,12 @@ suspend fun main() {
if (getInput("only safe actions").isEmpty()
|| !getBooleanInput("only safe actions")
) {
// on windows-2025 WSL is not installed at all currently, so install it without distribution
// work-around for https://github.com/actions/runner-images/issues/11265
if (wslInstallationNeeded()) {
group("Install WSL", ::installWsl)
}

if (installationNeeded()) {
group("Install Distribution", ::installDistribution)
}
Expand Down Expand Up @@ -370,23 +378,26 @@ suspend fun verifyWindowsEnvironment() {
}
}

suspend fun installWsl() {
exec(
commandLine = "pwsh",
args = arrayOf("-Command", """Start-Process wsl "--install --no-distribution""""),
options = ExecOptions(ignoreReturnCode = true)
)
waitForWslStatusNotContaining("is not installed", 5.minutes)
}

suspend fun installDistribution() {
executeWslCommand(
wslArguments = arrayOf("--set-default-version", "${wslVersion()}")
)
if (wslVersion() != 1u) {
retry(5) {
retry(10) {
executeWslCommand(
wslArguments = arrayOf("--update")
)
}

(2..30)
.asFlow()
.onEach { delay(1.seconds) }
.onStart { emit(1) }
.map { wslStatus() }
.firstOrNull { !it.contains("WSL is finishing an upgrade...") }
waitForWslStatusNotContaining("WSL is finishing an upgrade...")
}
exec(
commandLine = """"${path.join(distributionDirectory(), distribution.installerFile)}"""",
Expand All @@ -395,6 +406,15 @@ suspend fun installDistribution() {
)
}

suspend fun waitForWslStatusNotContaining(text: String, duration: Duration = 30.seconds) {
(2..duration.inWholeSeconds)
.asFlow()
.onEach { delay(1.seconds) }
.onStart { emit(1) }
.map { wslOutput("--status") }
.firstOrNull { !it.contains(text) }
}

suspend fun adjustWslConf() {
exec(
commandLine = "wsl",
Expand Down

0 comments on commit c8f2540

Please sign in to comment.