Setup Gitlab shared runner for run tests on windows
Today in one of my projects, I discovered a bug that happened only on Windows, I personally have no machines that run Windows so had some trouble to reproduce the problem, so the first thing that came to my mind was try to set up the Continuous Integration to run on Windows, for the specific project I use GitLab and the relative GitLab-CI, I went to search what was the support for Windows in the shared runners and I got a good surprise, GitLab provide shared runners with the support of windows you just need to specify some tags:
Example of reusable configuration:
.shared_windows_runners:
tags:
- shared-windows
- windows
- windows-1809
done this I went to the hunt of how to install rust on the machine to run the tests, was thinking to go ahead with rustup, but it felt a bit of an overkill, so a searched a bit for possible solution and on my surprise as well I discovered that also Windows has finally entered the twenty-first century, and have a package manager called Chocolatey that is already install in the GitLab shared runner, and there is a package rust that seems to work pretty fine so I could do a .gitlab-ci.yaml that look more or less like this:
.shared_windows_runners:
tags:
- shared-windows
- windows
- windows-1809
tests_windows:
extends:
- .shared_windows_runners
script:
- choco install rust -y -f
- rustc --version # Print version info for debugging
- cargo --version # Print version info for debugging
- cargo test --all-features
I'm posting because I've been surprised how this has been easy, I guess has been too many years that I do not do anything meaningful on a Windows machine, and I missed a lot of catch-up that Windows has done.