test_coverage.yml 13 KB

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