Skip to content

Commit

Permalink
Update CI to run on macOS 11+ (#63)
Browse files Browse the repository at this point in the history
* Update CI to run on macOS 11

* Update build script to run on more platforms

* Run CI on more platforms

* Github actions does not support iOS or tvOS 12

* We don't run tests on watchOS 5

* Use the 'swift' from the Xcode install

* Get CI passing on Xcode 13 in Release

* Use xcversion
  • Loading branch information
dfed committed Sep 3, 2022
1 parent 70ae698 commit 944702f
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 61 deletions.
60 changes: 48 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,38 @@ on:
jobs:
pod-lint:
name: Pod Lint
runs-on: macOS-10.15
runs-on: macOS-11
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer
run: xcversion select 11.7
- name: Lint Podspec
run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.1
carthage:
name: Carthage
runs-on: macOS-10.15
runs-on: macOS-11
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer
run: xcversion select 11.7
- name: Install Carthage
run: brew outdated carthage || brew upgrade carthage
- name: Build Framework
run: swift package generate-xcodeproj --output generated/ && carthage build --project-directory generated/ --verbose --no-skip-current
spm-11:
name: SPM Build Xcode 11
runs-on: macOS-10.15
name: Build Xcode 11
runs-on: macOS-11
strategy:
matrix:
platforms: [
'iOS_12,tvOS_12',
'iOS_13,tvOS_13,watchOS_6',
'macOS_10_15'
'macOS_10_15',
]
fail-fast: false
steps:
Expand All @@ -50,7 +49,7 @@ jobs:
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer
run: xcversion select 11.7
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
- name: Build and Test Framework
Expand All @@ -59,12 +58,13 @@ jobs:
if: success()
run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }}
spm-12:
name: SPM Build Xcode 12
runs-on: macOS-10.15
name: Build Xcode 12
runs-on: macOS-11
strategy:
matrix:
platforms: [
'iOS_14,tvOS_14,watchOS_7',
'macOS_11',
]
fail-fast: false
steps:
Expand All @@ -73,11 +73,47 @@ jobs:
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer
run: xcversion select 12.4
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
- name: Build and Test Framework
run: Scripts/build.swift ${{ matrix.platforms }}
- name: Upload Coverage Reports
if: success()
run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }}
spm-13:
name: Build Xcode 13
runs-on: macOS-12
strategy:
matrix:
platforms: [
'iOS_15,tvOS_15,watchOS_8',
'macOS_12',
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: xcversion select 13.4.1
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }}
- name: Build and Test Framework
run: Scripts/build.swift ${{ matrix.platforms }}
- name: Upload Coverage Reports
if: success()
run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }}
spm-13-swift:
name: Swift Build Xcode 13
runs-on: macOS-12
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: xcversion select 13.4.1
- name: Build and Test Framework
run: xcrun swift test -c release -Xswiftc -enable-testing
120 changes: 82 additions & 38 deletions Scripts/build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,82 +21,113 @@ enum TaskError: Error {
}

enum Platform: String, CaseIterable, CustomStringConvertible {
case iOS_12
case iOS_13
case iOS_14
case tvOS_12
case iOS_15
case tvOS_13
case tvOS_14
case tvOS_15
case macOS_10_15
case watchOS_5
case macOS_11
case macOS_12
case watchOS_6
case watchOS_7
case watchOS_8

var destination: String {
switch self {
case .iOS_12:
return "platform=iOS Simulator,OS=12.4,name=iPad Pro (12.9-inch) (3rd generation)"
case .iOS_13:
return "platform=iOS Simulator,OS=13.7,name=iPad Pro (12.9-inch) (4th generation)"
case .iOS_14:
return "platform=iOS Simulator,OS=14.4,name=iPad Pro (12.9-inch) (4th generation)"
case .iOS_15:
return "platform=iOS Simulator,OS=15.5,name=iPad Pro (12.9-inch) (5th generation)"

case .tvOS_12:
return "platform=tvOS Simulator,OS=12.4,name=Apple TV"
case .tvOS_13:
return "platform=tvOS Simulator,OS=13.4,name=Apple TV"
case .tvOS_14:
return "platform=tvOS Simulator,OS=14.3,name=Apple TV"
case .tvOS_15:
return "platform=tvOS Simulator,OS=15.4,name=Apple TV"

case .macOS_10_15:
case .macOS_10_15,
.macOS_11,
.macOS_12:
return "platform=OS X"

case .watchOS_5:
return "OS=5.3,name=Apple Watch Series 4 - 44mm"
case .watchOS_6:
return "OS=6.2.1,name=Apple Watch Series 4 - 44mm"
case .watchOS_7:
return "OS=7.2,name=Apple Watch Series 6 - 44mm"
case .watchOS_8:
return "OS=8.5,name=Apple Watch Series 6 - 44mm"
}
}

var sdk: String {
switch self {
case .iOS_12,
.iOS_13,
.iOS_14:
case .iOS_13,
.iOS_14,
.iOS_15:
return "iphonesimulator"

case .tvOS_12,
.tvOS_13,
.tvOS_14:
case .tvOS_13,
.tvOS_14,
.tvOS_15:
return "appletvsimulator"

case .macOS_10_15:
return "macosx10.15"

case .watchOS_5,
.watchOS_6,
.watchOS_7:
case .macOS_11:
return "macosx11.1"
case .macOS_12:
return "macosx12.3"

case .watchOS_6,
.watchOS_7,
.watchOS_8:
return "watchsimulator"
}
}

var shouldTest: Bool {
switch self {
case .iOS_12,
.iOS_13,
case .iOS_13,
.iOS_14,
.tvOS_12,
.iOS_15,
.tvOS_13,
.tvOS_14,
.macOS_10_15:
.tvOS_15,
.macOS_10_15,
.macOS_11,
.macOS_12:
return true

case .watchOS_5,
case .watchOS_6,
.watchOS_7,
.watchOS_8:
// watchOS does not support unit testing (yet?).
return false
}
}

var shouldGenerateXcodeproj: Bool {
switch self {
case .iOS_13,
.iOS_14,
.tvOS_13,
.tvOS_14,
.macOS_10_15,
.macOS_11,
.watchOS_6,
.watchOS_7:
// watchOS does not support unit testing (yet?).
return true

case .iOS_15,
.tvOS_15,
.macOS_12,
.watchOS_8:
// Xcode 13 does not require xcodeproj generation
return false
}
}
Expand All @@ -115,31 +146,43 @@ guard CommandLine.arguments.count > 1 else {
throw TaskError.code(1)
}

try execute(commandPath: "/usr/bin/swift", arguments: ["package", "generate-xcodeproj", "--output=generated/"])

// The generate-xcodeproj command has a bug where the test deployment target is above the minimum deployment target for the project. Fix it with sed.
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/IPHONEOS_DEPLOYMENT_TARGET = \"14.0\"/IPHONEOS_DEPLOYMENT_TARGET = \"12.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/TVOS_DEPLOYMENT_TARGET = \"14.0\"/TVOS_DEPLOYMENT_TARGET = \"12.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/WATCHOS_DEPLOYMENT_TARGET = \"7.0\"/MACOSX_DEPLOYMENT_TARGET = \"5.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/MACOSX_DEPLOYMENT_TARGET = \"11.0\"/MACOSX_DEPLOYMENT_TARGET = \"10.15\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])

let rawPlatforms = CommandLine.arguments[1].components(separatedBy: ",")

var isFirstRun = true
for rawPlatform in rawPlatforms {
guard let platform = Platform(rawValue: rawPlatform) else {
print("Received unknown platform type \(rawPlatform)")
print("Possible platform types are: \(Platform.allCases)")
throw TaskError.code(1)
}

if isFirstRun && platform.shouldGenerateXcodeproj {
// Generate the xcode project if we need it
try execute(commandPath: "/usr/bin/swift", arguments: ["package", "generate-xcodeproj", "--output=generated/"])

// The generate-xcodeproj command has a bug where the test deployment target is above the minimum deployment target for the project. Fix it with sed.
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/IPHONEOS_DEPLOYMENT_TARGET = \"14.0\"/IPHONEOS_DEPLOYMENT_TARGET = \"12.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/TVOS_DEPLOYMENT_TARGET = \"14.0\"/TVOS_DEPLOYMENT_TARGET = \"12.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/WATCHOS_DEPLOYMENT_TARGET = \"7.0\"/WATCHOS_DEPLOYMENT_TARGET = \"5.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
try execute(commandPath: "/usr/bin/sed", arguments: ["-i", "-e", "s/MACOSX_DEPLOYMENT_TARGET = \"11.0\"/MACOSX_DEPLOYMENT_TARGET = \"11.0\"/g", "generated/CacheAdvance.xcodeproj/project.pbxproj"])
}

var xcodeBuildArguments = [
"-project", "generated/CacheAdvance.xcodeproj",
"-scheme", "CacheAdvance-Package",
"-sdk", platform.sdk,
"-configuration", "Release",
"-derivedDataPath", platform.derivedDataPath,
"-PBXBuildsContinueAfterErrors=0",
"OTHER_CFLAGS='-DGENERATED_XCODE_PROJECT'",
"-PBXBuildsContinueAfterErrors=0"
]
if platform.shouldGenerateXcodeproj {
// Point at the generated project
xcodeBuildArguments.append("-project")
xcodeBuildArguments.append("generated/CacheAdvance.xcodeproj")
// Set the configuration to be release – this configuration is not supported when running xcodebuild without a xcodeproj file.
xcodeBuildArguments.append("-configuration")
xcodeBuildArguments.append("Release")
// Set a compiler flag to enable a xcodeproj-specific build flag.
xcodeBuildArguments.append("OTHER_CFLAGS='-DGENERATED_XCODE_PROJECT'")
}
if !platform.destination.isEmpty {
xcodeBuildArguments.append("-destination")
xcodeBuildArguments.append(platform.destination)
Expand All @@ -154,4 +197,5 @@ for rawPlatform in rawPlatforms {
}

try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments)
isFirstRun = false
}
8 changes: 0 additions & 8 deletions Scripts/github/prepare-simulators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ if [[ ${PLATFORMS[*]} =~ 'iOS_13' ]]; then
sudo ln -s /Applications/Xcode_11.7.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 13.7.simruntime
fi

if [[ ${PLATFORMS[*]} =~ 'iOS_12' ]]; then
sudo ln -s /Applications/Xcode_10.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 12.4.simruntime
fi

if [[ ${PLATFORMS[*]} =~ 'tvOS_13' ]]; then
sudo ln -s /Applications/Xcode_11.7.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS\ 13.4.simruntime
fi

if [[ ${PLATFORMS[*]} =~ 'tvOS_12' ]]; then
sudo ln -s /Applications/Xcode_10.3.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/tvOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS\ 12.4.simruntime
fi

xcrun simctl list runtimes
6 changes: 3 additions & 3 deletions Sources/CacheAdvance/BigEndianHostSwappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extension BigEndianHostSwappable {
///
/// - Parameter data: A data blob representing encodable data. Must be of length `Self.storageLength`.
init(_ data: Data) {
let decodedSize = withUnsafePointer(to: data) {
return UnsafeRawBufferPointer(start: $0, count: Self.storageLength)
let decodedSize = data.withUnsafeBytes {
return $0.load(as: Self.self)
}
self = Self.swapToHost(decodedSize.load(as: Self.self))
self = Self.swapToHost(decodedSize)
}

/// The length of a contiguous data blob required to store this type.
Expand Down

0 comments on commit 944702f

Please sign in to comment.