common.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: common
  2. permissions:
  3. contents: read
  4. on:
  5. workflow_call:
  6. inputs:
  7. # The target scheme to be tested.
  8. target:
  9. type: string
  10. required: true
  11. # The platforms to build on. Defaults to all.
  12. # To target specific platforms, pass a comma or space separated string of
  13. # platforms.
  14. #
  15. # Examples:
  16. # - build/test only for macOS: `macOS`
  17. # - build/test only for macOS and tvOS: `macOS, tvOS`
  18. platforms:
  19. type: string
  20. required: false
  21. default: "iOS, tvOS, macOS, watchOS, catalyst, visionOS"
  22. # By default, all platforms will be tested (see matrix in `spm` job).
  23. # To build instead of test, pass a comma or space separated string of
  24. # platforms.
  25. #
  26. # Platform options: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
  27. #
  28. # Note: Build-only platforms must be represented in the `platforms` input
  29. # (which defaults to all platforms) in order to take effect.
  30. #
  31. # Examples:
  32. # - build only for macOS: `macOS`
  33. # - build only for macOS and tvOS: `macOS, tvOS`
  34. # - build only for all platforms: `all`
  35. buildonly_platforms:
  36. type: string
  37. required: false
  38. default: ""
  39. # A command to execute before testing.
  40. #
  41. # This is useful for additional set up, like starting an emulator or
  42. # downloading test data.
  43. #
  44. # Example: `FirebaseFunctions/Backend/start.sh synchronous`
  45. setup_command:
  46. type: string
  47. required: false
  48. default: ""
  49. outputs:
  50. cache_key:
  51. description: "The cache key for the Swift package resolution."
  52. value: ${{ jobs.spm-package-resolved.outputs.cache_key }}
  53. jobs:
  54. spm-package-resolved:
  55. env:
  56. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  57. runs-on: macos-15
  58. outputs:
  59. cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
  60. steps:
  61. - uses: actions/checkout@v4
  62. - name: Xcode
  63. run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
  64. - name: Generate Swift Package.resolved
  65. id: swift_package_resolve
  66. run: swift package resolve
  67. - name: Generate cache key
  68. id: generate_cache_key
  69. run: |
  70. cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
  71. echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
  72. - uses: actions/cache/save@v4
  73. id: cache
  74. with:
  75. path: .build
  76. key: ${{ steps.generate_cache_key.outputs.cache_key }}
  77. spm:
  78. # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
  79. if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
  80. needs: [spm-package-resolved]
  81. strategy:
  82. matrix:
  83. os: [macos-15]
  84. xcode: [Xcode_16.4]
  85. platform: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
  86. include:
  87. - os: macos-14
  88. xcode: Xcode_16.2
  89. platform: iOS
  90. - os: macos-26
  91. xcode: Xcode_26.0
  92. platform: iOS
  93. runs-on: ${{ matrix.os }}
  94. steps:
  95. - uses: actions/checkout@v4
  96. - uses: actions/cache/restore@v4
  97. with:
  98. path: .build
  99. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  100. - name: Xcode
  101. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  102. - name: Run setup command, if needed.
  103. if: inputs.setup_command != ''
  104. run: ${{ inputs.setup_command }}
  105. - name: Initialize xcodebuild
  106. run: scripts/setup_spm_tests.sh
  107. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
  108. if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14'
  109. with:
  110. timeout_minutes: 15
  111. max_attempts: 3
  112. retry_wait_seconds: 120
  113. command: |
  114. ./scripts/build.sh \
  115. ${{ inputs.target }} \
  116. ${{ matrix.platform }} \
  117. ${{ (contains(inputs.buildonly_platforms, matrix.platform) || contains(inputs.buildonly_platforms, 'all')) && 'spmbuildonly' || 'spm' }}