Skip to content

Commit a6c5bad

Browse files
authored
Install Unity on GHA with a different tool (#532)
* Add Unity install fallback logic * Update unity_installer.py * Try downloading the installer differently * Update action.yml * Update action.yml * Download the installer a different way * More attempts * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Update build_windows.yml * Use setup unity for all builds * Update integration test installer method * Update integration_tests.yml * Update integration_tests.yml * Update integration_tests.yml * Update integration_tests.yml * Update integration_tests.yml * Update integration_tests.yml * Update integration_tests.yml * Update scripts * Fix timeout settings
1 parent 1ceebe6 commit a6c5bad

File tree

9 files changed

+146
-53
lines changed

9 files changed

+146
-53
lines changed

.github/workflows/build_android.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ jobs:
101101
shell: bash
102102
run: |
103103
pip install -r scripts/gha/requirements.txt
104-
105-
- id: unity_setup
106-
uses: ./gha/unity
104+
105+
- name: Setup Unity
106+
uses: kuler90/setup-unity@v1
107107
timeout-minutes: 30
108108
with:
109-
version: ${{ inputs.unity_version }}
110-
platforms: ${{ inputs.unity_platform_name }}
109+
unity-version: 2020.3.34f1
110+
unity-modules: android
111111

112112
- name: Display Swig Version
113113
shell: bash

.github/workflows/build_ios.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ jobs:
8181
run: |
8282
pip install -r scripts/gha/requirements.txt
8383
84-
- id: unity_setup
85-
uses: ./gha/unity
84+
- name: Setup Unity
85+
uses: kuler90/setup-unity@v1
8686
timeout-minutes: 30
8787
with:
88-
version: ${{ inputs.unity_version }}
89-
platforms: ${{ inputs.unity_platform_name }}
88+
unity-version: 2020.3.34f1
89+
unity-modules: ios
9090

9191
- name: Build SDK (iOS)
9292
timeout-minutes: 90

.github/workflows/build_linux.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ jobs:
8383
run: |
8484
sudo apt install openssl
8585
86-
- id: unity_setup
87-
uses: ./gha/unity
86+
- name: Setup Unity
87+
uses: kuler90/setup-unity@v1
8888
timeout-minutes: 30
8989
with:
90-
version: ${{ inputs.unity_version }}
91-
platforms: ${{ inputs.unity_platform_name }}
90+
unity-version: 2020.3.40f1
9291

9392
- name: Setup Swig Env
9493
shell: bash

.github/workflows/build_macos.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ jobs:
9797
# brew won't overwrite MacOS system default OpenSSL, so force it here.
9898
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl --installed)" >> $GITHUB_ENV
9999
100-
- id: unity_setup
101-
uses: ./gha/unity
100+
- name: Setup Unity
101+
uses: kuler90/setup-unity@v1
102102
timeout-minutes: 30
103103
with:
104-
version: ${{ inputs.unity_version }}
105-
platforms: ${{ inputs.unity_platform_name }}
104+
unity-version: 2020.3.34f1
105+
# Include iOS for the editor tools
106+
unity-modules: ios
106107

107108
- name: Setup Swig Env
108109
shell: bash

.github/workflows/build_tvos.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ jobs:
108108
run: |
109109
pod repo add cocoapods https://github.com/CocoaPods/Specs.git
110110
111-
- id: unity_setup
112-
uses: ./gha/unity
111+
- name: Setup Unity
112+
uses: kuler90/setup-unity@v1
113113
timeout-minutes: 30
114114
with:
115-
version: ${{ inputs.unity_version }}
116-
platforms: ${{ inputs.unity_platform_name }}
115+
unity-version: 2020.3.34f1
116+
unity-modules: appletv
117117

118118
- name: Build SDK (tvOS)
119119
timeout-minutes: 90

.github/workflows/build_windows.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ jobs:
8989
run: |
9090
choco install openssl -r
9191
92-
- id: unity_setup
93-
uses: ./gha/unity
92+
- name: Setup Unity
93+
uses: kuler90/setup-unity@v1
9494
timeout-minutes: 30
9595
with:
96-
version: ${{ inputs.unity_version }}
97-
platforms: ${{ inputs.unity_platform_name }}
96+
unity-version: 2020.3.34f1
9897

9998
- name: Setup Swig Env
10099
shell: bash

.github/workflows/integration_tests.yml

Lines changed: 101 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,72 @@ jobs:
184184
- name: setup Xcode version
185185
if: runner.os == 'macOS'
186186
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
187-
- id: unity_setup
188-
uses: ./gha/unity
187+
188+
- name: Setup Unity (Android)
189+
if: ${{ contains(matrix.platform, 'Android') }}
190+
uses: kuler90/setup-unity@v1
191+
timeout-minutes: 30
192+
with:
193+
unity-version: 2020.3.34f1
194+
unity-modules: android
195+
# Because of a bug, include iOS for the editor tools
196+
- name: Setup Unity (Android, Part 2)
197+
if: ${{ contains(matrix.platform, 'Android') }}
198+
uses: kuler90/setup-unity@v1
199+
timeout-minutes: 30
200+
with:
201+
unity-version: 2020.3.34f1
202+
unity-modules: ios
203+
204+
- name: Setup Unity (iOS)
205+
if: ${{ contains(matrix.platform, 'iOS') }}
206+
uses: kuler90/setup-unity@v1
207+
timeout-minutes: 30
208+
with:
209+
unity-version: 2020.3.34f1
210+
unity-modules: ios
211+
212+
- name: Setup Unity (Desktop Windows)
213+
if: ${{ !contains(matrix.platform, 'Android') && !contains(matrix.platform, 'iOS') && runner.os != 'macOS' }}
214+
uses: kuler90/setup-unity@v1
215+
timeout-minutes: 30
216+
with:
217+
unity-version: 2020.3.34f1
218+
unity-modules: mac-mono
219+
- name: Setup Unity (Desktop Windows Part 2)
220+
if: ${{ !contains(matrix.platform, 'Android') && !contains(matrix.platform, 'iOS') && runner.os != 'macOS' }}
221+
uses: kuler90/setup-unity@v1
222+
timeout-minutes: 30
223+
with:
224+
unity-version: 2020.3.34f1
225+
unity-modules: linux-mono
226+
227+
- name: Setup Unity (Desktop macOS)
228+
if: ${{ !contains(matrix.platform, 'Android') && !contains(matrix.platform, 'iOS') && runner.os == 'macOS' }}
229+
uses: kuler90/setup-unity@v1
230+
timeout-minutes: 30
231+
with:
232+
unity-version: 2020.3.34f1
233+
unity-modules: windows-mono
234+
- name: Setup Unity (Desktop macOS Part 2)
235+
if: ${{ !contains(matrix.platform, 'Android') && !contains(matrix.platform, 'iOS') && runner.os == 'macOS' }}
236+
uses: kuler90/setup-unity@v1
189237
timeout-minutes: 30
190238
with:
191-
version: ${{ matrix.unity_version }}
192-
platforms: ${{ matrix.platform }}
193-
username: ${{ secrets.UNITY_USERNAME }}
194-
password: ${{ secrets.UNITY_PASSWORD }}
195-
serial_ids: ${{ secrets.SERIAL_ID }}
239+
unity-version: 2020.3.34f1
240+
unity-modules: linux-mono
241+
242+
- name: Activate Unity license
243+
shell: bash
244+
run: |
245+
python gha/unity/unity_installer.py --activate_license \
246+
--version 2020 \
247+
--username "${{ secrets.UNITY_USERNAME }}" \
248+
--password "${{ secrets.UNITY_PASSWORD }}" \
249+
--serial_ids "${{ secrets.SERIAL_ID }}" \
250+
--logfile "testapps/activate_license.log"
251+
cat testapps/activate_license.log
252+
196253
- name: Prepare for integration tests
197254
timeout-minutes: 10
198255
shell: bash
@@ -218,21 +275,28 @@ jobs:
218275
fi
219276
python scripts/gha/build_testapps.py \
220277
--t ${{ needs.check_and_prepare.outputs.apis }} \
221-
--u "${{ steps.unity_setup.outputs.unity_version }}" \
278+
--u 2020.3.34f1 \
222279
--p "${{ matrix.platform }}" \
223280
--ios_sdk "${{ matrix.ios_sdk }}" \
224281
--plugin_dir ~/Downloads/firebase_unity_sdk \
225282
--output_directory "${{ github.workspace }}" \
226283
--artifact_name "${{ steps.matrix_info.outputs.info }}" \
227284
--force_latest_runtime \
228285
--ci
286+
229287
- name: Return Unity license
230-
# Always returns true, even when job failed or canceled. But will not run when a critical failure prevents the task from running.
231288
if: always()
232-
uses: ./gha/unity
289+
uses: nick-invision/retry@v2
233290
with:
234-
version: ${{ matrix.unity_version }}
235-
release_license: "true"
291+
timeout_minutes: 5
292+
max_attempts: 2
293+
shell: bash
294+
command: |
295+
python gha/unity/unity_installer.py --release_license \
296+
--version 2020 \
297+
--logfile "testapps/release_license.log"
298+
cat testapps/release_license.log
299+
236300
- name: Prepare results summary artifact
237301
if: ${{ !cancelled() }}
238302
shell: bash
@@ -358,14 +422,23 @@ jobs:
358422
shell: bash
359423
run: |
360424
pip install -r scripts/gha/requirements.txt
361-
- id: unity_setup
362-
uses: ./gha/unity
425+
- name: Setup Unity
426+
uses: kuler90/setup-unity@v1
363427
timeout-minutes: 30
364428
with:
365-
version: ${{ matrix.unity_version }}
366-
username: ${{ secrets.UNITY_USERNAME }}
367-
password: ${{ secrets.UNITY_PASSWORD }}
368-
serial_ids: ${{ secrets.SERIAL_ID }}
429+
unity-version: 2020.3.34f1
430+
# Install ios for the editor tools
431+
unity-modules: ios
432+
- name: Activate Unity license
433+
shell: bash
434+
run: |
435+
python gha/unity/unity_installer.py --activate_license \
436+
--version 2020 \
437+
--username "${{ secrets.UNITY_USERNAME }}" \
438+
--password "${{ secrets.UNITY_PASSWORD }}" \
439+
--serial_ids "${{ secrets.SERIAL_ID }}" \
440+
--logfile "testapps/activate_license.log"
441+
cat testapps/activate_license.log
369442
- name: Prepare for integration tests
370443
timeout-minutes: 10
371444
shell: bash
@@ -389,20 +462,25 @@ jobs:
389462
fi
390463
python scripts/gha/build_testapps.py \
391464
--t ${{ needs.check_and_prepare.outputs.apis }} \
392-
--u ${{ steps.unity_setup.outputs.unity_version }} \
465+
--u 2020.3.34f1 \
393466
--p Playmode \
394467
--plugin_dir ~/Downloads/firebase_unity_sdk \
395468
--output_directory "${{ github.workspace }}" \
396469
--artifact_name "${{ steps.matrix_info.outputs.info }}" \
397470
--force_latest_runtime \
398471
--ci
399472
- name: Return Unity license
400-
# Always returns true, even when job failed or canceled. But will not run when a critical failure prevents the task from running.
401473
if: always()
402-
uses: ./gha/unity
474+
uses: nick-invision/retry@v2
403475
with:
404-
version: ${{ matrix.unity_version }}
405-
release_license: "true"
476+
timeout_minutes: 5
477+
max_attempts: 2
478+
shell: bash
479+
command: |
480+
python gha/unity/unity_installer.py --release_license \
481+
--version 2020 \
482+
--logfile "testapps/release_license.log"
483+
cat testapps/release_license.log
406484
- name: Prepare results summary artifact
407485
if: ${{ !cancelled() }}
408486
shell: bash

gha/unity/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ runs:
6262
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
6363
echo "U3D_PASSWORD=" >> $GITHUB_ENV
6464
echo "U3D_SKIP_UPDATE_CHECK=1" >> $GITHUB_ENV
65+
- name: Download Unity Fallback
66+
if: inputs.release_license == '' && startsWith(matrix.os, 'windows')
67+
shell: bash
68+
run: |
69+
mkdir -p ~/Downloads
70+
curl -L https://download.unity3d.com/download_unity/9a4c9c70452b/Windows64EditorInstaller/UnitySetup64.exe -o ~/Downloads/UnityInstaller.exe
71+
ls -l ~/Downloads/
6572
- id: unity_installation
6673
name: Install Unity
6774
if: inputs.release_license == ''

gha/unity/unity_installer.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
7373
"""
7474

75+
import os
7576
import platform
7677
import shutil
7778
import subprocess
@@ -84,7 +85,7 @@
8485
_CMD_TIMEOUT = 900
8586
_MAX_ATTEMPTS = 3
8687

87-
_DEFALUT = "Default"
88+
_DEFAULT = "Default"
8889
_ANDROID = "Android"
8990
_IOS = "iOS"
9091
_TVOS = "tvOS"
@@ -199,7 +200,7 @@ def install_unity(unity_version, platforms):
199200
# for platforms other than the running OS, or embedded Android SDK/NDK.
200201
os = get_os()
201202
unity_full_version = UNITY_SETTINGS[unity_version][os]["version"]
202-
package_list = UNITY_SETTINGS[unity_version][os]["packages"][_DEFALUT]
203+
package_list = UNITY_SETTINGS[unity_version][os]["packages"][_DEFAULT]
203204
if platforms:
204205
for p in platforms:
205206
if UNITY_SETTINGS[unity_version][os]["packages"][p]:
@@ -226,7 +227,7 @@ def install_unity(unity_version, platforms):
226227
else:
227228
break
228229
attempt_num += 1
229-
230+
230231
logging.info("Finished installing Unity.")
231232

232233
unity_path = get_unity_path(unity_version)
@@ -313,9 +314,17 @@ def get_unity_executable(version):
313314
# https://github.com/DragonBox/u3d
314315
full_version = UNITY_SETTINGS[version][get_os()]["version"]
315316
if platform.system() == "Windows":
316-
return "C:/Program Files/Unity_%s/editor/unity.exe" % full_version
317+
unity_path = "C:/Program Files/Unity_%s/editor/unity.exe" % full_version
318+
if os.path.exists(unity_path):
319+
return unity_path
320+
else:
321+
return "C:/Program Files/Unity/Hub/Editor/2020.3.34f1/Editor/Unity.exe"
317322
elif platform.system() == "Darwin":
318-
return "/Applications/Unity_%s/Unity.app/Contents/MacOS/Unity" % full_version
323+
unity_path = "/Applications/Unity_%s/Unity.app/Contents/MacOS/Unity" % full_version
324+
if os.path.exists(unity_path):
325+
return unity_path
326+
else:
327+
return "/Applications/Unity/Hub/Editor/2020.3.34f1/Unity.app/Contents/MacOS/Unity"
319328
else:
320329
# /opt/unity-editor-%s/Editor/Unity is the path for Linux expected by U3D,
321330
# but Linux is not yet supported.

0 commit comments

Comments
 (0)