Skip to content

Commit

Permalink
Improve CI jobs (#3357)
Browse files Browse the repository at this point in the history
* 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 <stephen@stephencelis.com>
  • Loading branch information
mbrandonw and stephencelis committed Sep 10, 2024
1 parent e036737 commit 02292e7
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"originHash" : "a84dfeef15185f26bd546eb430da9b0b1f23f5a08c6ac0f99b345a8de1564068",
"pins" : [
{
"identity" : "combine-schedulers",
Expand Down Expand Up @@ -164,5 +163,5 @@
}
}
],
"version" : 3
"version" : 2
}
113 changes: 69 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down Expand Up @@ -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"
}
},
{
Expand Down
70 changes: 51 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,7 @@ final class PresentationReducerTests: BaseTCATestCase {
}
}

#if !os(visionOS)
@Reducer
struct TestEphemeralBindingDismissalFeature {
@ObservableState
Expand Down Expand Up @@ -2647,6 +2648,7 @@ final class PresentationReducerTests: BaseTCATestCase {
$store.scope(state: \.alert, action: \.alert).wrappedValue = nil
XCTAssertNil(store.alert)
}
#endif
}

@Reducer
Expand Down
2 changes: 2 additions & 0 deletions Tests/ComposableArchitectureTests/StoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ final class StoreTests: BaseTCATestCase {
var body: some ReducerOf<Self> { EmptyReducer() }
}

#if !os(visionOS)
@MainActor
func testInvalidatedStoreScope() async throws {
@Perception.Bindable var store = Store(
Expand All @@ -1107,6 +1108,7 @@ final class StoreTests: BaseTCATestCase {
store.send(.child(.dismiss))
grandchildStoreBinding.wrappedValue = nil
}
#endif

@MainActor
func testSurroundingDependencies() {
Expand Down

0 comments on commit 02292e7

Please sign in to comment.