Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple licensing products #661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ inputs:
default: ''
required: false
description: 'The Unity licensing server address to use for activating Unity.'
unityLicensingProductIds:
default: ''
required: false
description:
'Comma separated list of license product identifiers to request licenses for from the license server. Not setting
this will request the default license product configured on the licensing server. Only applicable if
unityLicensingServer is set.'
dockerWorkspacePath:
default: '/github/workspace'
required: false
Expand Down
10 changes: 10 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/unity-config/services-config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"enableEntitlementLicensing": true,
"enableFloatingApi": true,
"clientConnectTimeoutSec": 5,
"clientHandshakeTimeoutSec": 10
"clientHandshakeTimeoutSec": 10,
"toolset": "%LICENSE_PRODUCT_IDS%"
}
8 changes: 8 additions & 0 deletions src/model/build-parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ describe('BuildParameters', () => {
await expect(BuildParameters.create()).rejects.toThrowError();
});

it('returns the unity licensing product ids', async () => {
const mockValue = 'license_id_1';
jest.spyOn(Input, 'unityLicensingProductIds', 'get').mockReturnValue(mockValue);
await expect(BuildParameters.create()).resolves.toEqual(
expect.objectContaining({ unityLicensingProductIds: mockValue }),
);
});

it('return serial when no license server is provided', async () => {
const mockValue = '123';
delete process.env.UNITY_LICENSE; // Need to delete this as it is set for every test currently
Expand Down
2 changes: 2 additions & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class BuildParameters {
public customImage!: string;
public unitySerial!: string;
public unityLicensingServer!: string;
public unityLicensingProductIds!: string;
public skipActivation!: string;
public runnerTempPath!: string;
public targetPlatform!: string;
Expand Down Expand Up @@ -148,6 +149,7 @@ class BuildParameters {
customImage: Input.customImage,
unitySerial,
unityLicensingServer: Input.unityLicensingServer,
unityLicensingProductIds: Input.unityLicensingProductIds,
skipActivation: Input.skipActivation,
runnerTempPath: Input.runnerTempPath,
targetPlatform: Input.targetPlatform,
Expand Down
4 changes: 4 additions & 0 deletions src/model/image-environment-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class ImageEnvironmentFactory {
name: 'UNITY_LICENSING_SERVER',
value: parameters.unityLicensingServer,
},
{
name: 'UNITY_LICENSING_PRODUCT_IDS',
value: parameters.unityLicensingProductIds,
},
{ name: 'SKIP_ACTIVATION', value: parameters.skipActivation },
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{
Expand Down
4 changes: 4 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class Input {
return Input.getInput('unityLicensingServer') ?? '';
}

static get unityLicensingProductIds(): string {
return Input.getInput('unityLicensingProductIds') ?? '';
}

static get buildMethod(): string {
return Input.getInput('buildMethod') ?? ''; // Processed in docker file
}
Expand Down
1 change: 1 addition & 0 deletions src/model/platform-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PlatformSetup {

let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
servicesConfig = servicesConfig.replace('%LICENSE_PRODUCT_IDS%', buildParameters.unityLicensingProductIds);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ unityLicensingProductIds is not defined in BuildParameters.

The unityLicensingProductIds property used in platform-setup.ts is not defined in the BuildParameters class. This omission can lead to runtime errors or unexpected behavior.

Additionally, the search for unityLicensingProductIds usage in other files failed due to an unrecognized file type (typescript). Please ensure that the search tools are correctly configured to handle TypeScript files.

🔗 Analysis chain

LGTM! Verify integration with other components.

The implementation correctly adds support for multiple licensing products by replacing the '%LICENSE_PRODUCT_IDS%' placeholder with the value from buildParameters.unityLicensingProductIds. This change aligns well with the PR objectives.

To ensure complete integration, let's verify if the unityLicensingProductIds property is properly defined and used in other relevant parts of the codebase:

This script will help us confirm that the new property is properly integrated across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and definition of unityLicensingProductIds

# Test 1: Check for the definition of unityLicensingProductIds in BuildParameters
echo "Checking for unityLicensingProductIds definition in BuildParameters:"
ast-grep --lang typescript --pattern 'class BuildParameters {
  $$$
  unityLicensingProductIds: $_
  $$$
}'

# Test 2: Check for usage of unityLicensingProductIds in other files
echo "Checking for unityLicensingProductIds usage in other files:"
rg --type typescript -g '!platform-setup.ts' 'unityLicensingProductIds'

# Test 3: Check if the new parameter is added to action.yml
echo "Checking if unityLicensingProductIds is added to action.yml:"
rg 'unityLicensingProductIds:' action.yml

Length of output: 693

fs.writeFileSync(servicesConfigPath, servicesConfig);

SetupAndroid.setup(buildParameters);
Expand Down
1 change: 1 addition & 0 deletions src/model/platform-setup/setup-mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class SetupMac {
process.env.UNITY_VERSION = buildParameters.editorVersion;
process.env.UNITY_SERIAL = buildParameters.unitySerial;
process.env.UNITY_LICENSING_SERVER = buildParameters.unityLicensingServer;
process.env.UNITY_LICENSING_PRODUCT_IDS = buildParameters.unityLicensingProductIds;
process.env.SKIP_ACTIVATION = buildParameters.skipActivation;
process.env.PROJECT_PATH = buildParameters.projectPath;
process.env.BUILD_TARGET = buildParameters.targetPlatform;
Expand Down
Loading