Skip to content

Commit 2013803

Browse files
authored
Update firestore code & enable firestore test in CI (#165)
1 parent 4cdae17 commit 2013803

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

.github/workflows/integration_tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ on:
2323
required: true
2424
apis:
2525
description: 'CSV of apis to build and test'
26-
# TODO: firestore is excluded, because it fails to build on Unity 2017
27-
default: 'analytics,auth,crashlytics,database,dynamic_links,functions,installations,messaging,remote_config,storage'
26+
default: 'analytics,auth,crashlytics,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage'
2827
required: true
2928
mobile_test_on:
3029
description: 'Run mobile tests on real and/or virtual devices? (separated by commas)'
3130
default: 'real,virtual'
3231
required: true
3332
sdk_url:
3433
description: 'Download unity sdk from this URL'
35-
default: 'https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_8.5.0.zip'
34+
default: 'https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_8.7.0.zip'
3635
required: true
3736
use_expanded_matrix:
3837
description: 'Use an expanded matrix? Note: above config will be ignored.'
@@ -263,7 +262,7 @@ jobs:
263262
unzip -q firebase_unity_sdk.zip -d ~/Downloads/
264263
else
265264
if [[ -z "${{ github.event.inputs.sdk_url }}" ]];then
266-
sdk_url="https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_8.5.0.zip"
265+
sdk_url="https://dl.google.com/firebase/sdk/unity/firebase_unity_sdk_8.7.0.zip"
267266
else
268267
sdk_url=${{ github.event.inputs.sdk_url }}
269268
fi

scripts/gha/build_testapps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,10 @@ def _copy_unity_assets(dir_helper, files_to_ignore):
756756
if any(name in copied_file for name in files_to_ignore):
757757
logging.info("Removing %s", copied_file)
758758
os.remove(copied_file)
759-
759+
if "firestore" in dest.lower():
760+
logging.info("Removing firestore a) Tests b) Firebase/Editor/Builder.cs")
761+
dir_util.remove_tree(os.path.join(dir_helper.unity_project_assets_dir, "Tests"))
762+
os.remove(os.path.join(dir_helper.unity_project_assets_dir, "Firebase", "Editor", "Builder.cs"))
760763

761764
# The menu scene will timeout to the automated version of the app,
762765
# while leaving an option in manual testing to select the manual version.

scripts/gha/integration_testing/automated_testapp/AutomatedTestRunner.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public class AutomatedTestRunner {
1313
private Func<Task>[] tests = null;
1414
// The index of the currently running test.
1515
private int currentTestIndex = -1;
16+
// List of exceptions thrown in the currently running test.
17+
private List<Exception> testExceptions = new List<Exception>();
18+
// Whether the currently running test is expected to fail.
19+
private bool postTestIgnoredFailureCheckEnabled = true;
1620
// Name and index of the current running test function.
1721
public string CurrentTestDescription { get; private set; }
1822
// The Task that represents the currently running test.
@@ -59,6 +63,12 @@ public static AutomatedTestRunner CreateTestRunner(
5963
return new AutomatedTestRunner(testsToRun, testLabManager, logFunc, testNames);
6064
}
6165

66+
public void FailTest(String reason) {
67+
var e = new Exception(reason);
68+
testExceptions.Add(e);
69+
throw e;
70+
}
71+
6272
/// <summary>
6373
/// Configures a TestLabManager object to be used with Firebase Test Lab. Required even
6474
/// if not using Firebase Test Lab.
@@ -129,8 +139,18 @@ public void Update() {
129139
CurrentTestResult.Exception.Flatten().ToString()));
130140
++failedTestsCount;
131141
failingTestDescriptions.Add(CurrentTestDescription);
142+
} else if (postTestIgnoredFailureCheckEnabled && testExceptions.Count > 0) {
143+
LogFunc(String.Format("Test {0} failed with {1} exception(s).\n\n",
144+
CurrentTestDescription, testExceptions.Count.ToString()));
145+
for (int i = 0; i < testExceptions.Count; ++i) {
146+
LogFunc(String.Format("Exception message ({0}): {1}\n\n", (i + 1).ToString(),
147+
testExceptions[i].ToString()));
148+
}
149+
++failedTestsCount;
150+
failingTestDescriptions.Add(CurrentTestDescription);
132151
} else {
133-
// If the task was not faulted, assume it succeeded.
152+
// If the task was not faulted and no exceptions have been recorded,
153+
// assume it succeeded.
134154
LogFunc("Test " + CurrentTestDescription + " passed.");
135155
++passedTestsCount;
136156
}
@@ -158,6 +178,8 @@ public void Update() {
158178

159179
void StartNextTest() {
160180
CurrentTestResult = null;
181+
postTestIgnoredFailureCheckEnabled = true;
182+
testExceptions.Clear();
161183
++currentTestIndex;
162184
if (currentTestIndex < tests.Length && tests[currentTestIndex] != null) {
163185
// Start running the next test.
@@ -179,6 +201,11 @@ void StartNextTest() {
179201
startTime = Time.time;
180202
}
181203
}
204+
205+
// Informs the test runner that the currently running test contains expected assertion failures.
206+
public void DisablePostTestIgnoredFailureCheck() {
207+
postTestIgnoredFailureCheckEnabled = false;
208+
}
182209
}
183210

184211
// This is a class for forcing code to run on the main thread.

scripts/gha/print_matrix_configuration.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,18 @@
5858

5959
MINIMAL_KEY: {
6060
"platform": ["Linux"],
61-
"apis": "firestore"
6261
},
6362

6463
EXPANDED_KEY: {
6564
"build_os": ["macos-latest"],
6665
"unity_version": ["2020", "2019", "2018"],
6766
"android_device": ["android_target", "android_latest", "emulator_target", "emulator_latest", "emulator_32bit"],
6867
"ios_device": ["ios_min", "ios_target", "ios_latest", "simulator_min", "simulator_target", "simulator_latest"],
69-
"apis": "crashlytics,database",
7068
}
7169
},
7270
"config": {
7371
"platform": "Windows,macOS,Linux",
74-
"apis": "analytics,auth,crashlytics,database,dynamic_links,functions,installations,messaging,remote_config,storage",
72+
"apis": "analytics,auth,crashlytics,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage",
7573
"mobile_test_on": "real,virtual"
7674
}
7775
},

scripts/gha/unity_installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def main(argv):
149149
username = FLAGS.username
150150
password = FLAGS.password
151151
serial_ids = FLAGS.serial_ids
152-
activate_license(username, password, serial_ids, FLAGS.logfile, FLAGS.version)
152+
return activate_license(username, password, serial_ids, FLAGS.logfile, FLAGS.version)
153153

154154
if FLAGS.release_license:
155155
release_license(FLAGS.logfile, FLAGS.version)

0 commit comments

Comments
 (0)