common.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. jobs:
  40. spm-package-resolved:
  41. env:
  42. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  43. runs-on: macos-15
  44. outputs:
  45. cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
  46. steps:
  47. - uses: actions/checkout@v4
  48. - name: Xcode
  49. run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
  50. - name: Generate Swift Package.resolved
  51. id: swift_package_resolve
  52. run: |
  53. swift package resolve
  54. - name: Generate cache key
  55. id: generate_cache_key
  56. run: |
  57. cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
  58. echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
  59. - uses: actions/cache/save@v4
  60. id: cache
  61. with:
  62. path: .build
  63. key: ${{ steps.generate_cache_key.outputs.cache_key }}
  64. spm:
  65. # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
  66. if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
  67. needs: [spm-package-resolved]
  68. strategy:
  69. matrix:
  70. os: [macos-15]
  71. xcode: [Xcode_16.3]
  72. platform: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
  73. include:
  74. - os: macos-14
  75. xcode: Xcode_16.2
  76. platform: iOS
  77. runs-on: ${{ matrix.os }}
  78. steps:
  79. - uses: actions/checkout@v4
  80. - uses: actions/cache/restore@v4
  81. with:
  82. path: .build
  83. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  84. - name: Xcode
  85. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  86. - name: Install visionOS, if needed.
  87. if: matrix.platform == 'visionOS'
  88. run: xcodebuild -downloadPlatform visionOS
  89. - name: Initialize xcodebuild
  90. run: scripts/setup_spm_tests.sh
  91. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
  92. if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14'
  93. with:
  94. timeout_minutes: 120
  95. max_attempts: 3
  96. retry_on: error
  97. retry_wait_seconds: 120
  98. command: |
  99. ./scripts/build.sh \
  100. ${{ inputs.target }} \
  101. ${{ matrix.platform }} \
  102. ${{ (contains(inputs.buildonly_platforms, matrix.platform) || contains(inputs.buildonly_platforms, 'all')) && 'spmbuildonly' || 'spm' }}