Skip to content

Commit

Permalink
Update scripts for XCode Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaafanador3 committed Sep 6, 2023
1 parent a76c0c9 commit 15a81a0
Show file tree
Hide file tree
Showing 2 changed files with 570 additions and 54 deletions.
112 changes: 58 additions & 54 deletions scripts/pr-ci-matrix.rb
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
#!/usr/bin/env ruby
# A script to generate the `ci_post_clone.sh` file used to run all the Xcode Cloud CI pull request job
XCODE_VERSIONS = %w(14.1 14.2 14.3.1)

all = ->(v) { true }
latest_only = ->(v) { v == XCODE_VERSIONS.last }
oldest_and_latest = ->(v) { v == XCODE_VERSIONS.first or v == XCODE_VERSIONS.last }
# A script to generate the `ci_post_clone.sh` file used to run all the Xcode Cloud CI pull request jobs.

module WORKFLOWS
XCODE_VERSIONS = %w(14.1 14.2 14.3.1)

all = ->(v) { true }
latest_only = ->(v) { v == XCODE_VERSIONS.last }
oldest_and_latest = ->(v) { v == XCODE_VERSIONS.first or v == XCODE_VERSIONS.last }

TARGETS = {
'docs' => latest_only,
'swiftlint' => latest_only,

'osx' => all,
'osx-encryption' => latest_only,
'osx-object-server' => oldest_and_latest,

'swiftpm' => oldest_and_latest,
'swiftpm-debug' => all,
'swiftpm-address' => latest_only,
'swiftpm-thread' => latest_only,
'ios-xcode-spm' => all,

'ios-static' => oldest_and_latest,
'ios' => oldest_and_latest,
'watchos' => oldest_and_latest,
'tvos' => oldest_and_latest,

'osx-swift' => all,
'ios-swift' => oldest_and_latest,
'tvos-swift' => oldest_and_latest,

'osx-swift-evolution' => latest_only,
'ios-swift-evolution' => latest_only,
'tvos-swift-evolution' => latest_only,

'catalyst' => oldest_and_latest,
'catalyst-swift' => oldest_and_latest,

'xcframework' => latest_only,

'cocoapods-osx' => all,
'cocoapods-ios-static' => latest_only,
'cocoapods-ios' => latest_only,
'cocoapods-watchos' => latest_only,
'cocoapods-tvos' => latest_only,
'cocoapods-catalyst' => latest_only,
'swiftui-ios' => latest_only,
'swiftui-server-osx' => latest_only,
}
end

def minimum_version(major)
->(v) { v.split('.').first.to_i >= major }
end

targets = {
'docs' => latest_only,
'swiftlint' => latest_only,

'osx' => all,
'osx-encryption' => latest_only,
'osx-object-server' => oldest_and_latest,

'swiftpm' => oldest_and_latest,
'swiftpm-debug' => all,
'swiftpm-address' => latest_only,
'swiftpm-thread' => latest_only,
'ios-xcode-spm' => all,

'ios-static' => oldest_and_latest,
'ios' => oldest_and_latest,
'watchos' => oldest_and_latest,
'tvos' => oldest_and_latest,

'osx-swift' => all,
'ios-swift' => oldest_and_latest,
'tvos-swift' => oldest_and_latest,

'osx-swift-evolution' => latest_only,
'ios-swift-evolution' => latest_only,
'tvos-swift-evolution' => latest_only,

'catalyst' => oldest_and_latest,
'catalyst-swift' => oldest_and_latest,

'xcframework' => latest_only,

'cocoapods-osx' => all,
'cocoapods-ios-static' => latest_only,
'cocoapods-ios' => latest_only,
'cocoapods-watchos' => latest_only,
'cocoapods-tvos' => latest_only,
'cocoapods-catalyst' => latest_only,
'swiftui-ios' => latest_only,
'swiftui-server-osx' => latest_only,
}

output_file = "#!/bin/sh"
output_file << """
# This is a generated file produced by scripts/pr-ci-matrix.rb.
Expand Down Expand Up @@ -109,8 +112,8 @@ def minimum_version(major)
}
: '
xcode_version:#{XCODE_VERSIONS.map { |v| "\n - #{v}" }.join()}
target:#{targets.map { |k, v| "\n - #{k}" }.join()}
xcode_version:#{WORKFLOWS::XCODE_VERSIONS.map { |v| "\n - #{v}" }.join()}
target:#{WORKFLOWS::TARGETS.map { |k, v| "\n - #{k}" }.join()}
configuration:
- N/A
'
Expand All @@ -123,24 +126,25 @@ def minimum_version(major)
cd ..
"""

targets.each_with_index { |(name, filter), index|
XCODE_VERSIONS.each { |version|
WORKFLOWS::TARGETS.each_with_index { |(name, filter), index|
WORKFLOWS::XCODE_VERSIONS.each_with_index { |version, index2|
if filter.call(version)
output_file << """
: '
- xcode_version: #{version}
- target: #{name}
'
"""
if index == 0
if index == 0 && index2 == 0
output_file << "if [ \"$CI_WORKFLOW\" = \"#{name}_#{version}\" ]; then\n"
first = false
else
output_file << "elif [ \"$CI_WORKFLOW\" = \"#{name}_#{version}\" ]; then\n"
end
output_file << " export target=\"#{name}\"\n"
output_file << " sh -x build.sh ci-pr | ts\n"

if index == targets.size - 1
if index == WORKFLOWS::TARGETS.size - 1 && index2 == WORKFLOWS::XCODE_VERSIONS.size - 1
output_file << "\nelif [ \"$CI_WORKFLOW\" = \"Realm-Latest\" ] || [ \"$CI_WORKFLOW\" = \"RealmSwift-Latest\" ]; then\n"
output_file << " echo \"CI workflows for testing latest XCode releases\"\n"
output_file << "\nelse\n"
Expand Down
Loading

0 comments on commit 15a81a0

Please sign in to comment.