spm.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. name: spm
  2. on:
  3. workflow_dispatch:
  4. pull_request:
  5. paths:
  6. - '.github/workflows/spm.yml'
  7. - 'Package.swift'
  8. - '.swiftpm/*'
  9. - 'scripts/build.sh'
  10. - 'SwiftPMTests/*'
  11. - 'SwiftPM-PlatformExclude'
  12. - 'Gemfile*'
  13. schedule:
  14. # Run every day at 1am (PDT) / 4am (EDT) - cron uses UTC times
  15. - cron: '0 8 * * *'
  16. # This workflow builds and tests the Swift Package Manager. Only iOS runs on PRs
  17. # because each platform takes 15-20 minutes after adding Firestore.
  18. concurrency:
  19. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  20. cancel-in-progress: true
  21. env:
  22. FIREBASE_CI: true
  23. jobs:
  24. spm-package-resolved:
  25. env:
  26. FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
  27. runs-on: macos-14
  28. outputs:
  29. cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
  30. steps:
  31. - uses: actions/checkout@v4
  32. - name: Xcode
  33. run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
  34. - name: Generate Swift Package.resolved
  35. id: swift_package_resolve
  36. run: |
  37. swift package resolve
  38. - name: Generate cache key
  39. id: generate_cache_key
  40. run: |
  41. cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
  42. echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
  43. - uses: actions/cache/save@v4
  44. id: cache
  45. with:
  46. path: .build
  47. key: ${{ steps.generate_cache_key.outputs.cache_key }}
  48. swift-build-run:
  49. # Don't run on private repo unless it is a PR.
  50. if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  51. needs: [spm-package-resolved]
  52. strategy:
  53. matrix:
  54. include:
  55. - os: macos-15
  56. xcode: Xcode_16.4
  57. test: spm
  58. - os: macos-14
  59. xcode: Xcode_16.2
  60. test: spm
  61. runs-on: ${{ matrix.os }}
  62. steps:
  63. - uses: actions/checkout@v4
  64. - uses: actions/cache/restore@v4
  65. with:
  66. path: .build
  67. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  68. - name: Clone mock responses for Firebase AI Logic unit tests
  69. run: scripts/update_vertexai_responses.sh
  70. - name: Xcode
  71. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  72. - name: Initialize xcodebuild
  73. run: scripts/setup_spm_tests.sh
  74. - name: Functions Integration Test Server
  75. run: FirebaseFunctions/Backend/start.sh synchronous
  76. - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
  77. with:
  78. timeout_minutes: 15
  79. max_attempts: 3
  80. retry_wait_seconds: 120
  81. command: scripts/build.sh Firebase-Package iOS ${{ matrix.test }}
  82. - uses: actions/upload-artifact@v4
  83. if: ${{ failure() }}
  84. with:
  85. name: spm-build-run-${{ matrix.os }}-${{ matrix.xcode }}-logs
  86. path: xcodebuild-*.log
  87. if-no-files-found: error
  88. # Test iOS Device build since some Firestore dependencies build different files.
  89. iOS-Device:
  90. # Don't run on private repo unless it is a PR.
  91. if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  92. needs: [spm-package-resolved]
  93. strategy:
  94. matrix:
  95. include:
  96. - os: macos-14
  97. xcode: Xcode_16.2
  98. - os: macos-15
  99. xcode: Xcode_16.4
  100. runs-on: ${{ matrix.os }}
  101. steps:
  102. - uses: actions/checkout@v4
  103. - uses: actions/cache/restore@v4
  104. with:
  105. path: .build
  106. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  107. - name: Clone mock responses for Firebase AI Logic unit tests
  108. run: scripts/update_vertexai_responses.sh
  109. - name: Xcode
  110. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  111. - name: Initialize xcodebuild
  112. run: scripts/setup_spm_tests.sh
  113. - name: iOS Device and Test Build
  114. run: scripts/third_party/travis/retry.sh ./scripts/build.sh Firebase-Package iOS-device spmbuildonly
  115. - uses: actions/upload-artifact@v4
  116. if: ${{ failure() }}
  117. with:
  118. name: spm-ios-device-${{ matrix.os }}-${{ matrix.xcode }}-logs
  119. path: xcodebuild-*.log
  120. if-no-files-found: error
  121. platforms:
  122. # Don't run on private repo unless it is a PR.
  123. if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
  124. needs: [spm-package-resolved]
  125. strategy:
  126. matrix:
  127. # Full set of Firebase-Package tests only run on iOS. Run subset on other platforms.
  128. # visionOS isn't buildable from here (even with Firestore source) because the test
  129. # targets need Analytics.
  130. target: [tvOS, macOS, catalyst]
  131. include:
  132. - os: macos-15
  133. xcode: Xcode_16.4
  134. - os: macos-14
  135. xcode: Xcode_16.2
  136. runs-on: ${{ matrix.os }}
  137. steps:
  138. - uses: actions/checkout@v4
  139. - uses: actions/cache/restore@v4
  140. with:
  141. path: .build
  142. key: ${{needs.spm-package-resolved.outputs.cache_key}}
  143. - name: Xcode
  144. run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
  145. - name: Initialize xcodebuild
  146. run: scripts/setup_spm_tests.sh
  147. - name: Objc Import Tests
  148. run: scripts/third_party/travis/retry.sh ./scripts/build.sh objc-import-test ${{ matrix.target }} spm
  149. - name: Swift Tests
  150. run: scripts/third_party/travis/retry.sh ./scripts/build.sh swift-test ${{ matrix.target }} spm
  151. - name: Version Tests
  152. run: scripts/third_party/travis/retry.sh ./scripts/build.sh version-test ${{ matrix.target }} spm
  153. - name: Analytics Build Tests
  154. run: scripts/third_party/travis/retry.sh ./scripts/build.sh analytics-import-test ${{ matrix.target }} spm
  155. - uses: actions/upload-artifact@v4
  156. if: ${{ failure() }}
  157. with:
  158. name: spm-platforms-${{ matrix.target }}-${{ matrix.os }}-${{ matrix.xcode }}-logs
  159. path: xcodebuild-*.log
  160. if-no-files-found: error