From 0e22c242e864b5281bf93e8b102fc98e31933d6e Mon Sep 17 00:00:00 2001 From: Kevin Hermawan <84965338+kevinhermawan@users.noreply.github.com> Date: Sat, 9 Mar 2024 19:41:19 +0700 Subject: [PATCH 1/2] chore: setup SwiftLint --- .github/workflows/code-quality.yml | 8 +- .swiftlint.yml | 4 + Package.resolved | 81 +++++++++++++++++++ Package.swift | 16 ++-- Sources/OllamaKit/OllamaKit+CopyModel.swift | 2 +- Sources/OllamaKit/OllamaKit+DeleteModel.swift | 2 +- .../OKGenerateEmbeddingsRequestData.swift | 2 +- 7 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 .swiftlint.yml diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 863c13d..0031a44 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -10,19 +10,19 @@ on: jobs: test-ios: - runs-on: macos-13 + runs-on: macos-14-arm64 steps: - uses: actions/checkout@v3 - name: Build and test - run: xcodebuild test -scheme OllamaKit -destination 'platform=iOS Simulator,name=iPhone 14 Pro' + run: xcodebuild test -scheme OllamaKit -destination 'platform=iOS Simulator,name=iPhone 15 Pro' test-macos: - runs-on: macos-13 + runs-on: macos-14-arm64 steps: - uses: actions/checkout@v3 - name: Build and test - run: xcodebuild test -scheme OllamaKit -destination 'platform=macOS,arch=x86_64' + run: xcodebuild test -scheme OllamaKit -destination 'platform=macOS,arch=arm64' diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..0c6bb5f --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,4 @@ +disabled_rules: + - line_length + - nesting + - trailing_whitespace diff --git a/Package.resolved b/Package.resolved index b5b6729..fa8cbb3 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,6 +9,42 @@ "version" : "5.8.1" } }, + { + "identity" : "collectionconcurrencykit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git", + "state" : { + "revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95", + "version" : "0.2.0" + } + }, + { + "identity" : "cryptoswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/krzyzanowskim/CryptoSwift.git", + "state" : { + "revision" : "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c", + "version" : "1.8.1" + } + }, + { + "identity" : "sourcekitten", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jpsim/SourceKitten.git", + "state" : { + "revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56", + "version" : "0.34.1" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531", + "version" : "1.2.3" + } + }, { "identity" : "swift-docc-plugin", "kind" : "remoteSourceControl", @@ -26,6 +62,51 @@ "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", "version" : "1.0.0" } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-syntax.git", + "state" : { + "revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036", + "version" : "509.0.2" + } + }, + { + "identity" : "swiftlint", + "kind" : "remoteSourceControl", + "location" : "https://github.com/realm/SwiftLint", + "state" : { + "revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee", + "version" : "0.54.0" + } + }, + { + "identity" : "swiftytexttable", + "kind" : "remoteSourceControl", + "location" : "https://github.com/scottrhoyt/SwiftyTextTable.git", + "state" : { + "revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3", + "version" : "0.9.0" + } + }, + { + "identity" : "swxmlhash", + "kind" : "remoteSourceControl", + "location" : "https://github.com/drmohundro/SWXMLHash.git", + "state" : { + "revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f", + "version" : "7.0.2" + } + }, + { + "identity" : "yams", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jpsim/Yams.git", + "state" : { + "revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3", + "version" : "5.0.6" + } } ], "version" : 2 diff --git a/Package.swift b/Package.swift index 85d91b0..1067aea 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -7,8 +7,7 @@ let package = Package( name: "OllamaKit", platforms: [ .iOS(.v13), - .macOS(.v11), - .macCatalyst(.v13) + .macOS(.v12) ], products: [ .library( @@ -17,12 +16,19 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.8.1")), - .package(url: "https://github.com/apple/swift-docc-plugin.git", .upToNextMajor(from: "1.3.0")) + .package(url: "https://github.com/apple/swift-docc-plugin.git", .upToNextMajor(from: "1.3.0")), + .package(url: "https://github.com/realm/SwiftLint.git", .upToNextMajor(from: "0.54.0")) ], targets: [ .target( name: "OllamaKit", - dependencies: ["Alamofire"]), + dependencies: [ + .product(name: "Alamofire", package: "Alamofire") + ], + plugins: [ + .plugin(name: "SwiftLintPlugin", package: "SwiftLint") + ] + ), .testTarget( name: "OllamaKitTests", dependencies: ["OllamaKit", "Alamofire"]), diff --git a/Sources/OllamaKit/OllamaKit+CopyModel.swift b/Sources/OllamaKit/OllamaKit+CopyModel.swift index 0b6d06f..fc23712 100644 --- a/Sources/OllamaKit/OllamaKit+CopyModel.swift +++ b/Sources/OllamaKit/OllamaKit+CopyModel.swift @@ -22,7 +22,7 @@ extension OllamaKit { /// /// - Parameter data: The ``OKCopyModelRequestData`` containing the details needed to copy the model. /// - Throws: An error if the request to copy the model fails. - public func copyModel(data: OKCopyModelRequestData) async throws -> Void { + public func copyModel(data: OKCopyModelRequestData) async throws { let request = AF.request(router.copyModel(data: data)).validate() _ = try await request.serializingData().response.result.get() } diff --git a/Sources/OllamaKit/OllamaKit+DeleteModel.swift b/Sources/OllamaKit/OllamaKit+DeleteModel.swift index 0ed6326..f823ce2 100644 --- a/Sources/OllamaKit/OllamaKit+DeleteModel.swift +++ b/Sources/OllamaKit/OllamaKit+DeleteModel.swift @@ -22,7 +22,7 @@ extension OllamaKit { /// /// - Parameter data: The ``OKDeleteModelRequestData`` containing the details needed to delete the model. /// - Throws: An error if the request to delete the model fails. - public func deleteModel(data: OKDeleteModelRequestData) async throws -> Void { + public func deleteModel(data: OKDeleteModelRequestData) async throws { let request = AF.request(router.deleteModel(data: data)).validate() _ = try await request.serializingData().response.result.get() } diff --git a/Sources/OllamaKit/RequestData/OKGenerateEmbeddingsRequestData.swift b/Sources/OllamaKit/RequestData/OKGenerateEmbeddingsRequestData.swift index b9fc4ee..826ebc6 100644 --- a/Sources/OllamaKit/RequestData/OKGenerateEmbeddingsRequestData.swift +++ b/Sources/OllamaKit/RequestData/OKGenerateEmbeddingsRequestData.swift @@ -19,7 +19,7 @@ public struct OKGenerateEmbeddingsRequestData: Encodable { public var options: OKCompletionOptions? /// Optionally control how long the model will stay loaded into memory following the request (default: 5m) - public var keep_alive: String? + public var keepAlive: String? public init(model: String, prompt: String) { self.model = model From e5bb18c5341738865416436e9a5213b4569ac9a5 Mon Sep 17 00:00:00 2001 From: Kevin Hermawan <84965338+kevinhermawan@users.noreply.github.com> Date: Sat, 9 Mar 2024 20:08:28 +0700 Subject: [PATCH 2/2] change runner image --- .github/workflows/code-quality.yml | 4 ++-- Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 0031a44..c4c1b72 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -10,7 +10,7 @@ on: jobs: test-ios: - runs-on: macos-14-arm64 + runs-on: macos-13-arm64 steps: - uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: run: xcodebuild test -scheme OllamaKit -destination 'platform=iOS Simulator,name=iPhone 15 Pro' test-macos: - runs-on: macos-14-arm64 + runs-on: macos-13-arm64 steps: - uses: actions/checkout@v3 diff --git a/Package.swift b/Package.swift index 1067aea..a61de99 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 5.7 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription