pr-ci-matrix.rb 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/usr/bin/env ruby
  2. # Matrix of current targets and XCode versions, and is used to add/update/delete XCode cloud workflows.
  3. Destination = Struct.new(:build_platform, :test_destination) do |cls|
  4. def cls.macOS
  5. Destination.new('MACOS', {
  6. 'deviceTypeName' => 'Mac',
  7. 'deviceTypeIdentifier' => 'mac',
  8. 'runtimeName' => 'Same As Selected macOS Version',
  9. 'runtimeIdentifier' => 'builder',
  10. 'kind' => 'MAC'
  11. })
  12. end
  13. def cls.catalyst
  14. Destination.new('MACOS', {
  15. 'deviceTypeName' => 'Mac (Mac Catalyst)',
  16. 'deviceTypeIdentifier' => 'mac_catalyst',
  17. 'runtimeName' => 'Same As Selected macOS Version',
  18. 'runtimeIdentifier' => 'builder',
  19. 'kind' => 'MAC'
  20. })
  21. end
  22. def cls.iOS
  23. Destination.new('IOS', {
  24. 'deviceTypeName' => 'iPhone 11',
  25. 'deviceTypeIdentifier' => 'com.apple.CoreSimulator.SimDeviceType.iPhone-11',
  26. 'runtimeName' => 'Latest from Selected Xcode (iOS 16.1)',
  27. 'runtimeIdentifier' => 'default',
  28. 'kind' => 'SIMULATOR'
  29. })
  30. end
  31. def cls.tvOS
  32. Destination.new('TVOS', {
  33. 'deviceTypeName' => 'Recommended Apple TVs',
  34. 'deviceTypeIdentifier' => 'recommended_apple_tvs',
  35. 'runtimeName' => 'Latest from Selected Xcode (tvOS 16.4)',
  36. 'runtimeIdentifier' => 'default',
  37. 'kind' => 'SIMULATOR'
  38. })
  39. end
  40. def cls.generic
  41. Destination.new('MACOS', nil)
  42. end
  43. end
  44. Target = Struct.new(:name, :scheme, :filter, :destination) do
  45. def action
  46. action = {
  47. name: self.name,
  48. actionType: 'BUILD',
  49. destination: nil,
  50. buildDistributionAudience: nil,
  51. scheme: self.scheme,
  52. platform: self.destination.build_platform,
  53. isRequiredToPass: true
  54. }
  55. test_destination = self.destination.test_destination
  56. if test_destination
  57. action[:actionType] = 'TEST'
  58. action[:destination] = 'ANY_MAC'
  59. action[:testConfiguration] = {
  60. kind: 'USE_SCHEME_SETTINGS',
  61. testPlanName: '',
  62. testDestinations: [test_destination]
  63. }
  64. end
  65. return action
  66. end
  67. end
  68. # Each test target has a name, a scheme, an xcode version filter, and a
  69. # destination to run tests on. Targets which aren't testing a framework
  70. # use the 'CI' target and always the a 'generic' destination.
  71. #
  72. # To avoid using excess CI resources we don't build the full matrix of
  73. # combinations of targets and Xcode version. We generally test each build
  74. # method (Xcode project, Swift package, and podspec) on every Xcode version for
  75. # a single platform, and everything else is tested with the oldest and newest
  76. # supported Xcode versions. Some things (e.g. swiftlint) only test the latest
  77. # because they don't care about Xcode versions, while some others are latest-only
  78. # because they're particularly slow to run.
  79. module Workflows
  80. XCODE_VERSIONS = %w(14.2 14.3.1 15.1 15.2 15.3)
  81. all = ->(v) { true }
  82. latest_only = ->(v) { v == XCODE_VERSIONS.last }
  83. oldest_and_latest = ->(v) { v == XCODE_VERSIONS.first or v == XCODE_VERSIONS.last }
  84. TARGETS = [
  85. Target.new('osx', 'Realm', all, Destination.macOS),
  86. Target.new('osx-encryption', 'Realm', latest_only, Destination.macOS),
  87. Target.new('osx-swift', 'RealmSwift', all, Destination.macOS),
  88. Target.new('osx-swift-evolution', 'RealmSwift', latest_only, Destination.macOS),
  89. Target.new('ios', 'Realm', oldest_and_latest, Destination.iOS),
  90. Target.new('ios-static', 'Realm', oldest_and_latest, Destination.iOS),
  91. Target.new('ios-swift', 'RealmSwift', oldest_and_latest, Destination.iOS),
  92. Target.new('ios-swift-evolution', 'RealmSwift', latest_only, Destination.iOS),
  93. Target.new('tvos', 'Realm', oldest_and_latest, Destination.tvOS),
  94. Target.new('tvos-static', 'Realm', oldest_and_latest, Destination.tvOS),
  95. Target.new('tvos-swift', 'RealmSwift', oldest_and_latest, Destination.tvOS),
  96. Target.new('tvos-swift-evolution', 'RealmSwift', latest_only, Destination.tvOS),
  97. Target.new('catalyst', 'Realm', oldest_and_latest, Destination.catalyst),
  98. Target.new('catalyst-swift', 'RealmSwift', oldest_and_latest, Destination.catalyst),
  99. Target.new('watchos', 'Realm', oldest_and_latest, Destination.generic),
  100. Target.new('watchos-swift', 'RealmSwift', oldest_and_latest, Destination.generic),
  101. Target.new('swiftui', 'SwiftUITests', latest_only, Destination.iOS),
  102. Target.new('swiftui-sync', 'SwiftUISyncTests', latest_only, Destination.macOS),
  103. Target.new('sync', 'Object Server Tests', oldest_and_latest, Destination.macOS),
  104. Target.new('docs', 'CI', latest_only, Destination.generic),
  105. Target.new('swiftlint', 'CI', latest_only, Destination.generic),
  106. Target.new('swiftpm', 'CI', oldest_and_latest, Destination.generic),
  107. Target.new('swiftpm-debug', 'CI', all, Destination.generic),
  108. Target.new('swiftpm-address', 'CI', latest_only, Destination.generic),
  109. Target.new('swiftpm-thread', 'CI', latest_only, Destination.generic),
  110. Target.new('spm-ios', 'CI', all, Destination.generic),
  111. Target.new('xcframework', 'CI', latest_only, Destination.generic),
  112. Target.new('cocoapods-osx', 'CI', all, Destination.generic),
  113. Target.new('cocoapods-ios', 'CI', latest_only, Destination.generic),
  114. Target.new('cocoapods-ios-static', 'CI', latest_only, Destination.generic),
  115. Target.new('cocoapods-watchos', 'CI', latest_only, Destination.generic),
  116. Target.new('cocoapods-tvos', 'CI', latest_only, Destination.generic),
  117. Target.new('cocoapods-catalyst', 'CI', latest_only, Destination.generic),
  118. ]
  119. end