Skip to content

Commit

Permalink
Allow Skipping Activation (#629)
Browse files Browse the repository at this point in the history
* Add skipActivation functionality

* Update packages and fix lint/test issues

* Use nullish coalescing operator

* Ensure there is enough space for Android test builds
  • Loading branch information
AndrewKahr committed Feb 19, 2024
1 parent 082ea39 commit 4ae184c
Show file tree
Hide file tree
Showing 13 changed files with 9,494 additions and 5,650 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-tests-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
- Android # Build an Android .apk.
- WebGL # WebGL.
steps:
- name: Clear Space for Android Build
if: matrix.targetPlatform == 'Android'
uses: jlumbroso/free-disk-space@v1.3.1

###########################
# Checkout #
###########################
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ inputs:
description:
'The path to mount the workspace inside the docker container. For windows, leave out the drive letter. For example
c:/github/workspace should be defined as /github/workspace'
skipActivation:
default: 'false'
required: false
description: 'Skip the activation/deactivation of Unity. This assumes Unity is already activated.'

outputs:
volume:
Expand Down
14,684 changes: 9,231 additions & 5,453 deletions dist/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions dist/licenses.txt

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

36 changes: 22 additions & 14 deletions dist/platforms/mac/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
#!/usr/bin/env bash

#
# Create directories for license activation
# Perform Activation
#

UNITY_LICENSE_PATH="/Library/Application Support/Unity"
if [ "$SKIP_ACTIVATION" != "true" ]; then
UNITY_LICENSE_PATH="/Library/Application Support/Unity"

if [ ! -d "$UNITY_LICENSE_PATH" ]; then
echo "Creating Unity License Directory"
sudo mkdir -p "$UNITY_LICENSE_PATH"
sudo chmod -R 777 "$UNITY_LICENSE_PATH"
fi;
if [ ! -d "$UNITY_LICENSE_PATH" ]; then
echo "Creating Unity License Directory"
sudo mkdir -p "$UNITY_LICENSE_PATH"
sudo chmod -R 777 "$UNITY_LICENSE_PATH"
fi;

ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject"
mkdir -p "$ACTIVATE_LICENSE_PATH"

ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject"
mkdir -p "$ACTIVATE_LICENSE_PATH"
source $ACTION_FOLDER/platforms/mac/steps/activate.sh
else
echo "Skipping activation"
fi

#
# Run steps
# Run Build
#
source $ACTION_FOLDER/platforms/mac/steps/activate.sh

source $ACTION_FOLDER/platforms/mac/steps/build.sh
source $ACTION_FOLDER/platforms/mac/steps/return_license.sh

#
# Remove license activation directory
# License Cleanup
#

rm -r "$ACTIVATE_LICENSE_PATH"
if [ "$SKIP_ACTIVATION" != "true" ]; then
source $ACTION_FOLDER/platforms/mac/steps/return_license.sh
rm -r "$ACTIVATE_LICENSE_PATH"
fi

#
# Instructions for debugging
Expand Down
18 changes: 13 additions & 5 deletions dist/platforms/ubuntu/steps/runsteps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
#
source /steps/set_extra_git_configs.sh
source /steps/set_gitcredential.sh
source /steps/activate.sh

# If we didn't activate successfully, exit with the exit code from the activation step.
if [[ $UNITY_EXIT_CODE -ne 0 ]]; then
exit $UNITY_EXIT_CODE
if [ "$SKIP_ACTIVATION" != "true" ]; then
source /steps/activate.sh

# If we didn't activate successfully, exit with the exit code from the activation step.
if [[ $UNITY_EXIT_CODE -ne 0 ]]; then
exit $UNITY_EXIT_CODE
fi
else
echo "Skipping activation"
fi

source /steps/build.sh
source /steps/return_license.sh

if [ "$SKIP_ACTIVATION" != "true" ]; then
source /steps/return_license.sh
fi

#
# Instructions for debugging
Expand Down
17 changes: 12 additions & 5 deletions dist/platforms/windows/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Get-Process

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

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

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

# If we didn't activate successfully, exit with the exit code from the activation step.
if ($ACTIVATION_EXIT_CODE -ne 0) {
# If we didn't activate successfully, exit with the exit code from the activation step.
if ($ACTIVATION_EXIT_CODE -ne 0) {
exit $ACTIVATION_EXIT_CODE
}
}
else {
Write-Host "Skipping activation"
}

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

# Free the seat for the activated license
. "c:\steps\return_license.ps1"
if ($env:SKIP_ACTIVATION -ne "true") {
. "c:\steps\return_license.ps1"
}

Get-Process

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"node": ">=18.x"
},
"dependencies": {
"@actions/cache": "^3.1.3",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0",
"@actions/cache": "^3.2.4",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0",
"@kubernetes/client-node": "^0.16.3",
"@octokit/core": "^3.5.1",
"@octokit/core": "^5.1.0",
"async-wait-until": "^2.0.12",
"aws-sdk": "^2.1081.0",
"base-64": "^1.0.0",
Expand All @@ -50,7 +50,6 @@
"yaml": "^2.2.2"
},
"devDependencies": {
"@evilmartians/lefthook": "^1.2.9",
"@types/base-64": "^1.0.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
Expand All @@ -69,6 +68,7 @@
"jest-circus": "^27.5.1",
"jest-fail-on-console": "^3.0.2",
"js-yaml": "^4.1.0",
"lefthook": "^1.6.1",
"prettier": "^2.5.1",
"ts-jest": "^27.1.3",
"ts-node": "10.8.1",
Expand Down
8 changes: 5 additions & 3 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 skipActivation!: string;
public runnerTempPath!: string;
public targetPlatform!: string;
public projectPath!: string;
Expand Down Expand Up @@ -59,7 +60,7 @@ class BuildParameters {
public kubeVolumeSize!: string;
public kubeVolume!: string;
public kubeStorageClass!: string;
public runAsHostUser!: String;
public runAsHostUser!: string;
public chownFilesTo!: string;
public commandHooks!: string;
public pullInputList!: string[];
Expand Down Expand Up @@ -146,6 +147,7 @@ class BuildParameters {
customImage: Input.customImage,
unitySerial,
unityLicensingServer: Input.unityLicensingServer,
skipActivation: Input.skipActivation,
runnerTempPath: Input.runnerTempPath,
targetPlatform: Input.targetPlatform,
projectPath: Input.projectPath,
Expand All @@ -168,7 +170,7 @@ class BuildParameters {
customParameters: Input.customParameters,
sshAgent: Input.sshAgent,
sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath,
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
gitPrivateToken: Input.gitPrivateToken ?? (await GithubCliReader.GetGitHubAuthToken()),
runAsHostUser: Input.runAsHostUser,
chownFilesTo: Input.chownFilesTo,
dockerCpuLimit: Input.dockerCpuLimit,
Expand All @@ -190,7 +192,7 @@ class BuildParameters {
branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()),
cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerDebug: CloudRunnerOptions.cloudRunnerDebug,
githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder',
githubRepo: (Input.githubRepo ?? (await GitRepoReader.GetRemote())) || 'game-ci/unity-builder',
isCliMode: Cli.isCliMode,
awsStackName: CloudRunnerOptions.awsStackName,
gitSha: Input.gitSha,
Expand Down
13 changes: 3 additions & 10 deletions src/model/image-environment-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ImageEnvironmentFactory {
name: 'UNITY_LICENSING_SERVER',
value: parameters.unityLicensingServer,
},
{ name: 'SKIP_ACTIVATION', value: parameters.skipActivation },
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{
name: 'USYM_UPLOAD_AUTH_TOKEN',
Expand Down Expand Up @@ -81,20 +82,12 @@ class ImageEnvironmentFactory {
];
if (parameters.providerStrategy === 'local-docker') {
for (const element of additionalVariables) {
if (
environmentVariables.find(
(x) => element !== undefined && element.name !== undefined && x.name === element.name,
) === undefined
) {
if (!environmentVariables.some((x) => element?.name === x?.name)) {
environmentVariables.push(element);
}
}
for (const variable of environmentVariables) {
if (
environmentVariables.find(
(x) => variable !== undefined && variable.name !== undefined && x.name === variable.name,
) === undefined
) {
if (!environmentVariables.some((x) => variable?.name === x?.name)) {
environmentVariables = environmentVariables.filter((x) => x !== variable);
}
}
Expand Down
Loading

0 comments on commit 4ae184c

Please sign in to comment.