test_coverage.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. name: test_coverage
  2. on:
  3. pull_request:
  4. # open will be triggered when a pull request is created.
  5. # synchronize will be triggered when a pull request has new commits.
  6. # closed will be triggered when a pull request is closed.
  7. types: [opened, synchronize, closed]
  8. env:
  9. METRICS_SERVICE_SECRET: ${{ secrets.GHASecretsGPGPassphrase1 }}
  10. jobs:
  11. check:
  12. if: github.repository == 'Firebase/firebase-ios-sdk' && (github.event.action == 'opened' || github.event.action == 'synchronize')
  13. name: Check changed files
  14. outputs:
  15. abtesting_run_job: ${{ steps.check_files.outputs.abtesting_run_job }}
  16. auth_run_job: ${{ steps.check_files.outputs.auth_run_job }}
  17. database_run_job: ${{ steps.check_files.outputs.database_run_job }}
  18. dynamiclinks_run_job: ${{ steps.check_files.outputs.dynamiclinks_run_job }}
  19. firestore_run_job: ${{ steps.check_files.outputs.firestore_run_job }}
  20. functions_run_job: ${{ steps.check_files.outputs.functions_run_job }}
  21. inappmessaging_run_job: ${{ steps.check_files.outputs.inappmessaging_run_job }}
  22. instanceid_run_job: ${{ steps.check_files.outputs.instanceid_run_job }}
  23. messaging_run_job: ${{ steps.check_files.outputs.messaging_run_job }}
  24. performance_run_job: ${{ steps.check_files.outputs.performance_run_job }}
  25. remoteconfig_run_job: ${{ steps.check_files.outputs.remoteconfig_run_job }}
  26. storage_run_job: ${{ steps.check_files.outputs.storage_run_job }}
  27. base_commit: ${{ steps.check_files.outputs.base_commit }}
  28. runs-on: ubuntu-latest
  29. steps:
  30. - name: Checkout code
  31. uses: actions/checkout@v2
  32. with:
  33. fetch-depth: 0
  34. - name: check files
  35. id: check_files
  36. env:
  37. pr_branch: ${{ github.event.pull_request.head.ref }}
  38. run: |
  39. if [ ! -z "${{ env.METRICS_SERVICE_SECRET }}" ]; then
  40. ./scripts/code_coverage_report/get_updated_files.sh
  41. fi
  42. pod-lib-lint-abtesting:
  43. needs: check
  44. # Don't run on private repo unless it is a PR.
  45. # always() will trigger this job when `needs` are skipped in a `merge` pull_request event.
  46. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.abtesting_run_job == 'true'|| github.event.pull_request.merged)
  47. runs-on: macOS-latest
  48. strategy:
  49. matrix:
  50. target: [iOS]
  51. steps:
  52. - uses: actions/checkout@v2
  53. - name: Setup Bundler
  54. run: scripts/setup_bundler.sh
  55. - name: Build and test
  56. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseABTesting --platform=${{ matrix.target }}
  57. - uses: actions/upload-artifact@v2
  58. with:
  59. name: codecoverage
  60. path: /Users/runner/*.xcresult
  61. pod-lib-lint-auth:
  62. needs: check
  63. # Don't run on private repo unless it is a PR.
  64. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.auth_run_job == 'true'|| github.event.pull_request.merged)
  65. runs-on: macOS-latest
  66. strategy:
  67. matrix:
  68. target: [iOS]
  69. steps:
  70. - uses: actions/checkout@v2
  71. - name: Setup Bundler
  72. run: scripts/setup_bundler.sh
  73. - name: Build and test
  74. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseAuth --platform=${{ matrix.target }}
  75. - uses: actions/upload-artifact@v2
  76. with:
  77. name: codecoverage
  78. path: /Users/runner/*.xcresult
  79. pod-lib-lint-database:
  80. needs: check
  81. # Don't run on private repo unless it is a PR.
  82. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.database_run_job == 'true' || github.event.pull_request.merged)
  83. runs-on: macOS-latest
  84. strategy:
  85. matrix:
  86. target: [iOS]
  87. steps:
  88. - uses: actions/checkout@v2
  89. - name: Setup Bundler
  90. run: scripts/setup_bundler.sh
  91. - name: Build and test
  92. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseDatabase --platform=${{ matrix.target }}
  93. - uses: actions/upload-artifact@v2
  94. with:
  95. name: codecoverage
  96. path: /Users/runner/*.xcresult
  97. pod-lib-lint-dynamiclinks:
  98. needs: check
  99. # Don't run on private repo unless it is a PR.
  100. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.dynamiclinks_run_job == 'true'|| github.event.pull_request.merged)
  101. runs-on: macOS-latest
  102. strategy:
  103. matrix:
  104. target: [iOS]
  105. steps:
  106. - uses: actions/checkout@v2
  107. - name: Setup Bundler
  108. run: scripts/setup_bundler.sh
  109. - name: Build and test
  110. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseDynamicLinks --platform=${{ matrix.target }}
  111. - uses: actions/upload-artifact@v2
  112. with:
  113. name: codecoverage
  114. path: /Users/runner/*.xcresult
  115. pod-lib-lint-firestore:
  116. needs: check
  117. # Don't run on private repo unless it is a PR.
  118. # Disable Firestore for now since Firestore currently does not have unit tests in podspecs.
  119. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.firestore_run_job == 'true'|| github.event.pull_request.merged)
  120. runs-on: macOS-latest
  121. strategy:
  122. matrix:
  123. target: [iOS]
  124. steps:
  125. - uses: actions/checkout@v2
  126. - name: Setup Bundler
  127. run: scripts/setup_bundler.sh
  128. - name: Build and test
  129. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseFirestore --platform=${{ matrix.target }}
  130. - uses: actions/upload-artifact@v2
  131. with:
  132. name: codecoverage
  133. path: /Users/runner/*.xcresult
  134. pod-lib-lint-functions:
  135. needs: check
  136. # Don't run on private repo unless it is a PR.
  137. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.functions_run_job == 'true'|| github.event.pull_request.merged)
  138. runs-on: macOS-latest
  139. strategy:
  140. matrix:
  141. target: [iOS]
  142. steps:
  143. - uses: actions/checkout@v2
  144. - name: Setup Bundler
  145. run: scripts/setup_bundler.sh
  146. - name: Build and test
  147. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseFunctions --platform=${{ matrix.target }}
  148. - uses: actions/upload-artifact@v2
  149. with:
  150. name: codecoverage
  151. path: /Users/runner/*.xcresult
  152. pod-lib-lint-inappmessaging:
  153. needs: check
  154. # Don't run on private repo unless it is a PR.
  155. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.inappmessaging_run_job == 'true'|| github.event.pull_request.merged)
  156. runs-on: macOS-latest
  157. strategy:
  158. matrix:
  159. target: [iOS]
  160. steps:
  161. - uses: actions/checkout@v2
  162. - name: Setup Bundler
  163. run: scripts/setup_bundler.sh
  164. - name: Build and test
  165. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseInAppMessaging --platform=${{ matrix.target }}
  166. - uses: actions/upload-artifact@v2
  167. with:
  168. name: codecoverage
  169. path: /Users/runner/*.xcresult
  170. pod-lib-lint-instanceid:
  171. needs: check
  172. # Don't run on private repo unless it is a PR.
  173. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.instanceid_run_job == 'true'|| github.event.pull_request.merged)
  174. runs-on: macOS-latest
  175. strategy:
  176. matrix:
  177. target: [iOS]
  178. steps:
  179. - uses: actions/checkout@v2
  180. - name: Setup Bundler
  181. run: scripts/setup_bundler.sh
  182. - name: Build and test
  183. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseInstanceID --platform=${{ matrix.target }}
  184. - uses: actions/upload-artifact@v2
  185. with:
  186. name: codecoverage
  187. path: /Users/runner/*.xcresult
  188. pod-lib-lint-messaging:
  189. needs: check
  190. # Don't run on private repo unless it is a PR.
  191. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.messaging_run_job == 'true'|| github.event.pull_request.merged)
  192. runs-on: macOS-latest
  193. strategy:
  194. matrix:
  195. target: [iOS]
  196. steps:
  197. - uses: actions/checkout@v2
  198. - name: Setup Bundler
  199. run: scripts/setup_bundler.sh
  200. - name: Build and test
  201. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseMessaging --platform=${{ matrix.target }}
  202. - uses: actions/upload-artifact@v2
  203. with:
  204. name: codecoverage
  205. path: /Users/runner/*.xcresult
  206. pod-lib-lint-performance:
  207. needs: check
  208. # Don't run on private repo unless it is a PR.
  209. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.performance_run_job == 'true'|| github.event.pull_request.merged)
  210. runs-on: macOS-latest
  211. strategy:
  212. matrix:
  213. target: [iOS]
  214. steps:
  215. - uses: actions/checkout@v2
  216. - name: Setup Bundler
  217. run: scripts/setup_bundler.sh
  218. - name: Build and test
  219. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebasePerformance --platform=${{ matrix.target }}
  220. - uses: actions/upload-artifact@v2
  221. with:
  222. name: codecoverage
  223. path: /Users/runner/*.xcresult
  224. pod-lib-lint-remoteconfig:
  225. needs: check
  226. # Don't run on private repo unless it is a PR.
  227. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.remoteconfig_run_job == 'true'|| github.event.pull_request.merged)
  228. runs-on: macOS-latest
  229. strategy:
  230. matrix:
  231. target: [iOS]
  232. steps:
  233. - uses: actions/checkout@v2
  234. - name: Setup Bundler
  235. run: scripts/setup_bundler.sh
  236. - name: Build and test
  237. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseRemoteConfig --platform=${{ matrix.target }}
  238. - uses: actions/upload-artifact@v2
  239. with:
  240. name: codecoverage
  241. path: /Users/runner/*.xcresult
  242. pod-lib-lint-storage:
  243. needs: check
  244. # Don't run on private repo unless it is a PR.
  245. if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.storage_run_job == 'true'|| github.event.pull_request.merged)
  246. runs-on: macOS-latest
  247. strategy:
  248. matrix:
  249. target: [iOS]
  250. steps:
  251. - uses: actions/checkout@v2
  252. - name: Setup Bundler
  253. run: scripts/setup_bundler.sh
  254. - name: Build and test
  255. run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh --sdk=FirebaseStorage --platform=${{ matrix.target }}
  256. - uses: actions/upload-artifact@v2
  257. with:
  258. name: codecoverage
  259. path: /Users/runner/*.xcresult
  260. create_report:
  261. needs: [check, pod-lib-lint-abtesting, pod-lib-lint-auth, pod-lib-lint-database, pod-lib-lint-dynamiclinks, pod-lib-lint-firestore, pod-lib-lint-functions, pod-lib-lint-inappmessaging, pod-lib-lint-instanceid, pod-lib-lint-messaging, pod-lib-lint-performance, pod-lib-lint-remoteconfig, pod-lib-lint-storage]
  262. if: always()
  263. runs-on: macOS-latest
  264. steps:
  265. - uses: actions/checkout@v2
  266. - name: Access to Metrics Service
  267. if: ${{ env.METRICS_SERVICE_SECRET }}
  268. run: |
  269. # Install gcloud sdk
  270. curl https://sdk.cloud.google.com > install.sh
  271. bash install.sh --disable-prompts
  272. echo "${HOME}/google-cloud-sdk/bin/" >> $GITHUB_PATH
  273. export PATH="${HOME}/google-cloud-sdk/bin/:${PATH}"
  274. # Activate the service account for Metrics Service.
  275. scripts/decrypt_gha_secret.sh scripts/gha-encrypted/metrics_service_access.json.gpg \
  276. metrics-access.json "${{ env.METRICS_SERVICE_SECRET }}"
  277. gcloud auth activate-service-account --key-file metrics-access.json
  278. - uses: actions/download-artifact@v2
  279. id: download
  280. with:
  281. path: /Users/runner/test
  282. - name: Compare Diff and Post a Report
  283. if: github.event_name == 'pull_request' && ${{ env.METRICS_SERVICE_SECRET }}
  284. env:
  285. base_commit: ${{ needs.check.outputs.base_commit }}
  286. run: |
  287. # Get Head commit of the branch, instead of a merge commit created by actions/checkout.
  288. GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
  289. if [ -d "${{steps.download.outputs.download-path}}" ]; then
  290. cd scripts/code_coverage_report/generate_code_coverage_report
  291. swift run CoverageReportGenerator --presubmit "firebase/firebase-ios-sdk" --commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "/Users/runner/test/codecoverage" --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --pull-request-num ${{github.event.pull_request.number}} --base-commit "$base_commit"
  292. fi
  293. - name: Update New Coverage Data
  294. if: github.event.pull_request.merged == true && ${{ env.METRICS_SERVICE_SECRET }}
  295. run: |
  296. if [ -d "${{steps.download.outputs.download-path}}" ]; then
  297. cd scripts/code_coverage_report/generate_code_coverage_report
  298. swift run CoverageReportGenerator --merge "firebase/firebase-ios-sdk" --commit "${GITHUB_SHA}" --token $(gcloud auth print-identity-token) --xcresult-dir "/Users/runner/test/codecoverage" --log-link "https://github.com/firebase/firebase-ios-sdk/actions/runs/${GITHUB_RUN_ID}" --branch "${GITHUB_REF##*/}"
  299. fi