Windows and Mac builds do not raise error when the build fails
Bug description
Windows and Mac builds do not raise error when the build fails
How to reproduce
- Run a build using a windows image or using macos runner
- Have the build fail
Expected behavior
The GitHub actions status should show as errored.
Additional details
The windows builds here failed, but do not show as errored: https://github.com/finol-digital/Card-Game-Simulator/actions/runs/1748742227
Déjà vu. We used to have this image in Linux as well. Perhaps we can use a similar same solution.
It doesn't even seem like the process exits when the build fails, at least on my self-hosted runnner.
I see this in my logs, which is perhaps the culprit?
Build failed, with exit code True"
It looks like that's expecting an int? Probably some Windows hogwash.
Seems like something's wrong here, but I don't know anything about PowerShell:
https://github.com/game-ci/unity-builder/blob/e5e370e88ea0489ff08dac7a986c79e23e625eca/dist/platforms/windows/build.ps1#L128-L138
I think maybe $? needs to be $LastExitCode
Seems like nowhere in the script does it actually exit if there is a failure? I am playing with adding explicit exits on my fork. Not sure if that's the best solution or what, still learning this codebase. https://github.com/wilg/unity-builder
Yes, this can probably be improved.
This seems to have been added explicitly, the Mac builder is run with ignoreReturnCode:
https://github.com/game-ci/unity-builder/pull/326/files#diff-235ccbdf6464862b094c2efc53e8144265c6665ad99a973e18bad1c51d113204R8
https://github.com/game-ci/unity-builder/blob/3337de4dc90a37f0c9c786c0bcf6a1ec06dfe007/src/model/mac-builder.ts#L6-L9
Edit: and because exec returns the error code, it doesn't throw an exception. Example of catching it here: https://github.com/wilg/unity-builder/commit/4c4cb5d01f9026cae5fec68d6c5d0f3ce15aa386
Done by #505