Skip to content

Commit

Permalink
keepwsl
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Feb 10, 2025
1 parent 76c28f2 commit ec628f5
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions .github/workflows/win-wsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: windows-2022

steps:
- name: Start Ubuntu WSL
- name: Prepare WSL
run: |
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
Expand All @@ -17,8 +17,31 @@ jobs:
& wsl --set-default-version 2
& wsl --install Ubuntu
& wsl --set-default Ubuntu
# https://github.com/microsoft/WSL/issues/10138#issuecomment-1593856698
& wsl --exec dbus-launch true
# https://github.com/microsoft/WSL/issues/10138#issuecomment-2380431569
@'
[boot]
systemd=true
[automount]
enabled = true
'@ | & wsl tee /etc/wsl.conf
& wsl -- mkdir -p /usr/local/lib/systemd/system
@'
[Unit]
Description=A simple service to keep WSL alive
Documentation=https://github.com/gardengim/keepwsl
[Service]
ExecStart=/mnt/c/Windows/System32/wsl.exe sleep infinity
[Install]
WantedBy=default.target
'@ | & wsl tee /usr/local/lib/systemd/keepwsl.conf
& wsl --shutdown
- name: Start k0s controller in WSL
id: start-controller
Expand All @@ -39,9 +62,10 @@ jobs:
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
$k0sVersion = (Invoke-WebRequest -URI https://docs.k0sproject.io/latest.txt).Content.Trim()
$k0sVersion = (Invoke-WebRequest -Uri https://docs.k0sproject.io/latest.txt).Content.Trim()
$url = "https://github.com/k0sproject/k0s/releases/download/$k0sVersion/k0s-${k0sVersion}-amd64.exe"
Write-Host "Downloading k0s $k0sVersion"
& curl --proto =https --tlsv1.2 --retry 5 --retry-all-errors -sSLfo k0s.exe "https://github.com/k0sproject/k0s/releases/download/$k0sVersion/k0s-${k0sVersion}-amd64.exe"
Invoke-WebRequest -Uri $url -OutFile k0s.exe
& .\k0s version
- name: Prepare kubeconfig
Expand Down Expand Up @@ -129,5 +153,5 @@ jobs:
- name: k0 controller logs
if: always() && steps.start-controller.conclusion == 'success'
run: |
wsl systemctl status k0scontroller.service
wsl journalctl -u k0scontroller.service
& wsl systemctl status k0scontroller.service
& wsl journalctl -u k0scontroller.service

0 comments on commit ec628f5

Please sign in to comment.