Skip to content

Commit 4ae184c

Browse files
authored
Allow Skipping Activation (#629)
* Add skipActivation functionality * Update packages and fix lint/test issues * Use nullish coalescing operator * Ensure there is enough space for Android test builds
1 parent 082ea39 commit 4ae184c

File tree

13 files changed

+9494
-5650
lines changed

13 files changed

+9494
-5650
lines changed

.github/workflows/build-tests-ubuntu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
- Android # Build an Android .apk.
6060
- WebGL # WebGL.
6161
steps:
62+
- name: Clear Space for Android Build
63+
if: matrix.targetPlatform == 'Android'
64+
uses: jlumbroso/[email protected]
65+
6266
###########################
6367
# Checkout #
6468
###########################

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ inputs:
253253
description:
254254
'The path to mount the workspace inside the docker container. For windows, leave out the drive letter. For example
255255
c:/github/workspace should be defined as /github/workspace'
256+
skipActivation:
257+
default: 'false'
258+
required: false
259+
description: 'Skip the activation/deactivation of Unity. This assumes Unity is already activated.'
256260

257261
outputs:
258262
volume:

dist/index.js

Lines changed: 9231 additions & 5453 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/mac/entrypoint.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
#!/usr/bin/env bash
22

33
#
4-
# Create directories for license activation
4+
# Perform Activation
55
#
66

7-
UNITY_LICENSE_PATH="/Library/Application Support/Unity"
7+
if [ "$SKIP_ACTIVATION" != "true" ]; then
8+
UNITY_LICENSE_PATH="/Library/Application Support/Unity"
89

9-
if [ ! -d "$UNITY_LICENSE_PATH" ]; then
10-
echo "Creating Unity License Directory"
11-
sudo mkdir -p "$UNITY_LICENSE_PATH"
12-
sudo chmod -R 777 "$UNITY_LICENSE_PATH"
13-
fi;
10+
if [ ! -d "$UNITY_LICENSE_PATH" ]; then
11+
echo "Creating Unity License Directory"
12+
sudo mkdir -p "$UNITY_LICENSE_PATH"
13+
sudo chmod -R 777 "$UNITY_LICENSE_PATH"
14+
fi;
15+
16+
ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject"
17+
mkdir -p "$ACTIVATE_LICENSE_PATH"
1418

15-
ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject"
16-
mkdir -p "$ACTIVATE_LICENSE_PATH"
19+
source $ACTION_FOLDER/platforms/mac/steps/activate.sh
20+
else
21+
echo "Skipping activation"
22+
fi
1723

1824
#
19-
# Run steps
25+
# Run Build
2026
#
21-
source $ACTION_FOLDER/platforms/mac/steps/activate.sh
27+
2228
source $ACTION_FOLDER/platforms/mac/steps/build.sh
23-
source $ACTION_FOLDER/platforms/mac/steps/return_license.sh
2429

2530
#
26-
# Remove license activation directory
31+
# License Cleanup
2732
#
2833

29-
rm -r "$ACTIVATE_LICENSE_PATH"
34+
if [ "$SKIP_ACTIVATION" != "true" ]; then
35+
source $ACTION_FOLDER/platforms/mac/steps/return_license.sh
36+
rm -r "$ACTIVATE_LICENSE_PATH"
37+
fi
3038

3139
#
3240
# Instructions for debugging

dist/platforms/ubuntu/steps/runsteps.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
#
66
source /steps/set_extra_git_configs.sh
77
source /steps/set_gitcredential.sh
8-
source /steps/activate.sh
98

10-
# If we didn't activate successfully, exit with the exit code from the activation step.
11-
if [[ $UNITY_EXIT_CODE -ne 0 ]]; then
12-
exit $UNITY_EXIT_CODE
9+
if [ "$SKIP_ACTIVATION" != "true" ]; then
10+
source /steps/activate.sh
11+
12+
# If we didn't activate successfully, exit with the exit code from the activation step.
13+
if [[ $UNITY_EXIT_CODE -ne 0 ]]; then
14+
exit $UNITY_EXIT_CODE
15+
fi
16+
else
17+
echo "Skipping activation"
1318
fi
1419

1520
source /steps/build.sh
16-
source /steps/return_license.sh
21+
22+
if [ "$SKIP_ACTIVATION" != "true" ]; then
23+
source /steps/return_license.sh
24+
fi
1725

1826
#
1927
# Instructions for debugging

dist/platforms/windows/entrypoint.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Get-Process
22

33
# Import any necessary registry keys, ie: location of windows 10 sdk
44
# No guarantee that there will be any necessary registry keys, ie: tvOS
5-
Get-ChildItem -Path c:\regkeys -File | ForEach-Object {reg import $_.fullname}
5+
Get-ChildItem -Path c:\regkeys -File | ForEach-Object { reg import $_.fullname }
66

77
# Register the Visual Studio installation so Unity can find it
88
regsvr32 C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll
@@ -14,18 +14,25 @@ Get-Process -Name regsvr32 | ForEach-Object { Stop-Process -Id $_.Id -Force }
1414
. "c:\steps\set_gitcredential.ps1"
1515

1616
# Activate Unity
17-
. "c:\steps\activate.ps1"
17+
if ($env:SKIP_ACTIVATION -ne "true") {
18+
. "c:\steps\activate.ps1"
1819

19-
# If we didn't activate successfully, exit with the exit code from the activation step.
20-
if ($ACTIVATION_EXIT_CODE -ne 0) {
20+
# If we didn't activate successfully, exit with the exit code from the activation step.
21+
if ($ACTIVATION_EXIT_CODE -ne 0) {
2122
exit $ACTIVATION_EXIT_CODE
23+
}
24+
}
25+
else {
26+
Write-Host "Skipping activation"
2227
}
2328

2429
# Build the project
2530
. "c:\steps\build.ps1"
2631

2732
# Free the seat for the activated license
28-
. "c:\steps\return_license.ps1"
33+
if ($env:SKIP_ACTIVATION -ne "true") {
34+
. "c:\steps\return_license.ps1"
35+
}
2936

3037
Get-Process
3138

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
"node": ">=18.x"
2929
},
3030
"dependencies": {
31-
"@actions/cache": "^3.1.3",
32-
"@actions/core": "^1.10.0",
33-
"@actions/exec": "^1.1.0",
34-
"@actions/github": "^5.0.0",
31+
"@actions/cache": "^3.2.4",
32+
"@actions/core": "^1.10.1",
33+
"@actions/exec": "^1.1.1",
34+
"@actions/github": "^6.0.0",
3535
"@kubernetes/client-node": "^0.16.3",
36-
"@octokit/core": "^3.5.1",
36+
"@octokit/core": "^5.1.0",
3737
"async-wait-until": "^2.0.12",
3838
"aws-sdk": "^2.1081.0",
3939
"base-64": "^1.0.0",
@@ -50,7 +50,6 @@
5050
"yaml": "^2.2.2"
5151
},
5252
"devDependencies": {
53-
"@evilmartians/lefthook": "^1.2.9",
5453
"@types/base-64": "^1.0.0",
5554
"@types/jest": "^27.4.1",
5655
"@types/node": "^17.0.23",
@@ -69,6 +68,7 @@
6968
"jest-circus": "^27.5.1",
7069
"jest-fail-on-console": "^3.0.2",
7170
"js-yaml": "^4.1.0",
71+
"lefthook": "^1.6.1",
7272
"prettier": "^2.5.1",
7373
"ts-jest": "^27.1.3",
7474
"ts-node": "10.8.1",

src/model/build-parameters.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class BuildParameters {
2222
public customImage!: string;
2323
public unitySerial!: string;
2424
public unityLicensingServer!: string;
25+
public skipActivation!: string;
2526
public runnerTempPath!: string;
2627
public targetPlatform!: string;
2728
public projectPath!: string;
@@ -59,7 +60,7 @@ class BuildParameters {
5960
public kubeVolumeSize!: string;
6061
public kubeVolume!: string;
6162
public kubeStorageClass!: string;
62-
public runAsHostUser!: String;
63+
public runAsHostUser!: string;
6364
public chownFilesTo!: string;
6465
public commandHooks!: string;
6566
public pullInputList!: string[];
@@ -146,6 +147,7 @@ class BuildParameters {
146147
customImage: Input.customImage,
147148
unitySerial,
148149
unityLicensingServer: Input.unityLicensingServer,
150+
skipActivation: Input.skipActivation,
149151
runnerTempPath: Input.runnerTempPath,
150152
targetPlatform: Input.targetPlatform,
151153
projectPath: Input.projectPath,
@@ -168,7 +170,7 @@ class BuildParameters {
168170
customParameters: Input.customParameters,
169171
sshAgent: Input.sshAgent,
170172
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
171-
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
173+
gitPrivateToken: Input.gitPrivateToken ?? (await GithubCliReader.GetGitHubAuthToken()),
172174
runAsHostUser: Input.runAsHostUser,
173175
chownFilesTo: Input.chownFilesTo,
174176
dockerCpuLimit: Input.dockerCpuLimit,
@@ -190,7 +192,7 @@ class BuildParameters {
190192
branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()),
191193
cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0],
192194
cloudRunnerDebug: CloudRunnerOptions.cloudRunnerDebug,
193-
githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder',
195+
githubRepo: (Input.githubRepo ?? (await GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
194196
isCliMode: Cli.isCliMode,
195197
awsStackName: CloudRunnerOptions.awsStackName,
196198
gitSha: Input.gitSha,

src/model/image-environment-factory.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ImageEnvironmentFactory {
2929
name: 'UNITY_LICENSING_SERVER',
3030
value: parameters.unityLicensingServer,
3131
},
32+
{ name: 'SKIP_ACTIVATION', value: parameters.skipActivation },
3233
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
3334
{
3435
name: 'USYM_UPLOAD_AUTH_TOKEN',
@@ -81,20 +82,12 @@ class ImageEnvironmentFactory {
8182
];
8283
if (parameters.providerStrategy === 'local-docker') {
8384
for (const element of additionalVariables) {
84-
if (
85-
environmentVariables.find(
86-
(x) => element !== undefined && element.name !== undefined && x.name === element.name,
87-
) === undefined
88-
) {
85+
if (!environmentVariables.some((x) => element?.name === x?.name)) {
8986
environmentVariables.push(element);
9087
}
9188
}
9289
for (const variable of environmentVariables) {
93-
if (
94-
environmentVariables.find(
95-
(x) => variable !== undefined && variable.name !== undefined && x.name === variable.name,
96-
) === undefined
97-
) {
90+
if (!environmentVariables.some((x) => variable?.name === x?.name)) {
9891
environmentVariables = environmentVariables.filter((x) => x !== variable);
9992
}
10093
}

0 commit comments

Comments
 (0)