Skip to content

Commit

Permalink
Github action workflow and tests fix (#32)
Browse files Browse the repository at this point in the history
* CI fix

Removed lint step for a while

* Updated simulator device for testing

* Update tests.yml

* fixed tests
  • Loading branch information
KazaiMazai authored Aug 23, 2024
1 parent 41bfbf8 commit afc47f9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 47 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Lint
run: swiftlint
- uses: actions/checkout@v4
- name: Build for iOS
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild build-for-testing -scheme Puredux -destination "platform=iOS Simulator,OS=latest,name=iPhone 12" | xcpretty
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild build-for-testing -scheme Puredux -destination "platform=iOS Simulator,OS=17.4,name=iPhone 14" | xcpretty
- name: Run iOS tests
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild test-without-building -scheme Puredux -destination "platform=iOS Simulator,OS=latest,name=iPhone 12" | xcpretty

run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild test-without-building -scheme Puredux -destination "platform=iOS Simulator,OS=17.4,name=iPhone 14" | xcpretty
12 changes: 6 additions & 6 deletions Tests/PureduxTests/SideEffectsTests/SideEfectsBoolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SideEfectsBoolTests: XCTestCase {
let timeout: TimeInterval = 3.0

func test_WhenStateIsToggledToTrue_EffectExecuted() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")

Expand All @@ -34,7 +34,7 @@ final class SideEfectsBoolTests: XCTestCase {
}

func test_WhenBoolIsSetToTrueMultipleTime_EffectExecutedOnce() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")

Expand All @@ -54,7 +54,7 @@ final class SideEfectsBoolTests: XCTestCase {
}

func test_WhenBoolIsToggledTrueMultiple_EffectExecutedOnEveryToggle() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")
asyncExpectation.expectedFulfillmentCount = 3
Expand All @@ -76,7 +76,7 @@ final class SideEfectsBoolTests: XCTestCase {
}

func test_WhenEffectIsSkipped_ThenEffectCreationIsCalledAgain() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect creation executed")
asyncExpectation.expectedFulfillmentCount = 3
Expand All @@ -95,7 +95,7 @@ final class SideEfectsBoolTests: XCTestCase {
}

func test_WhenStateIsNotChangedAndFalse_ThenEffectIsNotCreated() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect creation executed")
asyncExpectation.isInverted = true
Expand All @@ -115,7 +115,7 @@ final class SideEfectsBoolTests: XCTestCase {
}

func test_WhenStateIsNotChangedAndFalse_ThenEffectIsNotExecuted() {
let store = StateStore<Bool, Bool>(initialState: false, reducer: { state, action in state = action })
let store = StateStore<Bool, Bool>(false, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")
asyncExpectation.isInverted = true
Expand Down
20 changes: 10 additions & 10 deletions Tests/PureduxTests/SideEffectsTests/SideEfectsCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateIsRun_EffectExecuted() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -45,7 +45,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateIsRunMultipleTimes_EachEffectExecutedOnce() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -74,7 +74,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenRestartedMultiple_ThenEachEffectExecutedForEveryRestart() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -105,7 +105,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenEffectIsSkipped_ThenEachEffectCreationIsCalledAgain() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -133,7 +133,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateIsInitial_ThenNoEffectIsCreated() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -164,7 +164,7 @@ final class SideEffectsCollectionTests: XCTestCase {
func test_WhenStateIsSuccess_ThenNoEffectIsCreated() {

let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -193,7 +193,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateIsFailed_ThenNoEffectIsCreated() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -223,7 +223,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateRetryOrFailAndHasAttempts_ThenEachEffectIsReExecuted() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -252,7 +252,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateRetryOrFailAndHasNoAttempts_ThenEachEffectIsExecutedOnce() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down Expand Up @@ -283,7 +283,7 @@ final class SideEffectsCollectionTests: XCTestCase {

func test_WhenStateIsNotRunning_ThenNoEffectIsExecuted() {
let store = StateStore<[Effect.State], Bool>(
initialState: [Effect.State(), Effect.State()],
[Effect.State(), Effect.State()],
reducer: { state, action in
state = state.map {
var effect = $0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SideEfectsEquatableTests: XCTestCase {
let timeout: TimeInterval = 3.0

func test_WhenStateChanged_EffectExecuted() {
let store = StateStore<Int, Int>(initialState: 0, reducer: { state, action in state = action })
let store = StateStore<Int, Int>(0, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")

Expand All @@ -34,7 +34,7 @@ final class SideEfectsEquatableTests: XCTestCase {
}

func test_WhenStateChangedAndEffectSkipped_EffectCreationIsCalledAgain() {
let store = StateStore<Int, Int>(initialState: 0, reducer: { state, action in state = action })
let store = StateStore<Int, Int>(0, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")
asyncExpectation.expectedFulfillmentCount = 3
Expand All @@ -53,7 +53,7 @@ final class SideEfectsEquatableTests: XCTestCase {
}

func test_WhenStateNotChanged_EffectNotExecuted() {
let store = StateStore<Int, Int>(initialState: 0, reducer: { state, action in state = action })
let store = StateStore<Int, Int>(0, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")
asyncExpectation.isInverted = true
Expand All @@ -73,7 +73,7 @@ final class SideEfectsEquatableTests: XCTestCase {
}

func test_WhenStateNotChanged_EffectCreationIsNotCalled() {
let store = StateStore<Int, Int>(initialState: 0, reducer: { state, action in state = action })
let store = StateStore<Int, Int>(0, reducer: { state, action in state = action })

let asyncExpectation = expectation(description: "Effect executed")
asyncExpectation.isInverted = true
Expand Down
22 changes: 11 additions & 11 deletions Tests/PureduxTests/SideEffectsTests/SideEfectsStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SideEfectsStateTests: XCTestCase {
let timeout: TimeInterval = 3.0

func test_WhenStateIsRun_EffectExecuted() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.cancel() })

let asyncExpectation = expectation(description: "Effect executed")
Expand All @@ -34,7 +34,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsRunMultipleTimes_EffectExecutedOnce() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.cancel() })
let asyncExpectation = expectation(description: "Effect executed")

Expand All @@ -54,7 +54,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenRestartedMultiple_EffectExecutedForEveryRestart() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.restart() : state.cancel() })

let asyncExpectation = expectation(description: "Effect executed")
Expand All @@ -77,7 +77,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenEffectIsSkipped_ThenEffectCreationIsCalledAgain() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.restart() : state.cancel() })

let asyncExpectation = expectation(description: "Effect creation executed")
Expand All @@ -97,7 +97,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsInitial_ThenEffectIsNotCreated() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.cancel() })

let asyncExpectation = expectation(description: "Effect creation executed")
Expand All @@ -118,7 +118,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsIdle_ThenEffectIsNotCreated() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.reset() })

let asyncExpectation = expectation(description: "Effect creation executed")
Expand All @@ -139,7 +139,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsSuccess_ThenEffectIsNotCreated() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.succeed() })

let asyncExpectation = expectation(description: "Effect creation executed")
Expand All @@ -160,7 +160,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsFailed_ThenEffectIsNotCreated() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.fail(nil) })

let asyncExpectation = expectation(description: "Effect creation executed")
Expand All @@ -183,7 +183,7 @@ final class SideEfectsStateTests: XCTestCase {

func test_WhenStateRetryOrFailAndHasAttempts_ThenEffectIsReExecuted() {
let store = StateStore<Effect.State, Bool>(
initialState: Effect.State(),
Effect.State(),
reducer: { state, action in
action ?
state.run(maxAttempts: 2)
Expand All @@ -210,7 +210,7 @@ final class SideEfectsStateTests: XCTestCase {

func test_WhenStateRetryOrFailAndHasNoAttempts_ThenEffectIsExecutedOnce() {
let store = StateStore<Effect.State, Bool>(
initialState: Effect.State(),
Effect.State(),
reducer: { state, action in
action ?
state.run(maxAttempts: 1)
Expand All @@ -237,7 +237,7 @@ final class SideEfectsStateTests: XCTestCase {
}

func test_WhenStateIsNotRunning_ThenEffectIsNotExecuted() {
let store = StateStore<Effect.State, Bool>(initialState: Effect.State(),
let store = StateStore<Effect.State, Bool>(Effect.State(),
reducer: { state, action in action ? state.run() : state.cancel() })

let asyncExpectation = expectation(description: "Effect executed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class StorePerformanceTests: XCTestCase {
measure(metrics: [XCTClockMetric(), XCTCPUMetric()]) {

let store = StateStore<Array<Int>, Int>(
initialState: Array(repeating: 0, count: 2000),
Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

Expand All @@ -38,11 +38,11 @@ final class StorePerformanceTests: XCTestCase {
measure(metrics: [XCTClockMetric(), XCTCPUMetric()]) {

let rootStore = StateStore<Array<Int>, Int>(
initialState: Array(repeating: 0, count: 2000),
Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let store = rootStore.appending(Array(repeating: 0, count: 2000),
let store = rootStore.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

Expand Down Expand Up @@ -70,15 +70,15 @@ final class StorePerformanceTests: XCTestCase {
measure(metrics: [XCTClockMetric(), XCTCPUMetric()]) {

let rootStore = StateStore<Array<Int>, Int>(
initialState: Array(repeating: 0, count: 2000),
Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let childOne = rootStore.appending(Array(repeating: 0, count: 2000),
let childOne = rootStore.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let childTwo = childOne.appending(Array(repeating: 0, count: 2000),
let childTwo = childOne.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

Expand Down Expand Up @@ -107,19 +107,19 @@ final class StorePerformanceTests: XCTestCase {
measure(metrics: [XCTClockMetric(), XCTCPUMetric()]) {

let rootStore = StateStore<Array<Int>, Int>(
initialState: Array(repeating: 0, count: 2000),
Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let childOne = rootStore.appending(Array(repeating: 0, count: 2000),
let childOne = rootStore.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let childTwo = childOne.appending(Array(repeating: 0, count: 2000),
let childTwo = childOne.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

let childThree = childTwo.appending(Array(repeating: 0, count: 2000),
let childThree = childTwo.stateStore(Array(repeating: 0, count: 2000),
reducer: { state, action in state = state.map { $0 + action } }
)

Expand Down

0 comments on commit afc47f9

Please sign in to comment.