common_cocoapods.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. name: common_cocoapods
  2. permissions:
  3. contents: read
  4. on:
  5. workflow_call:
  6. # Re-usable workflows do not automatically inherit the caller's secrets.
  7. #
  8. # If the calling workflow uses a secret in the `setup_command` input, then
  9. # it also must pass the secret to the re-usable workflow.
  10. #
  11. # Example:
  12. #
  13. # pod_lib_lint:
  14. # uses: ./.github/workflows/common_cocoapods.yml
  15. # with:
  16. # product: FirebaseFoo
  17. # setup_command: |
  18. # scripts/decrypt_gha_secret.sh \
  19. # /path/to/GoogleService-Info.plist.gpg \
  20. # /path/to/dest/GoogleService-Info.plist "$plist_secret"
  21. # secrets:
  22. # plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
  23. #
  24. secrets:
  25. plist_secret:
  26. required: false
  27. inputs:
  28. # The product to test be tested (e.g. `FirebaseABTesting`).
  29. product:
  30. type: string
  31. required: true
  32. # The platforms to build on. Defaults to all.
  33. # To target specific platforms, pass a comma or space separated string of
  34. # platforms.
  35. #
  36. # Examples:
  37. # - build/test only for macOS: `macOS`
  38. # - build/test only for macOS and tvOS: `macOS, tvOS`
  39. platforms:
  40. type: string
  41. required: false
  42. default: "iOS, tvOS, macOS, watchOS"
  43. # By default, all platforms will be tested (see matrix in `spm` job).
  44. # To build instead of test, pass a comma or space separated string of
  45. # platforms.
  46. #
  47. # Platform options: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
  48. #
  49. # Note: Build-only platforms must be represented in the `platforms` input
  50. # (which defaults to all platforms) in order to take effect.
  51. #
  52. # Examples:
  53. # - build only for macOS: `macOS`
  54. # - build only for macOS and tvOS: `macOS, tvOS`
  55. # - build only for all platforms: `all`
  56. buildonly_platforms:
  57. type: string
  58. required: false
  59. default: ""
  60. # Whether to lint with `--allow-warnings`. Defaults to false.
  61. allow_warnings:
  62. type: boolean
  63. required: false
  64. default: false
  65. # Whether to lint with `--analyze`. Defaults to true.
  66. analyze:
  67. type: boolean
  68. required: false
  69. default: true
  70. # Whether to additionally build with Swift 6. Defaults to false.
  71. supports_swift6:
  72. type: boolean
  73. required: false
  74. default: false
  75. # A comma separated (no spaces) string that will be passed to
  76. # pod lib lint's `--test-specs=` argument. By default, all
  77. # test specs will be tested.
  78. test_specs:
  79. type: string
  80. required: false
  81. default: ""
  82. # A command to execute before testing.
  83. #
  84. # This is useful for additional set up, like starting an emulator or
  85. # downloading test data.
  86. #
  87. # Note, this step has an env var set to decrypt plists. Use
  88. # "$plist_secret" in the given command. See `secrets` documentation
  89. # at top of this file.
  90. #
  91. # Example: `FirebaseFunctions/Backend/start.sh synchronous`
  92. setup_command:
  93. type: string
  94. required: false
  95. default: ""
  96. jobs:
  97. pod-lib-lint:
  98. # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
  99. if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
  100. strategy:
  101. matrix:
  102. os: [macos-15]
  103. xcode: [Xcode_16.4]
  104. platform: [iOS, tvOS, macOS, watchOS]
  105. include:
  106. - os: macos-14
  107. xcode: Xcode_16.2
  108. platform: iOS
  109. runs-on: ${{ matrix.os }}
  110. steps:
  111. - uses: actions/checkout@v4
  112. - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1
  113. - name: Setup Bundler
  114. run: scripts/setup_bundler.sh
  115. - name: Xcode
  116. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  117. - name: Set conditional environment variable, if needed.
  118. if: inputs.product == 'FirebaseAuth'
  119. run: echo "FIREBASE_CI=true" >> $GITHUB_ENV
  120. - name: Set podspec Swift version to 6.0, if supported.
  121. if: inputs.supports_swift6 == true && matrix.os != 'macos-14'
  122. run: sed -i "" "s/s.swift_version[[:space:]]*=[[:space:]]*'5.9'/s.swift_version = '6.0'/" ${{ inputs.product }}.podspec
  123. - name: Run setup command, if needed.
  124. if: inputs.setup_command != ''
  125. env:
  126. plist_secret: ${{ secrets.plist_secret }}
  127. run: ${{ inputs.setup_command }}
  128. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
  129. if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14'
  130. with:
  131. timeout_minutes: 120
  132. max_attempts: 3
  133. retry_on: error
  134. retry_wait_seconds: 120
  135. command: |
  136. scripts/pod_lib_lint.rb ${{ inputs.product }}.podspec --platforms=${{ matrix.platform }} \
  137. ${{ inputs.allow_warnings == true && '--allow-warnings' || '' }} \
  138. ${{ inputs.analyze == false && '--no-analyze' || '' }} \
  139. ${{ inputs.test_specs != '' && format('--test-specs={0}', inputs.test_specs) || '' }} \
  140. ${{ (contains(inputs.buildonly_platforms, matrix.platform) || contains(inputs.buildonly_platforms, 'all')) && '--skip-tests' || '' }}