If a second build target is run on the same self-hosted MacOS runner (with the same Unity version), the action will detect that the Unity Editor version is already installed, and it will skip the Unity Editor installation. The build will then fail, as the Unity Editor does not have the build target support installed.
This is admittedly a very specific case, so I'm not surprised no one else has hit this yet, or that no one thought of it.
How to reproduce
On a (clean) self-hosted MacOS runner, build some target, like iOS on some Unity version, like 2020.3.44f1.
On the same self-hosted runner, build a different target, like Android on the same Unity version.
Build will skip installing Unity Editor or modules, as the Unity Editor is already installed.
Build will fail with import errors.
Expected behavior
The action detects that the installed Unity Editor does not have the right build target module installed, and installs it before starting the build.
Additional details
Unfortunately, the Unity Hub CLI does not have a way to test what modules are currently installed. However, the install-modules command is idempotent, so it could be called every run without any downsides other than a bit of extra runtime.
Bug description
If a second build target is run on the same self-hosted MacOS runner (with the same Unity version), the action will detect that the Unity Editor version is already installed, and it will skip the Unity Editor installation. The build will then fail, as the Unity Editor does not have the build target support installed.
This is admittedly a very specific case, so I'm not surprised no one else has hit this yet, or that no one thought of it.
How to reproduce
Expected behavior
The action detects that the installed Unity Editor does not have the right build target module installed, and installs it before starting the build.
Additional details
Unfortunately, the Unity Hub CLI does not have a way to test what modules are currently installed. However, the
install-modules
command is idempotent, so it could be called every run without any downsides other than a bit of extra runtime.Suggested fix
It should be possible to simply ask Unity Hub to install the required module every build. That might look something like this in this block: https://github.com/game-ci/unity-builder/blob/ff23166e3002a9f3f869621650dc992e657e17ce/src/model/platform-setup/setup-mac.ts#L19-L21
and the new function:
This suggested code does not handle the MacOS Editor caching: the cache would likely need to be updated after.
This suggested Unity Hub CLI command is the exact command I used to solve my issue.