Skip to content
9 changes: 9 additions & 0 deletions .github/workflows/sessions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ jobs:
- os: macos-14
xcode: Xcode_15.3
tests:
swift_version: 5.9
# Flaky tests on CI
- os: macos-15
xcode: Xcode_16.2
tests: --skip-tests
swift_version: 5.9
# Flaky tests on CI
- os: macos-15
xcode: Xcode_16.2
tests: --skip-tests
swift_version: 6.0
runs-on: ${{ matrix.build-env.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -40,6 +47,8 @@ jobs:
run: scripts/setup_bundler.sh
- name: Xcode
run: sudo xcode-select -s /Applications/${{ matrix.build-env.xcode }}.app/Contents/Developer
- name: Set Swift swift_version
run: sed -i "" "s/s.swift_version[[:space:]]*=[[:space:]]*'5.9'/s.swift_version = '${{ matrix.build-env.swift_version }}'/" FirebaseSessions.podspec
- uses: nick-fields/retry@v3
with:
timeout_minutes: 120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
// We wanted to make sure that since we've introduced promises,
// once the promise has been fulfilled, that .then'ing on the promise
// in future initiations still results in a log
func test_multipleInitiations_logsSessionEventEachInitiation() {
@MainActor func test_multipleInitiations_logsSessionEventEachInitiation() {
var loggedCount = 0
var lastLoggedSessionID = ""
let loggedTwiceExpectation = expectation(description: "Sessions SDK logged events twice")
Expand Down Expand Up @@ -138,10 +138,10 @@
}
)

wait(for: [loggedTwiceExpectation], timeout: 3)

Check failure on line 141 in FirebaseSessions/Tests/Unit/FirebaseSessionsTests+BaseBehaviors.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS)

test_multipleInitiations_logsSessionEventEachInitiation, Asynchronous wait failed: Exceeded timeout of 3 seconds, with unfulfilled expectations: "Sessions SDK logged events twice".

// Make sure we logged 2 events
XCTAssertEqual(loggedCount, 2)

Check failure on line 144 in FirebaseSessions/Tests/Unit/FirebaseSessionsTests+BaseBehaviors.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_15.4, iOS)

test_multipleInitiations_logsSessionEventEachInitiation, XCTAssertEqual failed: ("0") is not equal to ("2")
}

#endif // !os(watchOS)
Expand Down
2 changes: 1 addition & 1 deletion FirebaseSessions/Tests/Unit/InitiatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class InitiatorTests: XCTestCase {
XCTAssert(initiateCalled)
}

func test_appForegrounded_initiatesNewSession() throws {
@MainActor func test_appForegrounded_initiatesNewSession() throws {
// Given
var pausedClock = date
let initiator = SessionInitiator(
Expand Down
26 changes: 2 additions & 24 deletions FirebaseSessions/Tests/Unit/Library/LifecycleNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ import Dispatch
#endif // swift(>=5.9)

extension XCTestCase {
func postBackgroundedNotification() {
// On Catalyst, the notifications can only be called on a the main thread
if Thread.isMainThread {
postBackgroundedNotificationInternal()
} else {
DispatchQueue.main.sync {
self.postBackgroundedNotificationInternal()
}
}
}

private func postBackgroundedNotificationInternal() {
@MainActor func postBackgroundedNotification() {
let notificationCenter = NotificationCenter.default
#if os(iOS) || os(tvOS)
notificationCenter.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
Expand All @@ -74,18 +63,7 @@ extension XCTestCase {
#endif // swift(>=5.9)
}

func postForegroundedNotification() {
// On Catalyst, the notifications can only be called on a the main thread
if Thread.isMainThread {
postForegroundedNotificationInternal()
} else {
DispatchQueue.main.sync {
self.postForegroundedNotificationInternal()
}
}
}

private func postForegroundedNotificationInternal() {
@MainActor func postForegroundedNotification() {
let notificationCenter = NotificationCenter.default
#if os(iOS) || os(tvOS)
notificationCenter.post(name: UIApplication.didBecomeActiveNotification, object: nil)
Expand Down
Loading