Skip to content

Commit 1be374e

Browse files
Merge pull request #216 from firebase/feature/aks-flaky-android-builds
Work around flaky integration test builds due to gtest
2 parents d580b33 + 180261e commit 1be374e

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

scripts/gha/build_testapps.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def _build(
247247
os.chdir(project_dir)
248248

249249
_run_setup_script(root_dir, project_dir)
250-
250+
251251
failures = []
252252

253253
if _DESKTOP in platforms:
@@ -339,20 +339,7 @@ def _build_android(project_dir, sdk_dir):
339339
f.write("systemProp.firebase_cpp_sdk.dir=" + sdk_dir + "\n")
340340
# This will log the versions of dependencies for debugging purposes.
341341
_run([gradlew, "dependencies", "--configuration", "debugCompileClasspath"])
342-
# Building for Android has a known issue that can be worked around by
343-
# simply building again. Since building from source takes a while, we don't
344-
# want to retry the build if a different error occurred.
345-
build_args = [gradlew, "assembleDebug", "--stacktrace"]
346-
result = _run(args=build_args, capture_output=True, text=True, check=False)
347-
if result.returncode:
348-
if "Execution failed for task ':generateJsonModel" in result.stderr:
349-
logging.info("Task failed for ':generateJsonModel<target>'. Retrying.")
350-
_run(args=build_args)
351-
else:
352-
logging.error(result.stderr)
353-
raise subprocess.CalledProcessError(
354-
returncode=result.returncode,
355-
cmd=build_args)
342+
_run([gradlew, "assembleDebug", "--stacktrace"])
356343

357344

358345
def _validate_android_environment_variables():
@@ -502,15 +489,18 @@ def _build_ios(
502489
output_dir=build_dir, configuration="Debug")
503490

504491

505-
# This script is responsible for copying shared files into the integration
506-
# test projects. Should be executed before performing any builds.
492+
# This should be executed before performing any builds.
507493
def _run_setup_script(root_dir, testapp_dir):
508-
"""Runs the setup_integration_tests.py script if needed."""
494+
"""Runs the setup_integration_tests.py script."""
495+
# This script will download gtest to its own directory.
496+
# The CMake projects were configured to download gtest, but this was
497+
# found to be flaky and errors didn't propagate up the build system
498+
# layers. The workaround is to download gtest with this script and copy it.
499+
downloader_dir = os.path.join(root_dir, "testing", "test_framework")
500+
_run([sys.executable, os.path.join(downloader_dir, "download_googletest.py")])
501+
# Copies shared test framework files into the project, including gtest.
509502
script_path = os.path.join(root_dir, "setup_integration_tests.py")
510-
if os.path.isfile(script_path):
511-
_run([sys.executable, script_path, testapp_dir])
512-
else:
513-
logging.info("setup_integration_tests.py not found")
503+
_run([sys.executable, script_path, testapp_dir])
514504

515505

516506
def _run(args, timeout=2400, capture_output=False, text=None, check=True):

0 commit comments

Comments
 (0)