From 2c9e0b99af59cb50e085f7c4ad90105a87197b83 Mon Sep 17 00:00:00 2001 From: Michael Rebello Date: Tue, 9 Jan 2024 09:28:20 -0800 Subject: [PATCH] Update CI to Xcode 15.1 & run builds for iOS, watchOS, tvOS (#231) - Adds new CI jobs to build the library against macOS, iOS, tvOS, and watchOS rather than only the default environment (macOS) - Updates `@available` annotations to properly accommodate these additional platforms - Updates CI to use Xcode 15.1 Originally the intent was to run tests on each platform, but for some reason GitHub runners are refusing to cooperate and jobs are stalling. Instead, we'll continue running `swift test` which runs tests on the host environment (macOS) and will use `xcodebuild` to build for each platform since it allows for specifying a target SDK/environment (see [this question](https://stackoverflow.com/questions/60245159/how-can-i-build-a-swift-package-for-ios-over-command-line) and [these notes](https://www.jessesquires.com/blog/2021/11/03/swift-package-ios-tests/)). Follow-up to https://github.com/connectrpc/connect-swift/pull/227 and related to https://github.com/connectrpc/connect-swift/issues/226. --- .github/workflows/ci.yaml | 77 ++++++++++++++----- .github/workflows/release.yml | 4 +- .../MockBidirectionalStream.swift | 2 +- .../ConnectMocks/MockClientOnlyStream.swift | 2 +- .../ConnectMocks/MockServerOnlyStream.swift | 2 +- .../CallbackConformanceTests.swift | 5 +- .../InterceptorIntegrationTests.swift | 6 +- 7 files changed, 67 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 621ab0a2..2ce127b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,45 +8,84 @@ on: permissions: contents: read jobs: - build-connect-library: - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app - - name: Build Connect library - run: make buildpackage build-eliza-cocoapods-example: runs-on: macos-13 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify - name: Build Eliza CocoaPods example run: | cd Examples/ElizaCocoaPodsApp pod install - xcodebuild -workspace ElizaCocoaPodsApp.xcworkspace -scheme ElizaCocoaPodsApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO + set -o pipefail && xcodebuild -workspace ElizaCocoaPodsApp.xcworkspace -scheme ElizaCocoaPodsApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify build-eliza-swiftpm-example: runs-on: macos-13 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify - name: Build Eliza Swift PM example run: | cd Examples/ElizaSwiftPackageApp - xcodebuild -scheme ElizaSwiftPackageApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO + set -o pipefail && xcodebuild -scheme ElizaSwiftPackageApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify + build-library-ios: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify + - name: Build Connect iOS library + run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' | xcbeautify + build-library-macos: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify + - name: Build Connect macOS library + run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=macOS' | xcbeautify + build-library-tvos: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify + - name: Build Connect tvOS library + run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=tvOS Simulator,name=Apple TV,OS=17.2' | xcbeautify + build-library-watchos: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app + - name: Install xcbeautify + run: brew install xcbeautify + - name: Build Connect watchOS library + run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2' | xcbeautify build-plugin-and-generate: runs-on: macos-13 steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app - uses: bufbuild/buf-setup-action@v1.28.1 with: github_token: ${{ github.token }} @@ -63,8 +102,8 @@ jobs: steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app - name: Set up docker (missing on macOS GitHub runners) # https://github.com/actions/runner-images/issues/2150 run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bce259b8..6609475c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,8 +12,8 @@ jobs: steps: - uses: actions/checkout@v4 - name: Select Xcode version - # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + # https://github.com/actions/runner-images/releases/tag/macos-13%2F20231218.2 + run: sudo xcode-select --switch /Applications/Xcode_15.1.app - uses: bufbuild/buf-setup-action@v1.28.1 with: github_token: ${{ github.token }} diff --git a/Libraries/ConnectMocks/MockBidirectionalStream.swift b/Libraries/ConnectMocks/MockBidirectionalStream.swift index 9060f159..18ed8879 100644 --- a/Libraries/ConnectMocks/MockBidirectionalStream.swift +++ b/Libraries/ConnectMocks/MockBidirectionalStream.swift @@ -23,7 +23,7 @@ import SwiftProtobuf /// or by subclassing the type and overriding functions such as `send()`. /// /// To return data over the stream, outputs can be specified using `init(outputs: ...)`. -@available(iOS 13.0, *) +@available(iOS 13, *) open class MockBidirectionalStream< Input: ProtobufMessage, Output: ProtobufMessage diff --git a/Libraries/ConnectMocks/MockClientOnlyStream.swift b/Libraries/ConnectMocks/MockClientOnlyStream.swift index d63caf2a..2989d8de 100644 --- a/Libraries/ConnectMocks/MockClientOnlyStream.swift +++ b/Libraries/ConnectMocks/MockClientOnlyStream.swift @@ -22,7 +22,7 @@ import SwiftProtobuf /// or by subclassing the type and overriding functions such as `send()`. /// /// To return data over the stream, outputs can be specified using `init(outputs: ...)`. -@available(iOS 13.0, *) +@available(iOS 13, *) open class MockClientOnlyStream< Input: ProtobufMessage, Output: ProtobufMessage diff --git a/Libraries/ConnectMocks/MockServerOnlyStream.swift b/Libraries/ConnectMocks/MockServerOnlyStream.swift index 4ed6dea9..fe3e0c16 100644 --- a/Libraries/ConnectMocks/MockServerOnlyStream.swift +++ b/Libraries/ConnectMocks/MockServerOnlyStream.swift @@ -23,7 +23,7 @@ import SwiftProtobuf /// or by subclassing the type and overriding functions such as `send()`. /// /// To return data over the stream, outputs can be specified using `init(outputs: ...)`. -@available(iOS 13.0, *) +@available(iOS 13, *) open class MockServerOnlyStream< Input: ProtobufMessage, Output: ProtobufMessage diff --git a/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformanceTests.swift b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformanceTests.swift index 99ce2118..ccf519c6 100644 --- a/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformanceTests.swift +++ b/Tests/ConnectLibraryTests/ConnectConformance/CallbackConformanceTests.swift @@ -180,10 +180,7 @@ final class CallbackConformanceTests: XCTestCase { } // Minimum requirements for runtime support for parameterized protocol types - @available(iOS 16, *) - @available(macOS 13, *) - @available(tvOS 16, *) - @available(watchOS 9, *) + @available(macOS 13, iOS 16, watchOS 9, tvOS 16, *) func testPingPong() { func createPayload( requestSize: Int, diff --git a/Tests/ConnectLibraryTests/ConnectTests/InterceptorIntegrationTests.swift b/Tests/ConnectLibraryTests/ConnectTests/InterceptorIntegrationTests.swift index e9ff20a0..ba561082 100644 --- a/Tests/ConnectLibraryTests/ConnectTests/InterceptorIntegrationTests.swift +++ b/Tests/ConnectLibraryTests/ConnectTests/InterceptorIntegrationTests.swift @@ -16,9 +16,7 @@ import SwiftProtobuf import XCTest -@available(iOS 16, *) -@available(tvOS 16, *) -@available(watchOS 9, *) +@available(iOS 13, *) final class InterceptorIntegrationTests: XCTestCase { func testUnaryInterceptorSuccess() async { let trackedSteps = Locked([InterceptorStep]()) @@ -112,6 +110,7 @@ final class InterceptorIntegrationTests: XCTestCase { ]) } + @available(macOS 13, iOS 16, watchOS 9, tvOS 16, *) // Required for .contains() func testUnaryInterceptorIsCalledWithMetrics() async { let trackedSteps = Locked([InterceptorStep]()) let client = self.createClient(interceptors: [ @@ -139,6 +138,7 @@ final class InterceptorIntegrationTests: XCTestCase { )) } + @available(macOS 13, iOS 16, watchOS 9, tvOS 16, *) // Required for .contains() func testStreamInterceptorIsCalledWithMetrics() async throws { let trackedSteps = Locked([InterceptorStep]()) let client = self.createClient(interceptors: [