create_binary_size_report.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # Copyright 2021 Google LLC
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This is to generate pod size report and send to the Metrics Service.
  16. # The Metrics Service will either
  17. # 1. save binary size data into the databasae when POSTSUBMIT is true, or
  18. # 2. post a report in a PR when POSTSUBMIT is not true.
  19. set -ex
  20. BINARY_SIZE_SDK=()
  21. # In presubmits, `check` job in the health_metrics.yml workflow will turn on SDK flags if a corresponding
  22. # file path, in `scripts/health_metrics/file_patterns.json` is updated.
  23. # In postsubmits, all SDKs should be measured, so binary size data of all SDKs should be uploaded to a
  24. # merged commit. Next time a new PR can compare the head of the PR to a commit on the base branch.
  25. if [[ "${POSTSUBMIT}" == true || "${FirebaseABTesting}" == 'true' ]]; then
  26. BINARY_SIZE_SDK+=('FirebaseABTesting')
  27. fi
  28. if [[ "${POSTSUBMIT}" == true || "${FirebaseAnalytics}" == 'true' ]]; then
  29. BINARY_SIZE_SDK+=('FirebaseAnalytics')
  30. fi
  31. if [[ "${POSTSUBMIT}" == true || "${FirebaseAppCheck}" == 'true' ]]; then
  32. BINARY_SIZE_SDK+=('FirebaseAppCheck')
  33. fi
  34. if [[ "${POSTSUBMIT}" == true || "${FirebaseAppDistribution}" == 'true' ]]; then
  35. BINARY_SIZE_SDK+=('FirebaseAppDistribution')
  36. fi
  37. if [[ "${POSTSUBMIT}" == true || "${FirebaseAuth}" == 'true' ]]; then
  38. BINARY_SIZE_SDK+=('FirebaseAuth')
  39. fi
  40. if [[ "${POSTSUBMIT}" == true || "${FirebaseCrashlytics}" == 'true' ]]; then
  41. BINARY_SIZE_SDK+=('FirebaseCrashlytics')
  42. fi
  43. if [[ "${POSTSUBMIT}" == true || "${FirebaseDatabase}" == 'true' ]]; then
  44. BINARY_SIZE_SDK+=('FirebaseDatabase')
  45. fi
  46. if [[ "${POSTSUBMIT}" == true || "${FirebaseDynamicLinks}" == 'true' ]]; then
  47. BINARY_SIZE_SDK+=('FirebaseDynamicLinks')
  48. fi
  49. if [[ "${POSTSUBMIT}" == true || "${FirebaseFirestore}" == 'true' ]]; then
  50. BINARY_SIZE_SDK+=('FirebaseFirestore')
  51. fi
  52. if [[ "${POSTSUBMIT}" == true || "${FirebaseFunctions}" == 'true' ]]; then
  53. BINARY_SIZE_SDK+=('FirebaseFunctions')
  54. fi
  55. if [[ "${POSTSUBMIT}" == true || "${FirebaseInAppMessaging}" == 'true' ]]; then
  56. BINARY_SIZE_SDK+=('FirebaseInAppMessaging')
  57. fi
  58. if [[ "${POSTSUBMIT}" == true || "${FirebaseInstallations}" == 'true' ]]; then
  59. BINARY_SIZE_SDK+=('FirebaseInstallations')
  60. fi
  61. if [[ "${POSTSUBMIT}" == true || "${FirebaseMessaging}" == 'true' ]]; then
  62. BINARY_SIZE_SDK+=('FirebaseMessaging')
  63. fi
  64. if [[ "${POSTSUBMIT}" == true || "${FirebasePerformance}" == 'true' ]]; then
  65. BINARY_SIZE_SDK+=('FirebasePerformance');
  66. fi
  67. if [[ "${POSTSUBMIT}" == true || "${FirebaseRemoteConfig}" == 'true' ]]; then
  68. BINARY_SIZE_SDK+=('FirebaseRemoteConfig')
  69. fi
  70. if [[ "${POSTSUBMIT}" == true || "${FirebaseStorage}" == 'true' ]]; then
  71. BINARY_SIZE_SDK+=('FirebaseStorage')
  72. fi
  73. if [ -n "$BINARY_SIZE_SDK" ]; then
  74. cd scripts/health_metrics/generate_code_coverage_report/
  75. git clone https://github.com/google/cocoapods-size
  76. swift build
  77. if [[ "${POSTSUBMIT}" == true ]]; then
  78. .build/debug/BinarySizeReportGenerator --binary-size-tool-dir cocoapods-size/ --sdk-repo-dir "${GITHUB_WORKSPACE}" --sdk ${BINARY_SIZE_SDK[@]} --merge "firebase/firebase-ios-sdk" --head-commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --source-branch "${SOURCE_BRANCH}"
  79. else
  80. .build/debug/BinarySizeReportGenerator --binary-size-tool-dir cocoapods-size/ --sdk-repo-dir "${GITHUB_WORKSPACE}" --sdk ${BINARY_SIZE_SDK[@]} --presubmit "firebase/firebase-ios-sdk" --head-commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --pull-request-num "${PULL_REQUEST_NUM}" --base-commit "${BASE_COMMIT}"
  81. fi
  82. fi