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

Refactor orb to support proper activation of unity using serial #83

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
96 changes: 45 additions & 51 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,13 @@ jobs:
workflows:
test-build:
jobs:
# Activation file
- unity/create-activation-file:
name: "create-activation-file"
- unity/create-activation-file:
name: "create-activation-file-with-parameter"
editor_version: 2022.1.11f1

# Tests
- unity/test:
name: "test-linux"
step-name: "Check if the tests run and results are uploaded"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "linux-il2cpp"
Expand All @@ -104,9 +97,9 @@ workflows:
- unity/test:
name: "test-linux-with-custom-parameters"
step-name: "Check if test filter in custom parameter works"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "linux-il2cpp"
Expand All @@ -121,9 +114,10 @@ workflows:
# - unity/test:
# name: "test-windows"
# step-name: "Check if the tests run and results are uploaded"
# unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
# unity-username-var-name: "UNITY_USERNAME"
# unity-email-var-name: "UNITY_EMAIL"
# unity-password-var-name: "UNITY_PASSWORD"
# unity-serial-var-name: "UNITY_SERIAL"
# serial-password-var-name: "UNITY_SERIAL"
# executor:
# name: "unity/windows-2019"
# size: "large"
Expand All @@ -137,9 +131,9 @@ workflows:
# - unity/test:
# name: "test-windows-with-custom-parameters"
# step-name: "Check if test filter in custom parameter works"
# unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
# unity-username-var-name: "UNITY_USERNAME"
# unity-email-var-name: "UNITY_EMAIL"
# unity-password-var-name: "UNITY_PASSWORD"
# unity-serial-var-name: "UNITY_SERIAL"
# executor:
# name: "unity/windows-2019"
# size: "large"
Expand All @@ -154,9 +148,9 @@ workflows:
- unity/test:
name: "test-osx"
step-name: "Check if the tests run and results are uploaded"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/macos"
editor_version: "2022.3.33f1"
Expand All @@ -169,9 +163,9 @@ workflows:
- unity/test:
name: "test-osx-with-custom-parameters"
step-name: "Check if test filter in custom parameter works"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/macos"
editor_version: "2022.3.33f1"
Expand All @@ -187,9 +181,9 @@ workflows:
- unity/build:
name: "build-linux64-il2cpp"
step-name: "Build StandaloneLinux64"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "linux-il2cpp"
Expand All @@ -204,9 +198,9 @@ workflows:
# - unity/build:
# name: "build-Windows64-il2cpp"
# step-name: "Build StandaloneWindows64 il2cpp"
# unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
# unity-username-var-name: "UNITY_USERNAME"
# unity-email-var-name: "UNITY_EMAIL"
# unity-password-var-name: "UNITY_PASSWORD"
# unity-serial-var-name: "UNITY_SERIAL"
# executor:
# name: "unity/windows-2019"
# size: "large"
Expand All @@ -221,9 +215,9 @@ workflows:
- unity/build:
name: "build-osx-il2cpp"
step-name: "Build macOS IL2CPP"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/macos"
editor_version: "2022.3.33f1"
Expand All @@ -239,9 +233,9 @@ workflows:
- unity/build:
name: "build-linux64-mono"
step-name: "Build StandaloneLinux64"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "base"
Expand All @@ -256,9 +250,9 @@ workflows:
- unity/build:
name: "build-Windows64-mono"
step-name: "Build StandaloneWindows64"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "windows-mono"
Expand All @@ -272,9 +266,9 @@ workflows:
- unity/build:
name: "build-osx-mono"
step-name: "Build StandaloneOSX"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "mac-mono"
Expand All @@ -290,9 +284,9 @@ workflows:
- unity/build:
name: "build-webgl"
step-name: "Build WebGL"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "webgl"
Expand All @@ -307,9 +301,9 @@ workflows:
- unity/build:
name: "build-android"
step-name: "Build Android"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "android"
Expand All @@ -323,9 +317,9 @@ workflows:
- unity/build:
name: "build-ios"
step-name: "Build iOS"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "ios"
Expand All @@ -339,9 +333,9 @@ workflows:
# - unity/build:
# name: "build-tvOS"
# step-name: "Build Apple's tvOS"
# unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
# unity-username-var-name: "UNITY_USERNAME"
# unity-email-var-name: "UNITY_EMAIL"
# unity-password-var-name: "UNITY_PASSWORD"
# unity-serial-var-name: "UNITY_SERIAL"
# executor:
# name: "unity/windows-2019"
# size: "large"
Expand All @@ -358,9 +352,9 @@ workflows:
- unity/build:
name: "build-without-artifacts"
step-name: "Build StandaloneLinux64 with no artifacts"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "base"
Expand All @@ -375,9 +369,9 @@ workflows:
# - unity/build:
# name: "build-with-custom-method-windows"
# step-name: "Build with custom method in Windows"
# unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
# unity-username-var-name: "UNITY_USERNAME"
# unity-email-var-name: "UNITY_EMAIL"
# unity-password-var-name: "UNITY_PASSWORD"
# unity-serial-var-name: "UNITY_SERIAL"
# executor:
# name: "unity/windows-2019"
# size: "large"
Expand All @@ -393,9 +387,9 @@ workflows:
- unity/build:
name: "build-with-custom-method-osx"
step-name: "Build with custom method in macOS"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/macos"
editor_version: "2022.3.33f1"
Expand All @@ -410,9 +404,9 @@ workflows:
- unity/build:
name: "build-with-custom-method-linux"
step-name: "Build with custom method in Linux"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "linux-il2cpp"
Expand All @@ -429,9 +423,9 @@ workflows:
- unity/build:
name: "build-with-workspace"
step-name: "Build StandaloneLinux64 with workspace"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "base"
Expand All @@ -450,9 +444,9 @@ workflows:
- unity/build:
name: "compress-build-with-workspace"
step-name: "Compress build StandaloneLinux64 with workspace"
unity-license-var-name: "UNITY_ENCODED_LICENSE_2021"
unity-username-var-name: "UNITY_USERNAME"
unity-email-var-name: "UNITY_EMAIL"
unity-password-var-name: "UNITY_PASSWORD"
unity-serial-var-name: "UNITY_SERIAL"
executor:
name: "unity/ubuntu"
target_platform: "base"
Expand Down
13 changes: 3 additions & 10 deletions src/commands/prepare-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ description: >
This command prepares the environment for testing or building an Unity project.

parameters:
unity-username-var-name:
unity-email-var-name:
type: env_var_name
default: "UNITY_USERNAME"
default: "UNITY_EMAIL"
description: |
Enter the name of the environment variable containing your Unity username.
unity-password-var-name:
Expand All @@ -18,12 +18,6 @@ parameters:
description: |
Enter the name of the environment variable containing your Unity serial number.
Required if you have a Plus or Pro license.
unity-license-var-name:
type: env_var_name
default: "UNITY_ENCODED_LICENSE"
description: |
Enter the name of the environment variable containing your Unity license file encoded in base64.
Required if you have a Personal license.
cache-version:
type: string
default: "v1"
Expand Down Expand Up @@ -54,10 +48,9 @@ steps:
name: Prepare the environment
no_output_timeout: << parameters.no_output_timeout >>
environment:
PARAM_UNITY_USERNAME_VAR_NAME: << parameters.unity-username-var-name >>
PARAM_UNITY_EMAIL_VAR_NAME: << parameters.unity-email-var-name >>
PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >>
PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >>
PARAM_UNITY_LICENSE_VAR_NAME: << parameters.unity-license-var-name >>
PARAM_PROJECT_PATH: << parameters.project-path >>
SCRIPT_PREPARE_ENV_LINUX: << include(scripts/linux/prepare-env.sh) >>
SCRIPT_PREPARE_ENV_WINDOWS: << include(scripts/windows/prepare-env.sh) >>
Expand Down
16 changes: 13 additions & 3 deletions src/commands/return-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@ description: >
This command returns the license used to build or test the project.

parameters:
unity-username-var-name:
unity-email-var-name:
type: env_var_name
default: "UNITY_USERNAME"
default: "UNITY_EMAIL"
description: |
Enter the name of the environment variable containing your Unity username.
unity-password-var-name:
type: env_var_name
default: "UNITY_PASSWORD"
description: |
Enter the name of the environment variable containing your Unity password.
unity-serial-var-name:
type: env_var_name
default: "UNITY_SERIAL"
description: |
Enter the name of the environment variable containing your Unity serial number.
Required even for personal license.
TODO: Improve documentation on how to extract from personal license, it's something like this:
cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode
For future versions, we could simply request the user to provide the ulf file and we could do the extraction.
Comment on lines +15 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Parameter unity-serial-var-name is defined but not properly integrated

The parameter is defined in the YAML but not passed to the environment variables in the steps section. Additionally, the shell scripts are using a hardcoded unity_serial variable instead of expanding the environment variable name parameter. This needs to be fixed:

  • In src/commands/return-license.yml: Add PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >> to the environment variables
  • In src/scripts/return-license.sh: Add readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" along with other variable expansions
  • In platform-specific scripts (linux/return-license.sh, macos/return-license.sh): Update to use the expanded $unity_serial variable consistently
  • In windows/return-license.sh: Add -serial $Env:UNITY_SERIAL to the Unity command parameters
🔗 Analysis chain

Verify integration of unity-serial-var-name parameter

The new parameter is defined but not explicitly passed to the environment variables in the steps section. Let's verify its usage in the shell scripts.

Also applies to: 24-35


Let me try a different approach to locate the relevant files first.


Now let's check the actual usage of the parameter in the relevant shell scripts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if unity-serial-var-name is properly used in shell scripts

echo "Checking shell scripts for UNITY_SERIAL usage..."

# Check all shell scripts referenced in the YAML
for script in "scripts/linux/return-license.sh" "scripts/windows/return-license.sh" "scripts/macos/return-license.sh" "scripts/return-license.sh" "scripts/utils.sh"; do
  echo "\nChecking $script:"
  if [ -f "$script" ]; then
    # Look for UNITY_SERIAL or unity_serial usage
    rg -i "unity.?serial" "$script" || echo "No direct references found"
    
    # Look for parameter usage
    rg "PARAM_UNITY_SERIAL_VAR_NAME" "$script" || echo "No parameter references found"
  else
    echo "Script not found: $script"
  fi
done

Length of output: 2101


Script:

#!/bin/bash
# Find all shell scripts in the repository
echo "Finding all shell scripts in the repository..."
fd -e sh

# Find all YAML files that might reference the parameter
echo -e "\nFinding YAML files that mention unity-serial..."
rg -l -i "unity.?serial" -g "*.yml" -g "*.yaml"

Length of output: 1010


Script:

#!/bin/bash
# Check the content of return-license scripts
echo "Checking src/scripts/return-license.sh..."
cat src/scripts/return-license.sh

echo -e "\nChecking src/scripts/linux/return-license.sh..."
cat src/scripts/linux/return-license.sh

echo -e "\nChecking src/scripts/macos/return-license.sh..."
cat src/scripts/macos/return-license.sh

echo -e "\nChecking src/scripts/windows/return-license.sh..."
cat src/scripts/windows/return-license.sh

# Also check the YAML file to see how the parameter is passed
echo -e "\nChecking how the parameter is used in return-license.yml..."
cat src/commands/return-license.yml

Length of output: 4212


steps:
- run:
name: Return the Unity license
environment:
PARAM_UNITY_USERNAME_VAR_NAME: << parameters.unity-username-var-name >>
PARAM_UNITY_EMAIL_VAR_NAME: << parameters.unity-email-var-name >>
PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >>
PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >>
SCRIPT_RETURN_LICENSE_LINUX: << include(scripts/linux/return-license.sh) >>
SCRIPT_RETURN_LICENSE_WINDOWS: << include(scripts/windows/return-license.sh) >>
SCRIPT_RETURN_LICENSE_MACOS: << include(scripts/macos/return-license.sh) >>
Expand Down
Loading