Skip to content

Commit 4662460

Browse files
authored
chore: kickoff release
2 parents 74de7b9 + 7873d56 commit 4662460

File tree

46 files changed

+2018
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2018
-285
lines changed

.circleci/config.yml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parameters:
1111
default: platform=macOS,arch=x86_64
1212

1313
orbs:
14+
aws-cli: circleci/[email protected]
1415
# Using inline orb for now
1516
getting-started-smoke-test:
1617
orbs:
@@ -236,6 +237,47 @@ jobs:
236237
name: Release Amplify for Swift
237238
command: bundle exec fastlane << parameters.lane >>
238239
no_output_timeout: 60m
240+
241+
fortify_scan:
242+
<<: *defaults
243+
steps:
244+
- *restore_repo
245+
- run:
246+
name: Make source directory
247+
command: |
248+
mkdir source
249+
cp -r Amplify source
250+
cp -r AmplifyPlugins source
251+
- aws-cli/setup:
252+
role-arn: 'arn:aws:iam::971028514469:role/CircleCiOIDC'
253+
role-session-name: 'aws-s3-session'
254+
- run:
255+
name: Download License
256+
command: |
257+
aws s3 cp s3://amplify-swift-fortify-prod/fortify.license fortify.license
258+
- run:
259+
name: Download Installer
260+
command: |
261+
aws s3 cp s3://amplify-swift-fortify-prod/Fortify_SCA_and_Apps_22.1.1_Mac.tar.gz Fortify_SCA_and_Apps_22.1.1_Mac.tar.gz
262+
tar -xvf Fortify_SCA_and_Apps_22.1.1_Mac.tar.gz
263+
unzip Fortify_SCA_and_Apps_22.1.1_osx_x64.app.zip
264+
- run:
265+
name: Download Scripts
266+
command: |
267+
aws s3 cp s3://amplify-swift-fortify-prod/amplify_swift_fortify_scan.sh fortify_scan.sh
268+
- run:
269+
name: Run Installer
270+
command: |
271+
Fortify_SCA_and_Apps_22.1.1_osx_x64.app/Contents/MacOS/installbuilder.sh --mode unattended --installdir Fortify --InstallSamples 0 --fortify_license_path fortify.license --MigrateSCA 0
272+
export PATH=~/amplify-swift/Fortify/bin:$PATH
273+
echo "export PATH=~/amplify-swift/Fortify/bin:\$PATH" >> "$BASH_ENV"
274+
fortifyupdate -acceptKey
275+
sourceanalyzer -version
276+
- run:
277+
name: Run Scan
278+
command: |
279+
sh ./fortify_scan.sh source
280+
239281
240282
deploy_requires: &deploy_requires
241283
requires:
@@ -257,6 +299,7 @@ deploy_requires: &deploy_requires
257299
- macos_unit_test_datastore
258300
- macos_unit_test_geo
259301
- macos_unit_test_storage
302+
- fortify_scan
260303

261304
workflows:
262305
build_test_deploy:
@@ -268,12 +311,17 @@ workflows:
268311
- install_gems:
269312
requires:
270313
- checkout_code
271-
- build_amplify_ios_spm:
314+
- fortify_scan:
315+
context:
316+
- amplify-swift-aws-s3-download
272317
requires:
273318
- install_gems
319+
- build_amplify_ios_spm:
320+
requires:
321+
- fortify_scan
274322
- build_amplify_macos_spm:
275323
requires:
276-
- install_gems
324+
- fortify_scan
277325
- unit_test:
278326
name: ios_unit_test_amplify
279327
scheme: Amplify
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
9+
import Foundation
10+
11+
extension Optional {
12+
///
13+
/// Performing side effect function when data is exist
14+
/// - parameters:
15+
/// - then: a closure that takes wrapped data as a parameter
16+
@_spi(OptionalExtension)
17+
public func ifSome(_ then: (Wrapped) throws -> Void) rethrows {
18+
if case .some(let wrapped) = self {
19+
try then(wrapped)
20+
}
21+
}
22+
}

AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLConnectionScenario2Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class GraphQLConnectionScenario2Tests: XCTestCase {
4949

5050
override func tearDown() async throws {
5151
await Amplify.reset()
52+
try await Task.sleep(seconds: 1)
5253
}
5354

5455
// Create Project2 in different ways, then retrieve it

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLConnectionScenario3Tests+List.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,18 @@ extension GraphQLConnectionScenario3Tests {
159159
XCTFail("Could not create comment")
160160
return
161161
}
162+
162163
let predicate = Comment3.keys.postID.eq(post.id)
163-
let result = try await Amplify.API.query(request: .list(Comment3.self, where: predicate))
164-
switch result {
165-
case .success(let comments):
166-
XCTAssertEqual(comments.count, 1)
167-
case .failure(let response):
168-
XCTFail("Failed with: \(response)")
164+
guard case .success(var comments) = try await Amplify.API.query(request: .list(Comment3.self, where: predicate))
165+
else {
166+
XCTFail("Failed to retrieve comments")
167+
return
168+
}
169+
170+
while comments.count == 0 && comments.hasNextPage() {
171+
comments = try await comments.getNextPage()
169172
}
173+
XCTAssertEqual(comments.count, 1)
170174
}
171175

172176
/// Test paginated list query returns a List containing pagination functionality. This test also aggregates page

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLConnectionScenario3Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class GraphQLConnectionScenario3Tests: XCTestCase {
4949

5050
override func tearDown() async throws {
5151
await Amplify.reset()
52+
try await Task.sleep(seconds: 1)
5253
}
5354

5455
func testQuerySinglePost() async throws {

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginLazyLoadTests/GraphQLLazyLoadBaseTest.swift

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class GraphQLLazyLoadBaseTest: XCTestCase {
2121

2222
override func tearDown() async throws {
2323
await Amplify.reset()
24+
try await Task.sleep(seconds: 1)
2425
}
2526

2627
func setupConfig() {
@@ -185,10 +186,66 @@ class GraphQLLazyLoadBaseTest: XCTestCase {
185186
decodePath: document.name)
186187
return try await query(request)
187188
}
189+
190+
func subscribe<M: Model>(
191+
of modelType: M.Type,
192+
type: GraphQLSubscriptionType,
193+
verifyChange: @escaping (M) async throws -> Bool
194+
) async throws -> (AsyncExpectation, AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<M>>) {
195+
let connected = asyncExpectation(description: "Subscription connected")
196+
let eventReceived = asyncExpectation(description: "\(type.rawValue) received")
197+
let subscription = Amplify.API.subscribe(request: .subscription(of: modelType, type: type))
198+
199+
Task {
200+
for try await subscriptionEvent in subscription {
201+
if subscriptionEvent.isConnected() {
202+
await connected.fulfill()
203+
}
204+
205+
if let error = subscriptionEvent.extractError() {
206+
XCTFail("Failed to \(type.rawValue) \(modelType), error: \(error.errorDescription)")
207+
}
208+
209+
if let data = subscriptionEvent.extractData(),
210+
try await verifyChange(data)
211+
{
212+
await eventReceived.fulfill()
213+
}
214+
}
215+
}
216+
217+
await waitForExpectations([connected], timeout: 10)
218+
return (eventReceived, subscription)
219+
}
188220
}
189221

190222
extension LazyReferenceIdentifier: Equatable {
191223
public static func == (lhs: LazyReferenceIdentifier, rhs: LazyReferenceIdentifier) -> Bool {
192224
return lhs.name == rhs.name && lhs.value == rhs.value
193225
}
194226
}
227+
228+
229+
extension GraphQLSubscriptionEvent {
230+
func isConnected() -> Bool {
231+
if case .connection(.connected) = self {
232+
return true
233+
}
234+
return false
235+
}
236+
237+
func extractData() -> T? {
238+
if case .data(.success(let data)) = self {
239+
return data
240+
}
241+
return nil
242+
}
243+
244+
func extractError() -> GraphQLResponseError<T>? {
245+
if case .data(.failure(let error)) = self {
246+
return error
247+
}
248+
return nil
249+
}
250+
251+
}

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginLazyLoadTests/LL1/GraphQLLazyLoadPostComment4V2Tests.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ final class GraphQLLazyLoadPostComment4V2Tests: GraphQLLazyLoadBaseTest {
1919
await setup(withModels: PostComment4V2Models())
2020
let post = Post(title: "title")
2121
let comment = Comment(content: "content", post: post)
22-
let createdPost = try await mutate(.create(post))
23-
let createdComment = try await mutate(.create(comment))
22+
try await mutate(.create(post))
23+
try await mutate(.create(comment))
2424
}
2525

2626
// Without `includes` and latest codegenerated types with the model path, the post should be lazy loaded
@@ -117,7 +117,16 @@ final class GraphQLLazyLoadPostComment4V2Tests: GraphQLLazyLoadBaseTest {
117117
assertLazyReference(comments.first!._post, state: .notLoaded(identifiers: [.init(name: "id", value: post.identifier)]))
118118
}
119119

120-
// This looks broken
120+
121+
/*
122+
- Given: Api plugin is cleared
123+
- When:
124+
- Initialize with PostComment4V2Models
125+
- Create post
126+
- Create comment with [comment.post.comments.post] association path
127+
- Then:
128+
- The comment creation request GraphQL Selection Set represents the assocation path
129+
*/
121130
func testCommentWithEagerLoadPostAndPostCommentsAndPostCommentsPost() async throws {
122131
await setup(withModels: PostComment4V2Models())
123132
let post = Post(title: "title")
@@ -145,25 +154,21 @@ final class GraphQLLazyLoadPostComment4V2Tests: GraphQLLazyLoadBaseTest {
145154
updatedAt
146155
post {
147156
id
157+
createdAt
158+
title
159+
updatedAt
148160
__typename
149161
}
150162
__typename
151163
}
152164
}
153-
post {
154-
id
155-
createdAt
156-
title
157-
updatedAt
158-
__typename
159-
}
160165
}
161166
__typename
162167
}
163168
}
164169
"""
165170
XCTAssertEqual(request.document, expectedDocument)
166-
let createdComment = try await mutate(request)
171+
try await mutate(request)
167172
}
168173

169174
// Without `includes` and latest codegenerated types with the model path, the post's comments should be lazy loaded

0 commit comments

Comments
 (0)