Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ 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)" \
"$(PLATFORM_TVOS)" \
"$(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
2 changes: 2 additions & 0 deletions Sources/OneWay/ViewStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright (c) 2022-2024 SeungYeop Yeom ( https://github.com/DevYeom ).
//

#if !os(Linux)
#if canImport(Combine)
import Combine
#endif
Expand Down Expand Up @@ -97,3 +98,4 @@ where R.Action: Sendable, R.State: Sendable & Equatable {
#if canImport(Combine)
extension ViewStore: ObservableObject { }
#endif
#endif
8 changes: 8 additions & 0 deletions Tests/OneWayTests/StoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//

import Clocks
#if canImport(Combine)
import Combine
#endif
import OneWay
import XCTest

Expand Down Expand Up @@ -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<String> = []

Expand All @@ -114,6 +117,7 @@ final class StoreTests: XCTestCase {

XCTAssertEqual(result, ["", "first", "1", "second", "2"])
}
#endif

func test_removeDuplicates() async {
await sut.send(.response("First"))
Expand Down Expand Up @@ -251,8 +255,10 @@ final class StoreTests: XCTestCase {
}
}

#if canImport(Combine)
private let textPublisher = PassthroughSubject<String, Never>()
private let numberPublisher = PassthroughSubject<Int, Never>()
#endif

@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
private var _clock = TestClock()
Expand Down Expand Up @@ -358,6 +364,7 @@ private struct TestReducer: Reducer {
}
}

#if canImport(Combine)
func bind() -> AnyEffect<Action> {
return .merge(
.sequence { send in
Expand All @@ -372,4 +379,5 @@ private struct TestReducer: Reducer {
}
)
}
#endif
}
2 changes: 2 additions & 0 deletions Tests/OneWayTests/TestHelper/Publisher+Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -21,3 +22,4 @@ extension Publisher where Failure == Never {
}
}
}
#endif
6 changes: 6 additions & 0 deletions Tests/OneWayTests/TestHelper/XCTestCase+Expect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions Tests/OneWayTests/ViewStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import OneWay
import XCTest

#if !os(Linux)
@MainActor
final class ViewStoreTests: XCTestCase {
private var sut: ViewStore<TestReducer>!
Expand Down Expand Up @@ -244,3 +245,4 @@ private actor Result {
values.append(value)
}
}
#endif