From 02292e70cf0bd04587a4c0e6d83a61511a2a9943 Mon Sep 17 00:00:00 2001 From: Brandon Williams <135203+mbrandonw@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:11:47 -0400 Subject: [PATCH] Improve CI jobs (#3357) * Improve CI jobs. * wip * wip * exclude * more exclude * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * try out caching * fix yml * fix makefile syntax * cache key * wip * fix * wip * wip * boop * wip * wip * wip * wip * wip * wip * wip * boop * wip * wip * wip * wip * wip * wip * wip * wip * fix visionos tests * wip * wip * wip * wip * wip * wip * boop * wip * boop * Update ci.yml * Update Makefile * Update Makefile * clean up --------- Co-authored-by: Stephen Celis --- .../xcshareddata/swiftpm/Package.resolved | 3 +- .github/workflows/ci.yml | 113 +++++++++++------- .../xcshareddata/swiftpm/Package.resolved | 10 +- Makefile | 70 ++++++++--- .../Reducers/PresentationReducerTests.swift | 2 + .../StoreTests.swift | 2 + 6 files changed, 130 insertions(+), 70 deletions(-) diff --git a/.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved b/.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7bde30387cf4..e06ac440c8c7 100644 --- a/.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,4 @@ { - "originHash" : "a84dfeef15185f26bd546eb430da9b0b1f23f5a08c6ac0f99b345a8de1564068", "pins" : [ { "identity" : "combine-schedulers", @@ -164,5 +163,5 @@ } } ], - "version" : 3 + "version" : 2 } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c766037e1be1..203eed92e737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,68 +14,93 @@ concurrency: cancel-in-progress: true jobs: - library-swift-latest: - name: Library + xcodebuild: + name: xcodebuild runs-on: macos-14 strategy: matrix: - xcode: - - 15.4 - - 16_beta_6 - config: - - debug - - release + command: [test, ''] + platform: [iOS, macOS, tvOS, watchOS, visionOS, macCatalyst] + xcode: [15.2, 15.4, 16_beta_6] + exclude: + - {xcode: 15.2, command: test} + - {xcode: 15.4, command: ''} + - {xcode: 15.2, platform: macCatalyst} + - {xcode: 15.2, platform: tvOS} + - {xcode: 15.2, platform: visionOS} + - {xcode: 15.2, platform: watchOS} + - {xcode: 16_beta_6, command: ''} + - {xcode: 16_beta_6, platform: macCatalyst} + - {xcode: 16_beta_6, platform: tvOS} + - {xcode: 16_beta_6, platform: visionOS} + - {xcode: 16_beta_6, platform: watchOS} + include: + - {xcode: 15.2, skip_release: 1} steps: - uses: actions/checkout@v4 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - - name: Build ${{ matrix.config }} - run: make CONFIG=${{ matrix.config }} build-all-platforms - - name: Run ${{ matrix.config }} tests - if: matrix.xcode == '15.4' - run: make CONFIG=${{ matrix.config }} test-library + - name: Cache derived data + uses: actions/cache@v3 + with: + path: | + ~/.derivedData + key: | + deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }} + restore-keys: | + deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}- + - name: Set IgnoreFileSystemDeviceInodeChanges flag + run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES + - name: Update mtime for incremental builds + uses: chetan/git-restore-mtime-action@v2 + - name: Debug + run: make COMMAND="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild + - name: Release + if: matrix.skip_release != '1' + run: make COMMAND="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild - # library-evolution: - # name: Library (evolution) - # runs-on: macos-14 - # steps: - # - uses: actions/checkout@v4 - # - name: Select Xcode 15.4 - # run: sudo xcode-select -s /Applications/Xcode_15.4.app - # - name: Build for library evolution - # run: make build-for-library-evolution - - library-compatibility: - name: Library (Swift 5.9) - runs-on: macos-14 - strategy: - matrix: - config: - - debug - - release - steps: - - uses: actions/checkout@v4 - - name: Select Xcode 15.2 - run: sudo xcode-select -s /Applications/Xcode_15.2.app - - name: Build ${{ matrix.config }} - run: swift build -c ${{ matrix.config }} - - benchmarks: - name: Benchmarks + library-evolution: + name: Library (evolution) runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: Select Xcode 15.4 run: sudo xcode-select -s /Applications/Xcode_15.4.app - - name: Run benchmark - run: make benchmark + - name: Build for library evolution + run: make build-for-library-evolution examples: name: Examples runs-on: macos-14 steps: - uses: actions/checkout@v4 + - name: Cache derived data + uses: actions/cache@v3 + with: + path: ~/.derivedData + key: | + deriveddata-examples-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift', '**/Examples/**/*.swift') }} + restore-keys: | + deriveddata-examples- - name: Select Xcode 15.4 run: sudo xcode-select -s /Applications/Xcode_15.4.app - - name: Run tests - run: make test-examples + - name: Set IgnoreFileSystemDeviceInodeChanges flag + run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES + - name: Update mtime for incremental builds + uses: chetan/git-restore-mtime-action@v2 + - name: CaseStudies (SwiftUI) + run: make SCHEME="CaseStudies (SwiftUI)" test-example + - name: CaseStudies (UIKit) + run: make SCHEME="CaseStudies (UIKit)" test-example + - name: Search + run: make SCHEME="Search" test-example + - name: SyncUps + run: make SCHEME="SyncUps" test-example + - name: SpeechRecognition + run: make SCHEME="SpeechRecognition" test-example + - name: TicTacToe + run: make SCHEME="TicTacToe" test-example + - name: Todos + run: make SCHEME="Todos" test-example + - name: VoiceMemos + run: make SCHEME="VoiceMemos" test-example diff --git a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved index 3a52a97357c9..64b602f4135d 100644 --- a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "71344dd930fde41e8f3adafe260adcbb2fc2a3dc", - "version" : "1.5.4" + "revision" : "642e6aab8e03e5f992d9c83e38c5be98cfad5078", + "version" : "1.5.5" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-docc-plugin", "state" : { - "revision" : "0510d9160330025fb5823f7845c26af3cd56a405", - "version" : "1.4.1" + "revision" : "2eb22993b3dfd0c0d32729b357c8dabb6cd44680", + "version" : "1.4.2" } }, { @@ -150,7 +150,7 @@ "location" : "https://github.com/swiftlang/swift-syntax", "state" : { "revision" : "515f79b522918f83483068d99c68daeb5116342d", - "version" : "600.0.0-prerelease-2024-08-20" + "version" : "600.0.0-prerelease-2024-09-04" } }, { diff --git a/Makefile b/Makefile index 5fdf379b72a1..9c4d5ce8e1e6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ CONFIG = debug +PLATFORM = iOS PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17.5,iPhone \d\+ Pro [^M]) PLATFORM_MACOS = macOS PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst @@ -14,25 +15,57 @@ test-all: test-examples $(MAKE) CONFIG=debug test-library $(MAKE) CONFIG=release test-library -build-all-platforms: - for platform in "iOS" "macOS" "macOS,variant=Mac Catalyst" "tvOS" "visionOS" "watchOS"; do \ - xcodebuild \ +xcodebuild: + if test "$(PLATFORM)" = "iOS"; \ + then xcodebuild $(COMMAND) \ -skipMacroValidation \ -configuration $(CONFIG) \ -workspace .github/package.xcworkspace \ -scheme ComposableArchitecture \ - -destination generic/platform="$$platform" || exit 1; \ - done; - -test-library: - for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)"; do \ - xcodebuild test \ + -destination platform="$(PLATFORM_IOS)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + elif test "$(PLATFORM)" = "macOS"; \ + then xcodebuild $(COMMAND) \ + -skipMacroValidation \ + -configuration $(CONFIG) \ + -workspace .github/package.xcworkspace \ + -scheme ComposableArchitecture \ + -destination platform="$(PLATFORM_MACOS)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + elif test "$(PLATFORM)" = "tvOS"; \ + then xcodebuild $(COMMAND) \ + -skipMacroValidation \ + -configuration $(CONFIG) \ + -workspace .github/package.xcworkspace \ + -scheme ComposableArchitecture \ + -destination platform="$(PLATFORM_TVOS)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + elif test "$(PLATFORM)" = "watchOS"; \ + then xcodebuild $(COMMAND) \ + -skipMacroValidation \ + -configuration $(CONFIG) \ + -workspace .github/package.xcworkspace \ + -scheme ComposableArchitecture \ + -destination platform="$(PLATFORM_WATCHOS)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + elif test "$(PLATFORM)" = "visionOS"; \ + then xcodebuild $(COMMAND) \ + -skipMacroValidation \ + -configuration $(CONFIG) \ + -workspace .github/package.xcworkspace \ + -scheme ComposableArchitecture \ + -destination platform="$(PLATFORM_VISIONOS)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + elif test "$(PLATFORM)" = "macCatalyst"; \ + then xcodebuild $(COMMAND) \ -skipMacroValidation \ -configuration $(CONFIG) \ -workspace .github/package.xcworkspace \ -scheme ComposableArchitecture \ - -destination platform="$$platform" || exit 1; \ - done; + -destination platform="$(PLATFORM_MAC_CATALYST)" \ + -derivedDataPath ~/.derivedData/$(CONFIG); \ + else exit 1; \ + fi; build-for-library-evolution: swift build \ @@ -54,19 +87,18 @@ test-docs: || (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \ && exit 1) -test-examples: - for scheme in "CaseStudies (SwiftUI)" "CaseStudies (UIKit)" Search SyncUps SpeechRecognition TicTacToe Todos VoiceMemos; do \ - xcodebuild test \ - -skipMacroValidation \ - -scheme "$$scheme" \ - -destination platform="$(PLATFORM_IOS)" || exit 1; \ - done +test-example: + xcodebuild test \ + -skipMacroValidation \ + -scheme "$(SCHEME)" \ + -destination platform="$(PLATFORM_IOS)" \ + -derivedDataPath ~/.derivedData test-integration: xcodebuild test \ -skipMacroValidation \ -scheme "Integration" \ - -destination platform="$(PLATFORM_IOS)" || exit 1; + -destination platform="$(PLATFORM_IOS)" benchmark: swift run --configuration release \ diff --git a/Tests/ComposableArchitectureTests/Reducers/PresentationReducerTests.swift b/Tests/ComposableArchitectureTests/Reducers/PresentationReducerTests.swift index c59603500057..69396ddfb095 100644 --- a/Tests/ComposableArchitectureTests/Reducers/PresentationReducerTests.swift +++ b/Tests/ComposableArchitectureTests/Reducers/PresentationReducerTests.swift @@ -2617,6 +2617,7 @@ final class PresentationReducerTests: BaseTCATestCase { } } + #if !os(visionOS) @Reducer struct TestEphemeralBindingDismissalFeature { @ObservableState @@ -2647,6 +2648,7 @@ final class PresentationReducerTests: BaseTCATestCase { $store.scope(state: \.alert, action: \.alert).wrappedValue = nil XCTAssertNil(store.alert) } + #endif } @Reducer diff --git a/Tests/ComposableArchitectureTests/StoreTests.swift b/Tests/ComposableArchitectureTests/StoreTests.swift index ae58b156fd45..2f842d8f1708 100644 --- a/Tests/ComposableArchitectureTests/StoreTests.swift +++ b/Tests/ComposableArchitectureTests/StoreTests.swift @@ -1088,6 +1088,7 @@ final class StoreTests: BaseTCATestCase { var body: some ReducerOf { EmptyReducer() } } +#if !os(visionOS) @MainActor func testInvalidatedStoreScope() async throws { @Perception.Bindable var store = Store( @@ -1107,6 +1108,7 @@ final class StoreTests: BaseTCATestCase { store.send(.child(.dismiss)) grandchildStoreBinding.wrappedValue = nil } + #endif @MainActor func testSurroundingDependencies() {