Skip to content

Commit de6f798

Browse files
authored
Update build testapp timeout & collect testapp build logs (#519)
1 parent ba13b11 commit de6f798

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

.github/workflows/integration_tests.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,16 @@ jobs:
243243
uses: actions/upload-artifact@v3
244244
if: ${{ !cancelled() }}
245245
with:
246-
name: log-artifact
246+
name: build_and_test_results
247247
path: build-results-${{ steps.matrix_info.outputs.info }}*
248248
retention-days: ${{ env.artifactRetentionDays }}
249+
- name: Upload build logs artifact
250+
uses: actions/upload-artifact@v3
251+
if: ${{ !cancelled() }}
252+
with:
253+
name: testapps-build-logs-${{ steps.matrix_info.outputs.info }}
254+
path: testapps-${{ steps.matrix_info.outputs.info }}/build-logs
255+
retention-days: ${{ env.artifactRetentionDays }}
249256
- name: Upload Android integration tests artifact
250257
uses: actions/upload-artifact@v3
251258
if: ${{ contains(matrix.platform, 'Android') && !cancelled() }}
@@ -306,7 +313,7 @@ jobs:
306313
uses: actions/download-artifact@v3
307314
with:
308315
path: test_results
309-
name: log-artifact
316+
name: build_and_test_results
310317
- name: Update PR label and comment
311318
if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }}
312319
shell: bash
@@ -404,7 +411,7 @@ jobs:
404411
uses: actions/upload-artifact@v3
405412
if: ${{ !cancelled() }}
406413
with:
407-
name: log-artifact
414+
name: build_and_test_results
408415
path: test-results-${{ steps.matrix_info.outputs.info }}*
409416
retention-days: ${{ env.artifactRetentionDays }}
410417
- name: Update PR label and comment
@@ -499,15 +506,15 @@ jobs:
499506
if: ${{ !cancelled() }}
500507
uses: actions/upload-artifact@v3
501508
with:
502-
name: log-artifact
509+
name: build_and_test_results
503510
path: testapps/test-results-${{ steps.matrix_info.outputs.info }}*
504511
retention-days: ${{ env.artifactRetentionDays }}
505512
- name: Download log artifacts
506513
if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }}
507514
uses: actions/download-artifact@v3
508515
with:
509516
path: test_results
510-
name: log-artifact
517+
name: build_and_test_results
511518
- name: Update PR label and comment
512519
shell: bash
513520
if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }}
@@ -546,7 +553,7 @@ jobs:
546553
uses: actions/download-artifact@v3
547554
with:
548555
path: test_results
549-
name: log-artifact
556+
name: build_and_test_results
550557
# Use a different token to remove the "in-progress" label,
551558
# to allow the removal to trigger the "Check Labels" workflow.
552559
- name: Generate token for GitHub API

scripts/gha/build_testapps.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def main(argv):
371371

372372
if platforms:
373373
_collect_integration_tests(config, testapps, root_output_dir, output_dir, FLAGS.artifact_name)
374+
_collect_build_logs(root_output_dir, output_dir, FLAGS.artifact_name)
374375
build_passes = _summarize_build_results(
375376
testapps=testapps,
376377
platforms=platforms,
@@ -471,14 +472,9 @@ def build_testapp(dir_helper, api_config, ios_config, target):
471472
shutil.copy(
472473
os.path.join(dir_helper.root_dir, api_config.entitlements),
473474
os.path.join(dir_helper.unity_project_editor_dir, "dev.entitlements"))
474-
try:
475-
# This is a patch. Unity 2018 retrun non 0 value, but it build successfully
476-
_run(arg_builder.get_args_to_open_project(build_flags))
477-
logging.info("Finished building target %s xcode project", target)
478-
except(subprocess.SubprocessError, RuntimeError) as e:
479-
logging.info(str(e))
480-
finally:
481-
run_xcodebuild(dir_helper=dir_helper, ios_config=ios_config, device_type = device_type)
475+
_run(arg_builder.get_args_to_open_project(build_flags))
476+
logging.info("Finished building target %s xcode project", target)
477+
run_xcodebuild(dir_helper=dir_helper, ios_config=ios_config, device_type = device_type)
482478
else:
483479
if api_config.minify:
484480
build_flags += ["-AppBuilderHelper.minify", api_config.minify]
@@ -637,6 +633,31 @@ def run_xcodebuild(dir_helper, ios_config, device_type):
637633
configuration=ios_config.configuration)
638634

639635

636+
def _collect_build_logs(root_output_dir, output_dir, artifact_name):
637+
log_extension = ".build.log"
638+
log_paths = []
639+
for file_dir, _, file_names in os.walk(output_dir):
640+
for file_name in file_names:
641+
if file_name.endswith(log_extension):
642+
log_paths.append(os.path.join(file_dir, file_name))
643+
logging.info(root_output_dir)
644+
logging.info(output_dir)
645+
logging.info("Collecting build log artifacts from: %s", log_paths)
646+
647+
if not log_paths:
648+
return
649+
650+
artifact_path = os.path.join(root_output_dir, "testapps-" + artifact_name, "build-logs")
651+
logging.info("Collecting build log artifacts to: %s", artifact_path)
652+
for path in log_paths:
653+
file_name = os.path.basename(path)
654+
testapp_name = os.path.basename(os.path.dirname(path))
655+
log_output_dir = os.path.join(artifact_path, testapp_name)
656+
if not os.path.exists(log_output_dir):
657+
os.makedirs(log_output_dir)
658+
shutil.move(path, os.path.join(log_output_dir, file_name))
659+
660+
640661
def _collect_integration_tests(config, testapps, root_output_dir, output_dir, artifact_name):
641662
"""Collect testapps to dir /${output_dir}/testapps-${artifact_name}/${platform}/${api}.
642663
In CI, testapps will be upload as Artifacts.
@@ -1037,7 +1058,7 @@ def _fix_path(path):
10371058
return os.path.abspath(os.path.expanduser(path))
10381059

10391060

1040-
def _run(args, timeout=3000, capture_output=False, text=None, check=True):
1061+
def _run(args, timeout=1200, capture_output=False, text=None, check=True):
10411062
"""Executes a command in a subprocess."""
10421063
logging.info("Running in subprocess: %s", " ".join(args))
10431064
return subprocess.run(
@@ -1190,7 +1211,7 @@ def make_log_path(self, name):
11901211
(str) Absolute path.
11911212
11921213
"""
1193-
return os.path.join(self.output_dir, name + ".log")
1214+
return os.path.join(self.output_dir, name + ".build.log")
11941215

11951216

11961217
if __name__ == "__main__":

0 commit comments

Comments
 (0)