Skip to content

Commit d66cf1a

Browse files
author
Di Wu
authored
ci: upgrade runner version to use latest xcode (#2964)
1 parent 0293c5c commit d66cf1a

File tree

9 files changed

+58
-47
lines changed

9 files changed

+58
-47
lines changed

.github/composite_actions/run_xcodebuild_test/action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
project_path:
99
required: false
1010
type: string
11+
xcode_path:
12+
required: false
13+
type: string
1114
destination:
1215
required: false
1316
type: string
@@ -28,7 +31,12 @@ runs:
2831
env:
2932
SCHEME: ${{ inputs.scheme }}
3033
PROJECT_PATH: ${{ inputs.project_path }}
34+
XCODE_PATH: ${{ inputs.xcode_path }}
3135
run: |
3236
cd $PROJECT_PATH
33-
xcodebuild test -scheme $SCHEME -sdk '${{ inputs.sdk }}' -destination '${{ inputs.destination }}' ${{ inputs.other_flags }} | xcpretty --simple --color --report junit && exit ${PIPESTATUS[0]}
34-
shell: bash
37+
if [ ! -z "$XCODE_PATH" ]; then
38+
sudo xcode-select -s $XCODE_PATH
39+
fi
40+
xcodebuild -version
41+
xcodebuild test -scheme $SCHEME -sdk '${{ inputs.sdk }}' -destination '${{ inputs.destination }}' ${{ inputs.other_flags }} | xcpretty --simple --color --report junit && exit ${PIPESTATUS[0]}
42+
shell: bash

.github/workflows/integ_test_datastore.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66

77
permissions:
88
id-token: write
9-
contents: read
9+
contents: read
1010

1111
concurrency:
1212
group: ${{ github.head_ref || github.run_id }}
1313
cancel-in-progress: true
1414

1515
jobs:
1616
prepare-for-test:
17-
runs-on: macos-12
17+
runs-on: macos-13
1818
environment: IntegrationTest
1919
steps:
2020
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
@@ -32,7 +32,7 @@ jobs:
3232
datastore-integration-test:
3333
timeout-minutes: 30
3434
needs: prepare-for-test
35-
runs-on: macos-12
35+
runs-on: macos-13
3636
environment: IntegrationTest
3737
steps:
3838
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
@@ -55,5 +55,7 @@ jobs:
5555
with:
5656
project_path: ./AmplifyPlugins/DataStore/Tests/DataStoreHostApp
5757
scheme: AWSDataStorePluginIntegrationTests
58+
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
59+
xcode_path: '/Applications/Xcode_14.3.app'
60+
5861

59-

.github/workflows/integ_test_datastore_v2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
permissions:
88
id-token: write
9-
contents: read
9+
contents: read
1010

1111
concurrency:
1212
group: ${{ github.head_ref || github.run_id }}
@@ -56,4 +56,4 @@ jobs:
5656
project_path: ./AmplifyPlugins/DataStore/Tests/DataStoreHostApp
5757
scheme: AWSDataStorePluginV2Tests
5858

59-
59+

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario2Tests.swift

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
4646
try await startAmplifyAndWaitForSync()
4747
let team = Team2(name: "name1")
4848
let project = Project2(teamID: team.id, team: team)
49-
let syncedTeamReceived = asyncExpectation(description: "received team from sync event")
50-
let syncProjectReceived = asyncExpectation(description: "received project from sync event")
49+
let syncedTeamReceived = expectation(description: "received team from sync event")
50+
let syncProjectReceived = expectation(description: "received project from sync event")
5151
let hubListener = Amplify.Hub.listen(to: .dataStore,
5252
eventName: HubPayload.EventName.DataStore.syncReceived) { payload in
5353
guard let mutationEvent = payload.data as? MutationEvent else {
@@ -57,16 +57,10 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
5757

5858
if let syncedTeam = try? mutationEvent.decodeModel() as? Team2,
5959
syncedTeam == team {
60-
Task {
61-
await syncedTeamReceived.fulfill()
62-
}
63-
60+
syncedTeamReceived.fulfill()
6461
} else if let syncedProject = try? mutationEvent.decodeModel() as? Project2,
6562
syncedProject == project {
66-
Task {
67-
await syncProjectReceived.fulfill()
68-
}
69-
63+
syncProjectReceived.fulfill()
7064
}
7165
}
7266
guard try await HubListenerTestUtilities.waitForListener(with: hubListener, timeout: 5.0) else {
@@ -75,11 +69,11 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
7569
}
7670

7771
_ = try await Amplify.DataStore.save(team)
78-
await waitForExpectations([syncedTeamReceived], timeout: networkTimeout)
72+
await fulfillment(of: [syncedTeamReceived], timeout: networkTimeout)
7973

8074
_ = try await Amplify.DataStore.save(project)
8175

82-
await waitForExpectations([syncProjectReceived], timeout: networkTimeout)
76+
await fulfillment(of: [syncProjectReceived], timeout: networkTimeout)
8377

8478
let queriedProject = try await Amplify.DataStore.query(Project2.self, byId: project.id)
8579
XCTAssertEqual(queriedProject, project)
@@ -131,13 +125,13 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
131125
func testDeleteAndGetProjectReturnsNilWithSync() async throws {
132126
await setUp(withModels: TestModelRegistration())
133127
try await startAmplifyAndWaitForSync()
134-
let team = try await saveTeam(name: "name")
135-
let project = try await saveProject(teamID: team.id, team: team)
128+
let team = Team2(id: UUID().uuidString, name: UUID().uuidString)
129+
let project = Project2(id: UUID().uuidString, name: UUID().uuidString, teamID: team.id, team: team)
136130

137-
let createReceived = asyncExpectation(description: "received created items from cloud",
138-
expectedFulfillmentCount: 2) // 1 project and 1 team
139-
let deleteReceived = asyncExpectation(description: "Delete notification received",
140-
expectedFulfillmentCount: 2) // 1 project and 1 team
131+
let createReceived = expectation(description: "received created items from cloud")
132+
createReceived.expectedFulfillmentCount = 2 // 1 project and 1 team
133+
let deleteReceived = expectation(description: "Delete notification received")
134+
deleteReceived.expectedFulfillmentCount = 2 // 1 project and 1 team
141135
let hubListener = Amplify.Hub.listen(to: .dataStore,
142136
eventName: HubPayload.EventName.DataStore.syncReceived) { payload in
143137
guard let mutationEvent = payload.data as? MutationEvent else {
@@ -149,17 +143,17 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
149143
projectEvent.id == project.id {
150144
if mutationEvent.mutationType == GraphQLMutationType.create.rawValue {
151145
XCTAssertEqual(mutationEvent.version, 1)
152-
Task { await createReceived.fulfill() }
146+
createReceived.fulfill()
153147
} else if mutationEvent.mutationType == GraphQLMutationType.delete.rawValue {
154-
Task { await deleteReceived.fulfill() }
148+
deleteReceived.fulfill()
155149
}
156150

157151
} else if let teamEvent = try? mutationEvent.decodeModel() as? Team2, teamEvent.id == team.id {
158152
if mutationEvent.mutationType == GraphQLMutationType.create.rawValue {
159153
XCTAssertEqual(mutationEvent.version, 1)
160-
Task { await createReceived.fulfill() }
154+
createReceived.fulfill()
161155
} else if mutationEvent.mutationType == GraphQLMutationType.delete.rawValue {
162-
Task { await deleteReceived.fulfill() }
156+
deleteReceived.fulfill()
163157
}
164158
}
165159

@@ -168,14 +162,16 @@ class DataStoreConnectionScenario2Tests: SyncEngineIntegrationTestBase {
168162
XCTFail("Listener not registered for hub")
169163
return
170164
}
171-
await waitForExpectations([createReceived], timeout: TestCommonConstants.networkTimeout)
165+
try await Amplify.DataStore.save(team)
166+
try await Amplify.DataStore.save(project)
167+
await fulfillment(of: [createReceived], timeout: TestCommonConstants.networkTimeout)
172168

173169
try await Amplify.DataStore.delete(project)
174170

175171
// TODO: Delete Team should not be necessary, cascade delete should delete the team when deleting the project.
176172
// Once cascade works for hasOne, the following code can be removed.
177173
try await Amplify.DataStore.delete(team)
178-
await waitForExpectations([deleteReceived], timeout: TestCommonConstants.networkTimeout)
174+
await fulfillment(of: [deleteReceived], timeout: TestCommonConstants.networkTimeout)
179175
let project2 = try await Amplify.DataStore.query(Project2.self, byId: project.id)
180176
XCTAssertNil(project2)
181177
}

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/Connection/DataStoreConnectionScenario3Tests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class DataStoreConnectionScenario3Tests: SyncEngineIntegrationTestBase {
4646
try await startAmplifyAndWaitForSync()
4747
let post = Post3(title: "title")
4848
let comment = Comment3(postID: post.id, content: "content")
49-
let syncedPostReceived = asyncExpectation(description: "received post from sync event")
50-
let syncCommentReceived = asyncExpectation(description: "received comment from sync event")
49+
let syncedPostReceived = expectation(description: "received post from sync event")
50+
let syncCommentReceived = expectation(description: "received comment from sync event")
5151
let hubListener = Amplify.Hub.listen(to: .dataStore,
5252
eventName: HubPayload.EventName.DataStore.syncReceived) { payload in
5353
guard let mutationEvent = payload.data as? MutationEvent else {
@@ -57,20 +57,20 @@ class DataStoreConnectionScenario3Tests: SyncEngineIntegrationTestBase {
5757

5858
if let syncedPost = try? mutationEvent.decodeModel() as? Post3,
5959
syncedPost == post {
60-
Task { await syncedPostReceived.fulfill() }
60+
syncedPostReceived.fulfill()
6161
} else if let syncComment = try? mutationEvent.decodeModel() as? Comment3,
6262
syncComment == comment {
63-
Task { await syncCommentReceived.fulfill() }
63+
syncCommentReceived.fulfill()
6464
}
6565
}
6666
guard try await HubListenerTestUtilities.waitForListener(with: hubListener, timeout: 5.0) else {
6767
XCTFail("Listener not registered for hub")
6868
return
6969
}
7070
_ = try await Amplify.DataStore.save(post)
71-
await waitForExpectations([syncedPostReceived], timeout: networkTimeout)
71+
await fulfillment(of: [syncedPostReceived], timeout: networkTimeout)
7272
_ = try await Amplify.DataStore.save(comment)
73-
await waitForExpectations([syncCommentReceived], timeout: networkTimeout)
73+
await fulfillment(of: [syncCommentReceived], timeout: networkTimeout)
7474

7575
let queriedComment = try await Amplify.DataStore.query(Comment3.self, byId: comment.id)
7676
XCTAssertEqual(queriedComment, comment)

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreConsecutiveUpdatesTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ class DataStoreConsecutiveUpdatesTests: SyncEngineIntegrationTestBase {
156156
// query the deleted post immediately
157157
let queryResult = try await queryPost(byId: newPost.id)
158158
XCTAssertNil(queryResult)
159-
160-
await waitForExpectations(timeout: networkTimeout)
159+
await fulfillment(of: [deleteSyncReceived], timeout: networkTimeout)
161160

162161
// query the deleted post in eventual consistent state
163162
let queryResultAfterSync = try await queryPost(byId: newPost.id)

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreEndToEndTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class DataStoreEndToEndTests: SyncEngineIntegrationTestBase {
147147
}
148148

149149
_ = try await Amplify.DataStore.save(newPost)
150-
await waitForExpectations(timeout: networkTimeout)
150+
await fulfillment(of: [createReceived], timeout: networkTimeout)
151151

152152
let updateReceived = expectation(description: "Update notification received")
153153
hubListener = Amplify.Hub.listen(
@@ -177,7 +177,7 @@ class DataStoreEndToEndTests: SyncEngineIntegrationTestBase {
177177
return
178178
}
179179
_ = try await Amplify.DataStore.save(updatedPost)
180-
await waitForExpectations(timeout: networkTimeout)
180+
await fulfillment(of: [updateReceived], timeout: networkTimeout)
181181

182182
let deleteReceived = expectation(description: "Delete notification received")
183183
hubListener = Amplify.Hub.listen(
@@ -207,7 +207,7 @@ class DataStoreEndToEndTests: SyncEngineIntegrationTestBase {
207207
return
208208
}
209209
try await Amplify.DataStore.delete(updatedPost)
210-
await waitForExpectations(timeout: networkTimeout)
210+
await fulfillment(of: [deleteReceived], timeout: networkTimeout)
211211
}
212212

213213
/// - Given: A post that has been saved

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreHubEventsTests.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ class DataStoreHubEventTests: HubEventsIntegrationTestBase {
8282

8383
await startAmplify(withModels: TestModelRegistration())
8484

85-
await waitForExpectations(timeout: networkTimeout)
85+
await fulfillment(of: [
86+
networkStatusReceived,
87+
subscriptionsEstablishedReceived,
88+
syncQueriesStartedReceived,
89+
outboxStatusReceived
90+
], timeout: networkTimeout)
91+
8692
hubListener.cancel()
8793
}
8894

@@ -134,7 +140,7 @@ class DataStoreHubEventTests: HubEventsIntegrationTestBase {
134140
await startAmplify(withModels: TestModelRegistration())
135141
_ = try await Amplify.DataStore.save(post)
136142

137-
await waitForExpectations(timeout: networkTimeout)
143+
await fulfillment(of: [outboxMutationEnqueuedReceived, outboxMutationProcessedReceived], timeout: networkTimeout)
138144
hubListener.cancel()
139145
}
140146

@@ -179,7 +185,7 @@ class DataStoreHubEventTests: HubEventsIntegrationTestBase {
179185

180186
await startAmplify(withModels: TestModelRegistration())
181187

182-
await waitForExpectations(timeout: networkTimeout)
188+
await fulfillment(of: [modelSyncedReceived, syncQueriesReadyReceived], timeout: networkTimeout)
183189
hubListener.cancel()
184190
}
185191
}

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/TestSupport/SyncEngineIntegrationTestBase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class SyncEngineIntegrationTestBase: DataStoreTestBase {
112112
}
113113

114114
try await Amplify.DataStore.start()
115-
await waitForExpectations(timeout: 10.0)
115+
await fulfillment(of: [eventReceived], timeout: 10)
116116

117117
try await deleteMutationEvents()
118118
}

0 commit comments

Comments
 (0)