fix(licensing): add unityLicensingToolset input + fix HOME/USER under runAsHostUser

Addresses #739. Two opt-in, backwards-compatible changes for users on Linux
Docker builds with a Unity floating-license server:

1. Floating license servers that host multiple toolsets had no way to tell
   the Licensing Client which toolset to request — Unity could fall through
   to an entitlement that lacks build-target support (e.g. Android), then
   silently produce a Linux Standalone artifact. The action now accepts an
   optional unityLicensingToolset input that is written into
   services-config.json. When unset, the rendered config is byte-for-byte
   identical to before.

2. With runAsHostUser: true, su was invoked without explicit HOME/USER, so
   the host user inherited root's environment (HOME=/root, USER unset). The
   Unity Licensing Client, which writes to ~/.config/unity3d, could not
   resolve a writable home directory, leading to intermittent license
   activation failures. Set HOME/USER/LOGNAME explicitly before sourcing
   build steps. Change lives entirely inside the existing runAsHostUser
   branch.
This commit is contained in:
frostebite
2026-05-07 20:00:10 +01:00
parent d829bfc901
commit dd95ad9604
9 changed files with 113 additions and 12986 deletions
+17 -2
View File
@@ -127,11 +127,18 @@ describe('BuildParameters', () => {
${Platform.types.StandaloneLinux64} | ${''} | ${'n/a'} | ${true}
`(
'appends $expectedExtension for $targetPlatform with linux64RemoveExecutableExtension=$linux64RemoveExecutableExtension',
async ({ targetPlatform, expectedExtension, androidExportType, linux64RemoveExecutableExtension }) => {
async ({
targetPlatform,
expectedExtension,
androidExportType,
linux64RemoveExecutableExtension,
}) => {
vi.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform);
vi.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform);
vi.spyOn(Input, 'androidExportType', 'get').mockReturnValue(androidExportType);
vi.spyOn(Input, 'linux64RemoveExecutableExtension', 'get').mockReturnValue(linux64RemoveExecutableExtension);
vi.spyOn(Input, 'linux64RemoveExecutableExtension', 'get').mockReturnValue(
linux64RemoveExecutableExtension,
);
await expect(BuildParameters.create()).resolves.toEqual(
expect.objectContaining({ buildFile: `${targetPlatform}${expectedExtension}` }),
);
@@ -221,6 +228,14 @@ describe('BuildParameters', () => {
);
});
it('returns the unity licensing toolset', async () => {
const mockValue = 'LicenseServer_1234567890_3';
vi.spyOn(Input, 'unityLicensingToolset', 'get').mockReturnValue(mockValue);
await expect(BuildParameters.create()).resolves.toEqual(
expect.objectContaining({ unityLicensingToolset: mockValue }),
);
});
it('throws error when no unity license provider provided', async () => {
delete process.env.UNITY_LICENSE; // Need to delete this as it is set for every test currently
await expect(BuildParameters.create()).rejects.toThrowError();