Skip to content

Commit e3ab72d

Browse files
authored
conditionally import FoundationEssentials (#36)
* conditionally import FoundationEssentials * add swift rules for amazon q * do not use CharacterSet * swift format * [CI] separate build and test
1 parent bc5a47f commit e3ab72d

File tree

80 files changed

+371
-10
lines changed

Some content is hidden

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

80 files changed

+371
-10
lines changed

.amazonq/rules/swift.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ struct AddingTwoNumbersTests {
6363

6464
}
6565
```
66-
When asked to write unit tests, always prefer the new Swift testing framework over XCTest.
66+
67+
Always use standard Swift 6 tools by preference. For example,
68+
when asked to write unit tests, always prefer the new Swift testing framework over XCTest.
69+
When asked to format files, use swift format instead of swift-format.
6770

6871
In general, prefer the use of Swift Concurrency (async/await,
6972
actors, etc.) over tools like Dispatch or Combine, but if the

.github/workflows/pull_request.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ jobs:
88
steps:
99
- name: Checkout repository
1010
uses: actions/checkout@v4
11-
- name: Run tests
11+
- name: Build
12+
run: swift build --configuration release
13+
- name: Tests
1214
run: swift test
1315

1416
soundness:

Sources/BedrockModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
//
1414
//===----------------------------------------------------------------------===//
1515

16+
#if canImport(FoundationEssentials)
17+
import FoundationEssentials
18+
#else
1619
import Foundation
20+
#endif
1721

1822
public struct BedrockModel: Hashable, Sendable, Equatable, RawRepresentable {
1923
public var rawValue: String { id }

Sources/BedrockService.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
@preconcurrency import AWSBedrockRuntime
1818
import AWSClientRuntime
1919
import AwsCommonRuntimeKit
20-
import Foundation
2120
import Logging
2221

22+
#if canImport(FoundationEssentials)
23+
import FoundationEssentials
24+
#else
25+
import Foundation
26+
#endif
27+
2328
// for setenv and unsetenv functions
2429
#if os(Linux)
2530
import Glibc

Sources/BedrockServiceError.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
//
1414
//===----------------------------------------------------------------------===//
1515

16+
#if canImport(FoundationEssentials)
17+
import FoundationEssentials
18+
#else
1619
import Foundation
20+
#endif
1721

1822
//TODO: split in two structs : BedrockModelError and BedrockLibraryError
1923
public enum BedrockLibraryError: Error {

Sources/Converse/BedrockService+Converse.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
@preconcurrency import AWSBedrockRuntime
1717
import AwsCommonRuntimeKit
18+
19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
1822
import Foundation
23+
#endif
1924

2025
extension BedrockService {
2126

Sources/Converse/BedrockService+ConverseStreaming.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
@preconcurrency import AWSBedrockRuntime
1717
import AwsCommonRuntimeKit
18+
19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
1822
import Foundation
23+
#endif
1924

2025
extension BedrockService {
2126

Sources/Converse/ContentBlocks/Content.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
@preconcurrency import AWSBedrockRuntime
17+
18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
1721
import Foundation
22+
#endif
1823

1924
public enum Content: Codable, CustomStringConvertible, Sendable {
2025
case text(String)

Sources/Converse/ContentBlocks/DocumentBlock.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
@preconcurrency import AWSBedrockRuntime
17+
18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
1721
import Foundation
22+
#endif
1823

1924
public struct DocumentBlock: Codable, Sendable {
2025
public let name: String

Sources/Converse/ContentBlocks/DocumentToJSON.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
//
1414
//===----------------------------------------------------------------------===//
1515

16-
import Foundation
1716
import Smithy
1817

18+
#if canImport(FoundationEssentials)
19+
import FoundationEssentials
20+
#else
21+
import Foundation
22+
#endif
23+
1924
// FIXME: avoid extensions on structs you do not control
2025
extension SmithyDocument {
2126
public func toJSON() throws -> JSON {

0 commit comments

Comments
 (0)