From ec53e2efea9fda9dc9cd44d1da424a688f63a293 Mon Sep 17 00:00:00 2001 From: SeungYeop Yeom Date: Sun, 31 Mar 2024 17:35:02 +0900 Subject: [PATCH] Improve the CI process entirely --- .github/workflows/ci.yml | 24 ++++++++++++------- Makefile | 18 ++++++++------ Sources/OneWay/ViewStore.swift | 2 ++ Tests/OneWayTests/StoreTests.swift | 8 +++++++ .../TestHelper/Publisher+Async.swift | 2 ++ .../TestHelper/XCTestCase+Expect.swift | 6 +++++ Tests/OneWayTests/ViewStoreTests.swift | 2 ++ 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71d2c24..4cb01b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,16 +13,22 @@ concurrency: cancel-in-progress: true jobs: - ci: + macos: runs-on: macos-14 timeout-minutes: 30 - env: - SCHEME: OneWay + steps: + - uses: actions/checkout@v4 + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_15.2.app + - name: Build + run: make build-all + - name: Test + run: make test-swift + linux: + runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v3 - - uses: maxim-lobanov/setup-xcode@v1.6.0 - with: - xcode-version: '15.2' - - name: Build and test - run: make test-all + - uses: actions/checkout@v4 + - name: Test + run: make test-swift diff --git a/Makefile b/Makefile index 723ea70..e1c7165 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,13 @@ PLATFORM_VISIONOS = visionOS Simulator,name=Apple Vision Pro PLATFORM_WATCHOS = watchOS Simulator,name=Apple Watch Series 9 (45mm) CONFIG = debug -default: test-all +default: test-swift -test-all: - CONFIG=debug make test - CONFIG=release make test +build-all: + CONFIG=debug make build + CONFIG=release make build -test: +build: for platform in \ "$(PLATFORM_IOS)" \ "$(PLATFORM_MACOS)" \ @@ -19,10 +19,14 @@ test: "$(PLATFORM_VISIONOS)" \ "$(PLATFORM_WATCHOS)"; \ do \ - xcodebuild clean build test \ + xcodebuild build \ -scheme OneWay \ -configuration $(CONFIG) \ -destination platform="$$platform" || exit 1; \ done; -.PHONY: test-all test +test-swift: + swift test --parallel -c debug + swift test --parallel -c release + +.PHONY: build-all build test-swift diff --git a/Sources/OneWay/ViewStore.swift b/Sources/OneWay/ViewStore.swift index 956c1df..3cce8b3 100644 --- a/Sources/OneWay/ViewStore.swift +++ b/Sources/OneWay/ViewStore.swift @@ -5,6 +5,7 @@ // Copyright (c) 2022-2024 SeungYeop Yeom ( https://github.com/DevYeom ). // +#if !os(Linux) #if canImport(Combine) import Combine #endif @@ -97,3 +98,4 @@ where R.Action: Sendable, R.State: Sendable & Equatable { #if canImport(Combine) extension ViewStore: ObservableObject { } #endif +#endif diff --git a/Tests/OneWayTests/StoreTests.swift b/Tests/OneWayTests/StoreTests.swift index ef1a81f..a1a3189 100644 --- a/Tests/OneWayTests/StoreTests.swift +++ b/Tests/OneWayTests/StoreTests.swift @@ -6,7 +6,9 @@ // import Clocks +#if canImport(Combine) import Combine +#endif import OneWay import XCTest @@ -94,6 +96,7 @@ final class StoreTests: XCTestCase { await expect { await sut.state.text == "Success" } } + #if canImport(Combine) func test_bind() async { var result: Set = [] @@ -114,6 +117,7 @@ final class StoreTests: XCTestCase { XCTAssertEqual(result, ["", "first", "1", "second", "2"]) } + #endif func test_removeDuplicates() async { await sut.send(.response("First")) @@ -251,8 +255,10 @@ final class StoreTests: XCTestCase { } } +#if canImport(Combine) private let textPublisher = PassthroughSubject() private let numberPublisher = PassthroughSubject() +#endif @available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) private var _clock = TestClock() @@ -358,6 +364,7 @@ private struct TestReducer: Reducer { } } +#if canImport(Combine) func bind() -> AnyEffect { return .merge( .sequence { send in @@ -372,4 +379,5 @@ private struct TestReducer: Reducer { } ) } +#endif } diff --git a/Tests/OneWayTests/TestHelper/Publisher+Async.swift b/Tests/OneWayTests/TestHelper/Publisher+Async.swift index b79e91d..03c4d34 100644 --- a/Tests/OneWayTests/TestHelper/Publisher+Async.swift +++ b/Tests/OneWayTests/TestHelper/Publisher+Async.swift @@ -5,6 +5,7 @@ // Copyright (c) 2022-2024 SeungYeop Yeom ( https://github.com/DevYeom ). // +#if canImport(Combine) @preconcurrency import Combine extension Publisher where Failure == Never { @@ -21,3 +22,4 @@ extension Publisher where Failure == Never { } } } +#endif diff --git a/Tests/OneWayTests/TestHelper/XCTestCase+Expect.swift b/Tests/OneWayTests/TestHelper/XCTestCase+Expect.swift index 340f066..d6743f9 100644 --- a/Tests/OneWayTests/TestHelper/XCTestCase+Expect.swift +++ b/Tests/OneWayTests/TestHelper/XCTestCase+Expect.swift @@ -50,3 +50,9 @@ extension XCTestCase { } } } + +#if canImport(Darwin) +#else +let NSEC_PER_SEC: UInt64 = 1_000_000_000 +let NSEC_PER_MSEC: UInt64 = 1_000_000 +#endif diff --git a/Tests/OneWayTests/ViewStoreTests.swift b/Tests/OneWayTests/ViewStoreTests.swift index 571e100..2ddb86c 100644 --- a/Tests/OneWayTests/ViewStoreTests.swift +++ b/Tests/OneWayTests/ViewStoreTests.swift @@ -8,6 +8,7 @@ import OneWay import XCTest +#if !os(Linux) @MainActor final class ViewStoreTests: XCTestCase { private var sut: ViewStore! @@ -244,3 +245,4 @@ private actor Result { values.append(value) } } +#endif