Skip to content

Commit 85ccba4

Browse files
authored
Update build & test summary report (#419)
Update build & test summary report
1 parent 343592a commit 85ccba4

File tree

19 files changed

+502
-344
lines changed

19 files changed

+502
-344
lines changed

.github/workflows/integration_tests.yml

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ jobs:
221221
fi
222222
mobile_test_on=$( python scripts/gha/print_matrix_configuration.py -c -w integration_tests -k mobile_test_on -o "${{github.event.inputs.mobile_test_on}}")
223223
echo "::set-output name=mobile_test_on::${mobile_test_on}"
224-
echo "::set-output name=android_device::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${EXPANDED_MATRIX_PARAM} -k android_device -d ${mobile_test_on} )"
225-
echo "::set-output name=ios_device::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${EXPANDED_MATRIX_PARAM} -k ios_device -d ${mobile_test_on} )"
224+
echo "::set-output name=android_device::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${EXPANDED_MATRIX_PARAM} -k android_device -t ${mobile_test_on} )"
225+
echo "::set-output name=ios_device::$( python scripts/gha/print_matrix_configuration.py -w integration_tests ${EXPANDED_MATRIX_PARAM} -k ios_device -t ${mobile_test_on} )"
226226
if [[ -z "${{github.event.inputs.test_pull_request}}" ]]; then
227227
echo "::warning ::Running on https://github.com/${{github.repository}}/commits/$GITHUB_SHA"
228228
echo "::set-output name=github_ref::$GITHUB_SHA"
@@ -354,7 +354,7 @@ jobs:
354354
if: ${{ !cancelled() }}
355355
with:
356356
name: log-artifact
357-
path: build-results-desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}.log
357+
path: build-results-desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}*
358358
retention-days: ${{ env.artifactRetentionDays }}
359359
- name: Set CLOUDSDK_PYTHON (Windows)
360360
shell: bash
@@ -510,7 +510,7 @@ jobs:
510510
if: ${{ !cancelled() }}
511511
with:
512512
name: log-artifact
513-
path: build-results-android-${{ matrix.os }}.log
513+
path: build-results-android-${{ matrix.os }}*
514514
retention-days: ${{ env.artifactRetentionDays }}
515515
- name: Add failure label
516516
# We can mark a failure as soon as any one test fails.
@@ -635,7 +635,7 @@ jobs:
635635
if: ${{ !cancelled() }}
636636
with:
637637
name: log-artifact
638-
path: build-results-ios-macos-latest.log
638+
path: build-results-ios-macos-latest*
639639
retention-days: ${{ env.artifactRetentionDays }}
640640
- name: Add failure label
641641
# We can mark a failure as soon as any one test fails.
@@ -692,7 +692,7 @@ jobs:
692692
name: test-desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}
693693
needs: [check_trigger, prepare_matrix, build_desktop]
694694
runs-on: ${{ matrix.os }}
695-
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'Desktop') && needs.prepare_matrix.outputs.apis != '' && !cancelled() && !failure()
695+
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'Desktop') && needs.prepare_matrix.outputs.apis != '' && !cancelled()
696696
strategy:
697697
fail-fast: false
698698
matrix:
@@ -722,7 +722,7 @@ jobs:
722722
uses: actions/[email protected]
723723
with:
724724
name: log-artifact
725-
path: testapps/test-results-desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}.log
725+
path: testapps/test-results-desktop-${{ matrix.os }}-${{ matrix.ssl_variant }}*
726726
retention-days: ${{ env.artifactRetentionDays }}
727727
- name: Add failure label
728728
# We can mark a failure as soon as any one test fails.
@@ -779,7 +779,7 @@ jobs:
779779
name: test-android-${{ matrix.build_os }}-${{ matrix.android_device }}
780780
needs: [check_trigger, prepare_matrix, build_android]
781781
runs-on: macos-latest
782-
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'Android') && needs.prepare_matrix.outputs.apis != '' && !cancelled() && !failure()
782+
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'Android') && needs.prepare_matrix.outputs.apis != '' && !cancelled()
783783
strategy:
784784
fail-fast: false
785785
matrix:
@@ -800,35 +800,34 @@ jobs:
800800
python-version: ${{ env.pythonVersion }}
801801
- name: Install python deps
802802
run: pip install -r scripts/gha/requirements.txt
803-
- id: get-device
803+
- id: get-device-type
804804
run: |
805-
device=$(echo "${{ matrix.android_device }}" | cut -d ":" -f2)
806-
echo "::set-output name=device::$device"
805+
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.android_device }} )"
807806
- name: Run Android integration tests on Emulator locally
808-
if: startsWith(matrix.android_device, 'virtual')
807+
if: steps.get-device-type.outputs.device_type == 'virtual'
809808
run: |
810809
python scripts/gha/test_simulator.py --testapp_dir testapps \
811-
--android_device "${{steps.get-device.outputs.device}}" \
812-
--logfile_name "android-${{ matrix.build_os }}-${{steps.get-device.outputs.device}}" \
810+
--android_device "${{ matrix.android_device }}" \
811+
--logfile_name "android-${{ matrix.build_os }}-${{ matrix.android_device }}" \
813812
--ci
814813
- name: Install Cloud SDK
815-
if: startsWith(matrix.android_device, 'real')
814+
if: steps.get-device-type.outputs.device_type == 'real'
816815
uses: google-github-actions/setup-gcloud@master
817816
- name: Run Android integration tests on Real Device via FTL
818-
if: startsWith(matrix.android_device, 'real')
817+
if: steps.get-device-type.outputs.device_type == 'real'
819818
run: |
820819
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
821820
python scripts/gha/test_lab.py --testapp_dir testapps \
822-
--android_device "${{steps.get-device.outputs.device}}" \
823-
--logfile_name "android-${{ matrix.build_os }}-${{steps.get-device.outputs.device}}" \
821+
--android_device "${{ matrix.android_device }}" \
822+
--logfile_name "android-${{ matrix.build_os }}-${{ matrix.android_device }}" \
824823
--code_platform cpp \
825824
--key_file scripts/gha-encrypted/gcs_key_file.json
826825
- name: Upload Android test results artifact
827826
if: ${{ !cancelled() }}
828827
uses: actions/[email protected]
829828
with:
830829
name: log-artifact
831-
path: testapps/test-results-android-${{ matrix.build_os }}-${{steps.get-device.outputs.device}}.log
830+
path: testapps/test-results-android-${{ matrix.build_os }}-${{ matrix.android_device }}*
832831
retention-days: ${{ env.artifactRetentionDays }}
833832
- name: Add failure label
834833
# We can mark a failure as soon as any one test fails.
@@ -876,7 +875,7 @@ jobs:
876875
if: ${{ !cancelled() }}
877876
shell: bash
878877
run: |
879-
cat "testapps/test-results-android-${{ matrix.build_os }}-${{steps.get-device.outputs.device}}.log"
878+
cat "testapps/test-results-android-${{ matrix.build_os }}-${{ matrix.android_device }}.log"
880879
if [[ "${{ job.status }}" != "success" ]]; then
881880
exit 1
882881
fi
@@ -885,7 +884,7 @@ jobs:
885884
name: test-ios-macos-latest-${{ matrix.ios_device }}
886885
needs: [check_trigger, prepare_matrix, build_ios]
887886
runs-on: macos-latest
888-
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'iOS') && needs.prepare_matrix.outputs.apis != '' && !cancelled() && !failure()
887+
if: contains(needs.prepare_matrix.outputs.matrix_platform, 'iOS') && needs.prepare_matrix.outputs.apis != '' && !cancelled()
889888
strategy:
890889
fail-fast: false
891890
matrix:
@@ -905,35 +904,34 @@ jobs:
905904
python-version: ${{ env.pythonVersion }}
906905
- name: Install python deps
907906
run: pip install -r scripts/gha/requirements.txt
908-
- id: get-device
907+
- id: get-device-type
909908
run: |
910-
device=$(echo "${{ matrix.ios_device }}" | cut -d ":" -f2)
911-
echo "::set-output name=device::$device"
909+
echo "::set-output name=device_type::$( python scripts/gha/print_matrix_configuration.py -d -k ${{ matrix.ios_device }} )"
912910
- name: Run iOS integration tests on Simulator locally
913-
if: startsWith(matrix.ios_device, 'virtual')
911+
if: steps.get-device-type.outputs.device_type == 'virtual'
914912
run: |
915913
python scripts/gha/test_simulator.py --testapp_dir testapps \
916-
--ios_device "${{steps.get-device.outputs.device}}" \
917-
--logfile_name "ios-macos-latest-${{steps.get-device.outputs.device}}" \
914+
--ios_device "${{ matrix.ios_device }}" \
915+
--logfile_name "ios-macos-latest-${{ matrix.ios_device }}" \
918916
--ci
919917
- name: Install Cloud SDK
920-
if: startsWith(matrix.ios_device, 'real')
918+
if: steps.get-device-type.outputs.device_type == 'real'
921919
uses: google-github-actions/setup-gcloud@master
922920
- name: Run iOS integration tests on Real Device via FTL
923-
if: startsWith(matrix.ios_device, 'real')
921+
if: steps.get-device-type.outputs.device_type == 'real'
924922
run: |
925923
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
926924
python scripts/gha/test_lab.py --testapp_dir testapps \
927-
--ios_device "${{steps.get-device.outputs.device}}" \
928-
--logfile_name "ios-macos-latest-${{steps.get-device.outputs.device}}" \
925+
--ios_device "${{ matrix.ios_device }}" \
926+
--logfile_name "ios-macos-latest-${{ matrix.ios_device }}" \
929927
--code_platform cpp \
930928
--key_file scripts/gha-encrypted/gcs_key_file.json
931929
- name: Upload Android test results artifact
932930
if: ${{ !cancelled() }}
933931
uses: actions/[email protected]
934932
with:
935933
name: log-artifact
936-
path: testapps/test-results-ios-macos-latest-${{steps.get-device.outputs.device}}.log
934+
path: testapps/test-results-ios-macos-latest-${{ matrix.ios_device }}*
937935
retention-days: ${{ env.artifactRetentionDays }}
938936
- name: Add failure label
939937
# We can mark a failure as soon as any one test fails.
@@ -981,7 +979,7 @@ jobs:
981979
if: ${{ !cancelled() }}
982980
shell: bash
983981
run: |
984-
cat "testapps/test-results-ios-macos-latest-${{steps.get-device.outputs.device}}.log"
982+
cat "testapps/test-results-ios-macos-latest-${{ matrix.ios_device }}.log"
985983
if [[ "${{ job.status }}" != "success" ]]; then
986984
exit 1
987985
fi
@@ -1061,7 +1059,7 @@ jobs:
10611059
### ❌  Integration test FAILED
10621060
Requested by @${{github.actor}} on commit ${{needs.prepare_matrix.outputs.github_ref}}
10631061
Last updated: ${{ steps.get-time.outputs.time }}
1064-
**[View integration test results](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})**
1062+
**[Download integration test detailed logs and artifacts](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})**
10651063
${{ env.SUMMARY_TABLE }}
10661064
GITHUB_TOKEN: ${{ github.token }}
10671065
COMMENT_IDENTIFIER: ${{ env.statusCommentIdentifier }}

scripts/gha/build_testapps.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import shutil
8181
import subprocess
8282
import sys
83+
import json
8384

8485
from absl import app
8586
from absl import flags
@@ -255,7 +256,7 @@ def main(argv):
255256
short_output_paths=FLAGS.short_output_paths)
256257
logging.info("END building for %s", testapp)
257258

258-
_collect_integration_tests(testapps, root_output_dir, FLAGS.artifact_name)
259+
_collect_integration_tests(testapps, root_output_dir, output_dir, FLAGS.artifact_name)
259260

260261
_summarize_results(testapps, platforms, failures, root_output_dir, FLAGS.artifact_name)
261262
return 1 if failures else 0
@@ -329,7 +330,7 @@ def _build(
329330
return failures
330331

331332

332-
def _collect_integration_tests(testapps, output_dir, artifact_name):
333+
def _collect_integration_tests(testapps, root_output_dir, output_dir, artifact_name):
333334
testapps_artifact_dir = "testapps-" + artifact_name
334335
android_testapp_extension = ".apk"
335336
ios_testapp_extension = ".ipa"
@@ -349,7 +350,8 @@ def _collect_integration_tests(testapps, output_dir, artifact_name):
349350
or file_name.endswith(ios_testapp_extension)):
350351
testapp_paths.append(os.path.join(file_dir, file_name))
351352

352-
artifact_path = os.path.join(output_dir, testapps_artifact_dir)
353+
artifact_path = os.path.join(root_output_dir, testapps_artifact_dir)
354+
_rm_dir_safe(artifact_path)
353355
for testapp in testapps:
354356
os.makedirs(os.path.join(artifact_path, testapp))
355357
for path in testapp_paths:
@@ -362,7 +364,7 @@ def _collect_integration_tests(testapps, output_dir, artifact_name):
362364
break
363365

364366

365-
def _summarize_results(testapps, platforms, failures, output_dir, artifact_name):
367+
def _summarize_results(testapps, platforms, failures, root_output_dir, artifact_name):
366368
"""Logs a readable summary of the results of the build."""
367369
file_name = "build-results-" + artifact_name + ".log"
368370

@@ -374,13 +376,20 @@ def _summarize_results(testapps, platforms, failures, output_dir, artifact_name)
374376
if not failures:
375377
summary.append("ALL BUILDS SUCCEEDED")
376378
else:
377-
summary.append("SOME FAILURES OCCURRED:")
379+
summary.append("SOME ERRORS OCCURRED:")
378380
for i, failure in enumerate(failures, start=1):
379381
summary.append("%d: %s" % (i, failure.describe()))
380382
summary = "\n".join(summary)
381383

382384
logging.info(summary)
383-
test_validation.write_summary(output_dir, summary, file_name=file_name)
385+
test_validation.write_summary(root_output_dir, summary, file_name=file_name)
386+
387+
summary_json = {}
388+
summary_json["type"] = "build"
389+
summary_json["testapps"] = testapps
390+
summary_json["errors"] = {failure.testapp:failure.error_message for failure in failures}
391+
with open(os.path.join(root_output_dir, file_name+".json"), "a") as f:
392+
f.write(json.dumps(summary_json, indent=2))
384393

385394

386395
def _build_desktop(sdk_dir, cmake_flags):
@@ -465,10 +474,11 @@ def _generate_makefiles_from_repo(repo_dir):
465474
"""Generates cmake makefiles for building iOS frameworks from SDK source."""
466475
ios_framework_builder = os.path.join(
467476
repo_dir, "build_scripts", "ios", "build.sh")
468-
477+
output_path = os.path.join(repo_dir, "ios_build")
478+
_rm_dir_safe(output_path)
469479
framework_builder_args = [
470480
ios_framework_builder,
471-
"-b", os.path.join(repo_dir, "ios_build"),
481+
"-b", output_path,
472482
"-s", repo_dir,
473483
"-c", "false"
474484
]
@@ -508,7 +518,7 @@ def _build_ios(
508518
if not ios_framework_exist:
509519
_build_ios_framework_from_repo(repo_dir, api_config)
510520
sdk_dir = os.path.join(repo_dir, "ios_build")
511-
logging.info("iOS xcframework created at: %s", " ".join(sdk_dir))
521+
logging.info("iOS xcframework created at: %s", sdk_dir)
512522

513523
build_dir = os.path.join(project_dir, "ios_build")
514524
os.makedirs(build_dir)

0 commit comments

Comments
 (0)