game-ci / unity-builder

Build Unity projects for different platforms
https://github.com/marketplace/actions/unity-builder
MIT License
822 stars 231 forks source link

Is a self-hosted Windows runner even possible? #637

Open JanikHelbig-NB opened 3 months ago

JanikHelbig-NB commented 3 months ago

Hi!

I'm currently trying to set up a bare-metal, self-hosted Windows runner for workflows using unity-builder@v4. However, I keep running into issues and I'm starting to wonder if it's been futile from the start.

I'm a bit confused by the documentation in regards to this. The guide for setting up a self hosted runner in the Game-CI docs makes no mention of windows at all and the GitHub Actions documentation states here that "you must use a Linux machine" to use actions utilizing docker containers. (Which I assume refers to actions such as this.)

For a little more context, I'm running into this error:

...
Building locally
"C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --workdir c:/github/workspace --rm ((flags omitted for brevity)) powershell c:/steps/entrypoint.ps1
docker: Error response from daemon: the working directory 'c:/github/workspace' is invalid, it needs to be an absolute path.
See 'docker run --help'.
Error: Build failed with exit code 125

This error does not occur when running the same workflow on a GitHub-hosted Windows runner. I'm not sure if this is an issue I can fix on my end or if there is some magic happening with GitHub's runners that I don't understand.

CheeryLee commented 3 months ago

In our case we have built CI/CD pipeline on top of Cygwin and host installation of Unity. No Docker used due to it's limitations. Therefore it's possible. Yes, this method does not provide complete isolation, but it is still fully functional.

However, it is worth saying that our configuration is already very different from the one presented in this repository. We have chosen the way to not to separate build scripts but stay on vanilla Bash with POSIX compatible instructions that are working both on Linux and Windows as well. In this case all you need to do is install Cygwin or MSYS (note: these things are different and have various POSIX compatibility) and change system related paths.

Unity binaries installation and license resolution work via Unity Hub, so you must have an access to a build machine via RDP or something else. Install all required versions of engine and activate the license once.

webbertakken commented 3 months ago

@JanikHelbig-NB builder on Windows just runs a docker command https://github.com/game-ci/unity-builder/blob/main/src/model/docker.ts#L91, not much different from what happens on the ubuntu variant.

Regarding the quote from GitHub Actions docs

If you want to run workflows that use Docker container actions or service containers, you must use a Linux machine and Docker must be installed.

I'd take that as a recommendation and as a word of warning for if you want "official support". However there's no reason why a windows runner wouldn't be able to run docker. In fact the very error you're getting indicates that docker is installed and works (as the error comes from the docker daemon).

Looks like the folder might not exist and the error is a bit misleading saying it's not an absolute path, or otherwise it might be a quoting issue.

Generally if things work on the GitHub hosted runners, then it should work on your runner too, as long as you use the official images (i.e. exactly the ones as GitHub hosted is running too).

The reason why I'm saying that is that people have reported problems before with different images. For example a docker-instanced runner has given people trouble because of the lack of DinD support and the instances not being exactly equal to the actual images that GitHub hosted runs on.