Skip to content

Commit a8d9a2f

Browse files
authored
De-flaky the unity installation in CI (#410)
1 parent bf5fba6 commit a8d9a2f

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

.github/workflows/build_starter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
echo "::set-output name=unity_branch::${{ github.event.inputs.unity_branch }}"
9999
echo "::set-output name=additional_cmake_flags::${{ github.event.inputs.unity_branch }}"
100100
else
101-
echo "::set-output name=platform::'Android,iOS,Windows,macOS,Linux'"
101+
echo "::set-output name=platform::'Android,iOS,Windows,macOS,Linux,Playmode'"
102102
echo "::set-output name=release_label::nightly-$(date "+%Y%m%d-%H%M%S")"
103103
echo "::set-output name=release_version::NoVersion"
104104
echo "::set-output name=apis::'analytics,auth,crashlytics,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage'"

.github/workflows/integration_tests.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ on:
55
workflow_dispatch:
66
inputs:
77
packaged_sdk_run_id:
8-
description: 'run # of "Firebase Unity SDK build" workflow'
9-
default: '0'
10-
required: true
8+
description: 'run # of "Firebase Unity SDK build" workflow. (If Leave it empty, the latest released Unity SDK will be used.)'
119
unity_versions:
1210
description: 'Unity version'
1311
default: '2019'
@@ -194,15 +192,16 @@ jobs:
194192
U3D_SKIP_UPDATE_CHECK: 1
195193
steps:
196194
- uses: actions/checkout@v2
195+
- uses: ruby/setup-ruby@v1
196+
with:
197+
ruby-version: 3.0.2
197198
- name: Install Unity installer (U3D)
198199
uses: nick-invision/retry@v2
199200
with:
200201
timeout_minutes: 10
201202
max_attempts: 3
202203
shell: bash
203-
command: |
204-
gem install u3d -v 1.2.3
205-
u3d available
204+
command: gem install u3d -v 1.2.3
206205
- name: Setup python
207206
uses: actions/setup-python@v2
208207
with:
@@ -218,7 +217,7 @@ jobs:
218217
timeout_minutes: 30
219218
max_attempts: 3
220219
shell: bash
221-
command: |
220+
command: |
222221
python scripts/gha/unity_installer.py --install \
223222
--platforms ${{ matrix.platform }} \
224223
--version ${{ matrix.unity_version }}
@@ -238,6 +237,7 @@ jobs:
238237
run: |
239238
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
240239
- name: Fetch prebuilt packaged SDK from previous run
240+
if: ${{ github.event.inputs.packaged_sdk_run_id != '' }}
241241
uses: dawidd6/action-download-artifact@v2
242242
with:
243243
name: 'firebase_unity_sdk.zip'
@@ -247,7 +247,12 @@ jobs:
247247
timeout-minutes: 240
248248
shell: bash
249249
run: |
250-
unzip -q firebase_unity_sdk.zip -d ~/Downloads/
250+
if [[ -n "${{ github.event.inputs.packaged_sdk_run_id }}" ]]; then
251+
unzip -q firebase_unity_sdk.zip -d ~/Downloads/
252+
else
253+
curl -L "https://firebase.google.com/download/unity" -o ~/Downloads/firebase_unity_sdk.zip
254+
unzip -q ~/Downloads/firebase_unity_sdk.zip -d ~/Downloads/
255+
fi
251256
python scripts/gha/build_testapps.py \
252257
--t ${{ needs.check_and_prepare.outputs.apis }} \
253258
--u $( python scripts/gha/print_matrix_configuration.py -k version -u ${{matrix.unity_version}}) \
@@ -382,17 +387,20 @@ jobs:
382387
LC_ALL: en_US.UTF-8
383388
LANG: en_US.UTF-8
384389
U3D_PASSWORD: ""
390+
# Disable checking for U3D updates, since it is buggy
391+
U3D_SKIP_UPDATE_CHECK: 1
385392
steps:
386393
- uses: actions/checkout@v2
394+
- uses: ruby/setup-ruby@v1
395+
with:
396+
ruby-version: 3.0.2
387397
- name: Install Unity installer (U3D)
388398
uses: nick-invision/retry@v2
389399
with:
390400
timeout_minutes: 10
391401
max_attempts: 3
392402
shell: bash
393-
command: |
394-
gem install u3d
395-
u3d available
403+
command: gem install u3d -v 1.2.3
396404
- name: Setup python
397405
uses: actions/setup-python@v2
398406
with:
@@ -405,10 +413,10 @@ jobs:
405413
- name: Install Unity
406414
uses: nick-invision/retry@v2
407415
with:
408-
timeout_minutes: 15
416+
timeout_minutes: 20
409417
max_attempts: 3
410418
shell: bash
411-
command: |
419+
command: |
412420
python scripts/gha/unity_installer.py --install \
413421
--version ${{ matrix.unity_version }}
414422
- name: Activate Unity license
@@ -427,15 +435,21 @@ jobs:
427435
run: |
428436
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
429437
- name: Fetch prebuilt packaged SDK from previous run
438+
if: ${{ github.event.inputs.packaged_sdk_run_id != '' }}
430439
uses: dawidd6/action-download-artifact@v2
431440
with:
432441
name: 'firebase_unity_sdk.zip'
433442
workflow: 'build_starter.yml'
434-
run_id: ${{ github.event.inputs.packaged_sdk_run_id }}
443+
run_id: ${{ github.event.inputs.packaged_sdk_run_id }}
435444
- name: Run Playmode (in editor mode) integration tests
436445
shell: bash
437446
run: |
438-
unzip -q firebase_unity_sdk.zip -d ~/Downloads/
447+
if [[ -n "${{ github.event.inputs.packaged_sdk_run_id }}" ]]; then
448+
unzip -q firebase_unity_sdk.zip -d ~/Downloads/
449+
else
450+
curl -L "https://firebase.google.com/download/unity" -o ~/Downloads/firebase_unity_sdk.zip
451+
unzip -q ~/Downloads/firebase_unity_sdk.zip -d ~/Downloads/
452+
fi
439453
python scripts/gha/build_testapps.py \
440454
--t ${{ needs.check_and_prepare.outputs.apis }} \
441455
--u $( python scripts/gha/print_matrix_configuration.py -k version -u ${{matrix.unity_version}}) \

scripts/gha/unity_installer.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
6969
7070
(3) License release:
71-
unity_installer.py --release_license --version 2017.3.1f1 --logfile return.log
71+
unity_installer.py --release_license --version 2019 --logfile return.log
7272
7373
"""
7474

@@ -83,7 +83,7 @@
8383
from print_matrix_configuration import UNITY_SETTINGS
8484

8585

86-
_CMD_TIMEOUT = 600
86+
_CMD_TIMEOUT = 900
8787

8888
_DEFALUT = "Default"
8989
_ANDROID = "Android"
@@ -109,7 +109,7 @@
109109
"release_license", False,
110110
"Release an activated Unity license. Supply --version and --logfile.")
111111

112-
flags.DEFINE_string("version", None, "Version string, e.g. 2017.3.1f1")
112+
flags.DEFINE_string("version", None, "Major version string, e.g. 2018")
113113
flags.DEFINE_string("license_file", None, "Path to the license file.")
114114
flags.DEFINE_string("username", None, "username for a Unity account.")
115115
flags.DEFINE_string("password", None, "password for that Unity account.")
@@ -139,6 +139,7 @@ def main(argv):
139139
raise app.UsageError("Too many command-line arguments.")
140140

141141
if FLAGS.install:
142+
uninstall_unity(FLAGS.version)
142143
install_unity(FLAGS.version, FLAGS.platforms)
143144

144145
if FLAGS.activate_license:
@@ -181,6 +182,17 @@ def install_unity(unity_version, platforms):
181182
logging.info("Finished installing Unity.")
182183

183184

185+
def uninstall_unity(unity_version):
186+
"""Uninstalls Unity and build supports (packages)."""
187+
# Cleaning up installed Unity.
188+
os = get_os()
189+
unity_full_version = UNITY_SETTINGS[unity_version][os]["version"]
190+
191+
u3d = find_u3d()
192+
run([u3d, "uninstall", "--trace", unity_full_version], check=False)
193+
logging.info("Finished uninstalling Unity.")
194+
195+
184196
def activate_license(username, password, serial_ids, logfile, unity_version):
185197
"""Activates an installation of Unity with a license."""
186198
# Unity can report a license activation failure even if the activation

0 commit comments

Comments
 (0)