Over at the Ubuntu/WSL repository, we developed some GitHub actions to make your life easier when running your CI in WSL. This is needed because GitHub runners do not support WSL. Just setting up an Azure VM will not cut it either, because the runner will run in session 0, which means that Microsoft Store applications such as WSL cannot be run.
- Set up a Windows machine to run your CI in. GitHub runners won't do the job, but Azure VMs will.
- Set up an auto-logon in your Windows machine. See here for a step-by-step guide.
- Add the GitHub runner as a startup application (specifically, the
run.cmd
batch file in your actions runner).
You're done! Your CI yaml files will need some extra work, however, as you need to allocate and deallocate the VM on demand. The runner needs to run on Windows and not directly on WSL, as WSL instances will shut themselves down automatically, so we implemented some utilities to install and update WSL and the distro, as well as to run scripts.
You can find these actions and some more in-depth explanation for the setup here.
This repository contains a very simple library src.py
with a function that returns different results inside and outside WSL.
To test it properly, we run a test on each platform:
- Ubuntu in a GitHub Runner: test.yaml
- Ubuntu in WSL: test_wsl.yaml