From f7ee5553f0651bc8b11674cf4c9dccb7b6e39652 Mon Sep 17 00:00:00 2001 From: Aron Budinszky Date: Wed, 27 Apr 2022 16:22:21 +0200 Subject: [PATCH 01/13] Add Linux support (#245) * Add FoundationNetworking imports for Linux support. * Remove autoreleasepool. --- Sources/MeiliSearch/Config.swift | 3 +++ Sources/MeiliSearch/Error.swift | 3 +++ Sources/MeiliSearch/Formatter.swift | 3 +++ Sources/MeiliSearch/Request.swift | 5 +++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/MeiliSearch/Config.swift b/Sources/MeiliSearch/Config.swift index dacea539..b040250b 100755 --- a/Sources/MeiliSearch/Config.swift +++ b/Sources/MeiliSearch/Config.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** A `Config` instance represents the config used by MeiliSearch instance. diff --git a/Sources/MeiliSearch/Error.swift b/Sources/MeiliSearch/Error.swift index aa178b34..b7b3a505 100644 --- a/Sources/MeiliSearch/Error.swift +++ b/Sources/MeiliSearch/Error.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Represent all error types in the client. diff --git a/Sources/MeiliSearch/Formatter.swift b/Sources/MeiliSearch/Formatter.swift index 3699224b..b6c732a7 100644 --- a/Sources/MeiliSearch/Formatter.swift +++ b/Sources/MeiliSearch/Formatter.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif extension Formatter { static let iso8601: DateFormatter = { diff --git a/Sources/MeiliSearch/Request.swift b/Sources/MeiliSearch/Request.swift index fcdf280b..5740e666 100755 --- a/Sources/MeiliSearch/Request.swift +++ b/Sources/MeiliSearch/Request.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Protocol that allows custom implementation of the HTTP layer. @@ -68,7 +71,6 @@ public final class Request { param: String? = nil, headers: [String: String] = [:], _ completion: @escaping (Result) -> Void) { - autoreleasepool { var urlString: String = config.url(api: api) if let param: String = param, !param.isEmpty { urlString += param @@ -90,7 +92,6 @@ public final class Request { } task.resume() - } } func post( From 54cff84e6e3cc37d5a883b349114d66e1ce3216d Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Wed, 27 Apr 2022 16:30:16 +0200 Subject: [PATCH 02/13] Add linux import everywhere foundation is imported --- Sources/MeiliSearch/Client.swift | 3 +++ Sources/MeiliSearch/Config.swift | 2 +- Sources/MeiliSearch/Constants.swift | 3 +++ Sources/MeiliSearch/Documents.swift | 3 +++ Sources/MeiliSearch/Dumps.swift | 3 +++ Sources/MeiliSearch/Error.swift | 2 +- Sources/MeiliSearch/Formatter.swift | 2 +- Sources/MeiliSearch/Indexes.swift | 3 +++ Sources/MeiliSearch/Keys.swift | 3 +++ Sources/MeiliSearch/Model/Health.swift | 3 +++ Sources/MeiliSearch/Model/Index.swift | 3 +++ Sources/MeiliSearch/Model/Key.swift | 3 +++ Sources/MeiliSearch/Model/KeyParams.swift | 3 +++ Sources/MeiliSearch/Model/PackageVersion.swift | 3 +++ Sources/MeiliSearch/Model/SearchParameters.swift | 3 +++ Sources/MeiliSearch/Model/SearchResult.swift | 3 +++ Sources/MeiliSearch/Model/Setting.swift | 3 +++ Sources/MeiliSearch/Model/Stat.swift | 3 +++ Sources/MeiliSearch/Model/Task.swift | 3 +++ Sources/MeiliSearch/Model/Version.swift | 3 +++ Sources/MeiliSearch/Model/WaitOptions.swift | 3 +++ Sources/MeiliSearch/Request.swift | 2 +- Sources/MeiliSearch/Search.swift | 3 +++ Sources/MeiliSearch/Settings.swift | 3 +++ Sources/MeiliSearch/Stats.swift | 3 +++ Sources/MeiliSearch/System.swift | 3 +++ Sources/MeiliSearch/Tasks.swift | 3 +++ Tests/MeiliSearchIntegrationTests/DocumentsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/DumpsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/IndexesTests.swift | 4 ++++ Tests/MeiliSearchIntegrationTests/KeysTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/SearchTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/SettingsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/Support/Movie.swift | 3 +++ Tests/MeiliSearchIntegrationTests/TaskTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/Utils.swift | 3 +++ Tests/MeiliSearchUnitTests/DocumentsTests.swift | 3 +++ Tests/MeiliSearchUnitTests/MockURLSession.swift | 3 +++ Tests/MeiliSearchUnitTests/PackageVersionTests.swift | 3 +++ Tests/MeiliSearchUnitTests/Utils.swift | 3 +++ 40 files changed, 113 insertions(+), 4 deletions(-) diff --git a/Sources/MeiliSearch/Client.swift b/Sources/MeiliSearch/Client.swift index 56bcf579..a5df1b93 100755 --- a/Sources/MeiliSearch/Client.swift +++ b/Sources/MeiliSearch/Client.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** A `MeiliSearch` instance represents a Meilisearch client used to easily integrate diff --git a/Sources/MeiliSearch/Config.swift b/Sources/MeiliSearch/Config.swift index b040250b..5dec4234 100755 --- a/Sources/MeiliSearch/Config.swift +++ b/Sources/MeiliSearch/Config.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Constants.swift b/Sources/MeiliSearch/Constants.swift index 5220be37..f1394a59 100644 --- a/Sources/MeiliSearch/Constants.swift +++ b/Sources/MeiliSearch/Constants.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Constants { static let customJSONDecoder: JSONDecoder = { diff --git a/Sources/MeiliSearch/Documents.swift b/Sources/MeiliSearch/Documents.swift index 81baeb0d..dacfe4e8 100755 --- a/Sources/MeiliSearch/Documents.swift +++ b/Sources/MeiliSearch/Documents.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Documents { // MARK: Properties diff --git a/Sources/MeiliSearch/Dumps.swift b/Sources/MeiliSearch/Dumps.swift index 1894a900..41c40798 100644 --- a/Sources/MeiliSearch/Dumps.swift +++ b/Sources/MeiliSearch/Dumps.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** The dumps route allows the creation of database dumps. Dumps are `.tar.gz` files that diff --git a/Sources/MeiliSearch/Error.swift b/Sources/MeiliSearch/Error.swift index b7b3a505..a049e619 100644 --- a/Sources/MeiliSearch/Error.swift +++ b/Sources/MeiliSearch/Error.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Formatter.swift b/Sources/MeiliSearch/Formatter.swift index b6c732a7..1d3ed195 100644 --- a/Sources/MeiliSearch/Formatter.swift +++ b/Sources/MeiliSearch/Formatter.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif extension Formatter { diff --git a/Sources/MeiliSearch/Indexes.swift b/Sources/MeiliSearch/Indexes.swift index 757ffb9a..5bb80a73 100755 --- a/Sources/MeiliSearch/Indexes.swift +++ b/Sources/MeiliSearch/Indexes.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif public struct Indexes { // MARK: Properties diff --git a/Sources/MeiliSearch/Keys.swift b/Sources/MeiliSearch/Keys.swift index e53dd78f..d460f6ed 100644 --- a/Sources/MeiliSearch/Keys.swift +++ b/Sources/MeiliSearch/Keys.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Keys { // MARK: Properties diff --git a/Sources/MeiliSearch/Model/Health.swift b/Sources/MeiliSearch/Model/Health.swift index 9d503301..2fcd2400 100644 --- a/Sources/MeiliSearch/Model/Health.swift +++ b/Sources/MeiliSearch/Model/Health.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Health` instances represent the status of the Meilisearch server. diff --git a/Sources/MeiliSearch/Model/Index.swift b/Sources/MeiliSearch/Model/Index.swift index fe50b27d..193da784 100755 --- a/Sources/MeiliSearch/Model/Index.swift +++ b/Sources/MeiliSearch/Model/Index.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Index` instances is an entity that gathers a set of documents with its own settings. diff --git a/Sources/MeiliSearch/Model/Key.swift b/Sources/MeiliSearch/Model/Key.swift index b05b3773..47e6d7a7 100644 --- a/Sources/MeiliSearch/Model/Key.swift +++ b/Sources/MeiliSearch/Model/Key.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Each key has a given set of permissions on the API routes. diff --git a/Sources/MeiliSearch/Model/KeyParams.swift b/Sources/MeiliSearch/Model/KeyParams.swift index 20b158c0..56613b65 100644 --- a/Sources/MeiliSearch/Model/KeyParams.swift +++ b/Sources/MeiliSearch/Model/KeyParams.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `KeyParams` contains all the parameters to create an API key. diff --git a/Sources/MeiliSearch/Model/PackageVersion.swift b/Sources/MeiliSearch/Model/PackageVersion.swift index ee3bed8e..8b228922 100644 --- a/Sources/MeiliSearch/Model/PackageVersion.swift +++ b/Sources/MeiliSearch/Model/PackageVersion.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif internal struct PackageVersion { /// This is the current version of the meilisearch-swift package diff --git a/Sources/MeiliSearch/Model/SearchParameters.swift b/Sources/MeiliSearch/Model/SearchParameters.swift index d354d4e6..38da79dd 100644 --- a/Sources/MeiliSearch/Model/SearchParameters.swift +++ b/Sources/MeiliSearch/Model/SearchParameters.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `SearchParameters` instances represent query setup for a search request. diff --git a/Sources/MeiliSearch/Model/SearchResult.swift b/Sources/MeiliSearch/Model/SearchResult.swift index 51ecf592..b14b8dca 100644 --- a/Sources/MeiliSearch/Model/SearchResult.swift +++ b/Sources/MeiliSearch/Model/SearchResult.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `SearchResult` instances represent the result of a search. diff --git a/Sources/MeiliSearch/Model/Setting.swift b/Sources/MeiliSearch/Model/Setting.swift index 4f18b4b2..8f52c578 100644 --- a/Sources/MeiliSearch/Model/Setting.swift +++ b/Sources/MeiliSearch/Model/Setting.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Settings object provided byb the user diff --git a/Sources/MeiliSearch/Model/Stat.swift b/Sources/MeiliSearch/Model/Stat.swift index 8bd27707..d82d968a 100644 --- a/Sources/MeiliSearch/Model/Stat.swift +++ b/Sources/MeiliSearch/Model/Stat.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `AllStats` instances represent stat of all Indexes. diff --git a/Sources/MeiliSearch/Model/Task.swift b/Sources/MeiliSearch/Model/Task.swift index 80212bcc..911b0b36 100644 --- a/Sources/MeiliSearch/Model/Task.swift +++ b/Sources/MeiliSearch/Model/Task.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Task` instances represent the current transaction status, use the `uid` value to diff --git a/Sources/MeiliSearch/Model/Version.swift b/Sources/MeiliSearch/Model/Version.swift index 1eb94b5d..7b68f2b0 100644 --- a/Sources/MeiliSearch/Model/Version.swift +++ b/Sources/MeiliSearch/Model/Version.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Version` instances represent the current version of the Meilisearch server. diff --git a/Sources/MeiliSearch/Model/WaitOptions.swift b/Sources/MeiliSearch/Model/WaitOptions.swift index ca95a1de..21a45265 100644 --- a/Sources/MeiliSearch/Model/WaitOptions.swift +++ b/Sources/MeiliSearch/Model/WaitOptions.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `WaitOptions` struct represent the options used during a waitForPendingUpdate call. diff --git a/Sources/MeiliSearch/Request.swift b/Sources/MeiliSearch/Request.swift index 5740e666..96e5e047 100755 --- a/Sources/MeiliSearch/Request.swift +++ b/Sources/MeiliSearch/Request.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Search.swift b/Sources/MeiliSearch/Search.swift index ec346178..e6d2582f 100644 --- a/Sources/MeiliSearch/Search.swift +++ b/Sources/MeiliSearch/Search.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Search { // MARK: Properties diff --git a/Sources/MeiliSearch/Settings.swift b/Sources/MeiliSearch/Settings.swift index 3e683d2d..79530acc 100644 --- a/Sources/MeiliSearch/Settings.swift +++ b/Sources/MeiliSearch/Settings.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Settings is a list of all the customization possible for an index. diff --git a/Sources/MeiliSearch/Stats.swift b/Sources/MeiliSearch/Stats.swift index a8490e97..0b4b7f98 100644 --- a/Sources/MeiliSearch/Stats.swift +++ b/Sources/MeiliSearch/Stats.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Stats { // MARK: Properties diff --git a/Sources/MeiliSearch/System.swift b/Sources/MeiliSearch/System.swift index 86f848b2..d1fc6d00 100755 --- a/Sources/MeiliSearch/System.swift +++ b/Sources/MeiliSearch/System.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct System { // MARK: Properties diff --git a/Sources/MeiliSearch/Tasks.swift b/Sources/MeiliSearch/Tasks.swift index a33bc951..2f760196 100644 --- a/Sources/MeiliSearch/Tasks.swift +++ b/Sources/MeiliSearch/Tasks.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Tasks contains information related to asynchronous tasks in MeiliSearch diff --git a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift index 9bad5937..ff664ee3 100755 --- a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping // swiftlint:disable force_try diff --git a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift index 9eab30cb..4ff96dbf 100644 --- a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class DumpsTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift index 7b4fe226..607e8316 100644 --- a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift +++ b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift @@ -1,5 +1,9 @@ @testable import MeiliSearch import XCTest +import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class IndexesTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/KeysTests.swift b/Tests/MeiliSearchIntegrationTests/KeysTests.swift index a8ed3613..f0cd1dc9 100644 --- a/Tests/MeiliSearchIntegrationTests/KeysTests.swift +++ b/Tests/MeiliSearchIntegrationTests/KeysTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class KeysTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/SearchTests.swift b/Tests/MeiliSearchIntegrationTests/SearchTests.swift index cf7e59ab..0f125b11 100644 --- a/Tests/MeiliSearchIntegrationTests/SearchTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SearchTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif private let books: [Book] = [ Book(id: 123, title: "Pride and Prejudice", comment: "A great book", genres: ["Classic Regency nove"]), diff --git a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift index 43707a82..04a7a95b 100644 --- a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class SettingsTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/Support/Movie.swift b/Tests/MeiliSearchIntegrationTests/Support/Movie.swift index b25fc67e..14b47935 100644 --- a/Tests/MeiliSearchIntegrationTests/Support/Movie.swift +++ b/Tests/MeiliSearchIntegrationTests/Support/Movie.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif public struct Movie: Codable, Equatable { let id: Int diff --git a/Tests/MeiliSearchIntegrationTests/TaskTests.swift b/Tests/MeiliSearchIntegrationTests/TaskTests.swift index 8ff7bee0..8856823c 100644 --- a/Tests/MeiliSearchIntegrationTests/TaskTests.swift +++ b/Tests/MeiliSearchIntegrationTests/TaskTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class TasksTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/Utils.swift b/Tests/MeiliSearchIntegrationTests/Utils.swift index a8d010c2..aeeb3980 100644 --- a/Tests/MeiliSearchIntegrationTests/Utils.swift +++ b/Tests/MeiliSearchIntegrationTests/Utils.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest @testable import MeiliSearch diff --git a/Tests/MeiliSearchUnitTests/DocumentsTests.swift b/Tests/MeiliSearchUnitTests/DocumentsTests.swift index 40036312..58397f01 100755 --- a/Tests/MeiliSearchUnitTests/DocumentsTests.swift +++ b/Tests/MeiliSearchUnitTests/DocumentsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping // swiftlint:disable force_try diff --git a/Tests/MeiliSearchUnitTests/MockURLSession.swift b/Tests/MeiliSearchUnitTests/MockURLSession.swift index 52b652ca..e187436a 100644 --- a/Tests/MeiliSearchUnitTests/MockURLSession.swift +++ b/Tests/MeiliSearchUnitTests/MockURLSession.swift @@ -1,5 +1,8 @@ @testable import MeiliSearch import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping class MockURLSession: URLSessionProtocol { diff --git a/Tests/MeiliSearchUnitTests/PackageVersionTests.swift b/Tests/MeiliSearchUnitTests/PackageVersionTests.swift index 08bb36a0..3cb3ec8b 100644 --- a/Tests/MeiliSearchUnitTests/PackageVersionTests.swift +++ b/Tests/MeiliSearchUnitTests/PackageVersionTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest class PackageVersionTests: XCTestCase { diff --git a/Tests/MeiliSearchUnitTests/Utils.swift b/Tests/MeiliSearchUnitTests/Utils.swift index da37246f..9608fb02 100644 --- a/Tests/MeiliSearchUnitTests/Utils.swift +++ b/Tests/MeiliSearchUnitTests/Utils.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest @testable import MeiliSearch From 4122cff4a169e427710613a7469fff691d45286a Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Thu, 4 Aug 2022 17:30:09 -0300 Subject: [PATCH 03/13] Add linux build to Ci --- .github/workflows/pre-release-tests.yml | 9 ++++++--- .github/workflows/tests.yml | 9 ++++++--- bors.toml | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pre-release-tests.yml b/.github/workflows/pre-release-tests.yml index 0e54d3eb..a0c364b5 100644 --- a/.github/workflows/pre-release-tests.yml +++ b/.github/workflows/pre-release-tests.yml @@ -9,9 +9,12 @@ on: branches: [bump-meilisearch-v*] jobs: - integeration_tests: - name: integration-tests - runs-on: macos-11 + integration_tests: + name: integration-tests on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] env: DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 08a6d36f..61b77c88 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,12 +10,15 @@ on: - main jobs: - integeration_tests: + integration_tests: # Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR) # Will still run for each push to bump-meilisearch-v* if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v') - name: integration-tests - runs-on: macos-latest + name: integration-tests on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] env: DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer GITHUB_PAT: ${{ secrets.MEILIBOT_PAT_REPO }} diff --git a/bors.toml b/bors.toml index 9b0e9575..ba719a56 100644 --- a/bors.toml +++ b/bors.toml @@ -1,3 +1,7 @@ -status = ['integration-tests', 'linter-check'] +status = [ + 'integration-tests on macos-11', + 'integration-tests on ubuntu-20.04', + 'linter-check' +] # 1 hour timeout timeout-sec = 3600 From a7968a78c86c099d9740b7717300f8f0268c5aa4 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 11:58:25 -0300 Subject: [PATCH 04/13] Remove older Dockerfile --- Dockerfile | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 871d4ab7..00000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# Run -FROM maxdesiatov/swift-alpine - -RUN apk add -q --no-cache libgcc tini curl && \ - curl -L https://install.meilisearch.com | sh && \ - chmod +x meilisearch - -COPY . . - -ENTRYPOINT ["tini", "--"] -CMD ./meilisearch From c7ea5652d5baea2cee1c45aa2ed0e27d012ddb6c Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 11:58:36 -0300 Subject: [PATCH 05/13] Create docker-compose with linux swift --- docker-compose.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..240ed9a0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.8" + +services: + package: + image: swift:5.6-focal + tty: true + stdin_open: true + working_dir: /home/package + environment: + - MEILISEARCH_HOST=http://meilisearch:7700 + depends_on: + - meilisearch + links: + - meilisearch + volumes: + - ./:/home/package + + meilisearch: + image: getmeili/meilisearch:latest + ports: + - "7700" + environment: + - MEILI_MASTER_KEY=masterKey + - MEILI_NO_ANALYTICS=true From 532bc09dcde606a9748cf2d6f1d5c049df5c11b9 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 11:58:49 -0300 Subject: [PATCH 06/13] Change instructions in CONTRIBUTING --- CONTRIBUTING.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c91e9839..e41eaa7b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,16 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume ### Setup +You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml). + +Example of running all the checks with docker: +```bash +docker-compose run --rm package bash -c "swift test && swift run swiftlint" +``` + +To install dependencies: + + ```bash swift build ``` @@ -62,9 +72,7 @@ If you want to fix your linting errors: swift run swiftlint --fix ``` -### On Xcode - -### Setup +### Setup on Xcode To build the project, if it's not already done, click on the play button in the top left corner of Xcode. From cdc95414b9d094c8f8d3f784852afe5d14f12137 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 13:00:00 -0300 Subject: [PATCH 07/13] Create a util method to handle ENV configuration from Docker --- Tests/MeiliSearchIntegrationTests/Utils.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/MeiliSearchIntegrationTests/Utils.swift b/Tests/MeiliSearchIntegrationTests/Utils.swift index aeeb3980..7850de18 100644 --- a/Tests/MeiliSearchIntegrationTests/Utils.swift +++ b/Tests/MeiliSearchIntegrationTests/Utils.swift @@ -19,6 +19,10 @@ private let movies: [Movie] = [ public let TESTS_TIME_OUT = 10.0 +public func currentHost() -> String { + ProcessInfo.processInfo.environment["MEILISEARCH_HOST"] ?? "http://localhost:7700" +} + public func waitForTask( _ client: MeiliSearch, _ uid: String, From 9868f3f8e7a011d83692edbebd9d1d215a4f9255 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 13:00:21 -0300 Subject: [PATCH 08/13] Use currentHost() func instead of hardcoded host --- Tests/MeiliSearchIntegrationTests/DocumentsTests.swift | 2 +- Tests/MeiliSearchIntegrationTests/DumpsTests.swift | 2 +- Tests/MeiliSearchIntegrationTests/IndexesTests.swift | 2 +- Tests/MeiliSearchIntegrationTests/SearchTests.swift | 2 +- Tests/MeiliSearchIntegrationTests/SettingsTests.swift | 2 +- Tests/MeiliSearchIntegrationTests/TaskTests.swift | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift index ff664ee3..f0ef1c3a 100755 --- a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift @@ -27,7 +27,7 @@ class DocumentsTests: XCTestCase { override func setUp() { super.setUp() session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) index = self.client.index(self.uid) let expectation = XCTestExpectation(description: "Create index if it does not exist") self.client.createIndex(uid: uid) { result in diff --git a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift index 4ff96dbf..bb5dbe60 100644 --- a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift @@ -16,7 +16,7 @@ class DumpsTests: XCTestCase { super.setUp() if client == nil { session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) } } diff --git a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift index 607e8316..d3f3ea9d 100644 --- a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift +++ b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift @@ -17,7 +17,7 @@ class IndexesTests: XCTestCase { if client == nil { session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) } index = self.client.index(self.uid) diff --git a/Tests/MeiliSearchIntegrationTests/SearchTests.swift b/Tests/MeiliSearchIntegrationTests/SearchTests.swift index 0f125b11..bca4524f 100644 --- a/Tests/MeiliSearchIntegrationTests/SearchTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SearchTests.swift @@ -38,7 +38,7 @@ class SearchTests: XCTestCase { super.setUp() session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) index = self.client.index(self.uid) nestedIndex = self.client.index(self.nested_uid) diff --git a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift index 04a7a95b..836ff2ea 100644 --- a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift @@ -36,7 +36,7 @@ class SettingsTests: XCTestCase { super.setUp() session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) index = self.client.index(self.uid) let createExpectation = XCTestExpectation(description: "Create Movies index") diff --git a/Tests/MeiliSearchIntegrationTests/TaskTests.swift b/Tests/MeiliSearchIntegrationTests/TaskTests.swift index 8856823c..3d421477 100644 --- a/Tests/MeiliSearchIntegrationTests/TaskTests.swift +++ b/Tests/MeiliSearchIntegrationTests/TaskTests.swift @@ -17,7 +17,7 @@ class TasksTests: XCTestCase { override func setUp() { super.setUp() session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) index = self.client.index(self.uid) let createExpectation = XCTestExpectation(description: "Create Movies index") createGenericIndex(client: self.client, uid: self.uid) { result in From 7e59f438e111d32da16c4055d87895c72b2265cd Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 13:00:38 -0300 Subject: [PATCH 09/13] Fix random issue in Keys tests --- .../KeysTests.swift | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Tests/MeiliSearchIntegrationTests/KeysTests.swift b/Tests/MeiliSearchIntegrationTests/KeysTests.swift index f0cd1dc9..99a18874 100644 --- a/Tests/MeiliSearchIntegrationTests/KeysTests.swift +++ b/Tests/MeiliSearchIntegrationTests/KeysTests.swift @@ -16,28 +16,25 @@ class KeysTests: XCTestCase { super.setUp() session = URLSession(configuration: .ephemeral) - client = try! MeiliSearch(host: "http://localhost:7700", apiKey: "masterKey", session: session) + client = try! MeiliSearch(host: currentHost(), apiKey: "masterKey", session: session) + + let semaphore = XCTestExpectation(description: "Setup: delete all keys") // remove all keys to keep a clean state self.client.getKeys(params: KeysQuery(limit: 100, offset: 0)) { result in switch result { case .success(let keys): keys.results.forEach { - self.client.deleteKey(key: $0.uid) { result in - switch result { - case .success: - () - case .failure(let error): - dump(error) - XCTFail("Failed to delete key") - } - } + self.client.deleteKey(key: $0.uid) { _ in } } - case .failure(let error): - dump(error) - XCTFail("Failed to retrieve and delete all keys") + + semaphore.fulfill() + case .failure: + semaphore.fulfill() } } + + self.wait(for: [semaphore], timeout: TESTS_TIME_OUT) } func testGetKeys() { @@ -122,7 +119,7 @@ class KeysTests: XCTestCase { func testCreateKeyWithOptionalUid() { let keyExpectation = XCTestExpectation(description: "Create a key") - let uid = "1f05fa47-cfa6-40f7-8b80-7bd17b39f105" + let uid = UUID().uuidString.lowercased() let keyParams = KeyParams(uid: uid, actions: ["*"], indexes: ["*"], expiresAt: nil) self.client.createKey(keyParams) { result in From d0f38b0d11f9a71f1ba03d186a8e584275221083 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Fri, 5 Aug 2022 14:07:36 -0300 Subject: [PATCH 10/13] Remove unused method from TaskInfo --- Sources/MeiliSearch/Model/TaskInfo.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sources/MeiliSearch/Model/TaskInfo.swift b/Sources/MeiliSearch/Model/TaskInfo.swift index 64cb381b..d64c72a9 100644 --- a/Sources/MeiliSearch/Model/TaskInfo.swift +++ b/Sources/MeiliSearch/Model/TaskInfo.swift @@ -23,10 +23,6 @@ public struct TaskInfo: Codable, Equatable { /// Date when the task has been enqueued. public let enqueuedAt: String - static func == (lhs: TaskInfo, rhs: Task) -> Bool { - lhs.taskUid == rhs.uid - } - public enum CodingKeys: String, CodingKey { case taskUid, indexUid, status, type, enqueuedAt } From 9b3c59af3e5bef88c8b98a79a08e6d189994aa53 Mon Sep 17 00:00:00 2001 From: Aron Budinszky Date: Wed, 27 Apr 2022 16:22:21 +0200 Subject: [PATCH 11/13] Add Linux support (#245) * Add FoundationNetworking imports for Linux support. * Remove autoreleasepool. --- Sources/MeiliSearch/Config.swift | 3 +++ Sources/MeiliSearch/Error.swift | 3 +++ Sources/MeiliSearch/Formatter.swift | 3 +++ Sources/MeiliSearch/Request.swift | 5 +++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/MeiliSearch/Config.swift b/Sources/MeiliSearch/Config.swift index dacea539..b040250b 100755 --- a/Sources/MeiliSearch/Config.swift +++ b/Sources/MeiliSearch/Config.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** A `Config` instance represents the config used by MeiliSearch instance. diff --git a/Sources/MeiliSearch/Error.swift b/Sources/MeiliSearch/Error.swift index aa178b34..b7b3a505 100644 --- a/Sources/MeiliSearch/Error.swift +++ b/Sources/MeiliSearch/Error.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Represent all error types in the client. diff --git a/Sources/MeiliSearch/Formatter.swift b/Sources/MeiliSearch/Formatter.swift index 4f78fc16..bbd59b78 100644 --- a/Sources/MeiliSearch/Formatter.swift +++ b/Sources/MeiliSearch/Formatter.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif extension Formatter { static let iso8601: DateFormatter = { diff --git a/Sources/MeiliSearch/Request.swift b/Sources/MeiliSearch/Request.swift index fcdf280b..5740e666 100755 --- a/Sources/MeiliSearch/Request.swift +++ b/Sources/MeiliSearch/Request.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Protocol that allows custom implementation of the HTTP layer. @@ -68,7 +71,6 @@ public final class Request { param: String? = nil, headers: [String: String] = [:], _ completion: @escaping (Result) -> Void) { - autoreleasepool { var urlString: String = config.url(api: api) if let param: String = param, !param.isEmpty { urlString += param @@ -90,7 +92,6 @@ public final class Request { } task.resume() - } } func post( From 8bd96604ed6507061a88cc9bb85e47ba738c43a5 Mon Sep 17 00:00:00 2001 From: Charlotte Vermandel Date: Wed, 27 Apr 2022 16:30:16 +0200 Subject: [PATCH 12/13] Add linux import everywhere foundation is imported --- Sources/MeiliSearch/Client.swift | 3 +++ Sources/MeiliSearch/Config.swift | 2 +- Sources/MeiliSearch/Constants.swift | 3 +++ Sources/MeiliSearch/Documents.swift | 3 +++ Sources/MeiliSearch/Dumps.swift | 3 +++ Sources/MeiliSearch/Error.swift | 2 +- Sources/MeiliSearch/Formatter.swift | 2 +- Sources/MeiliSearch/Indexes.swift | 3 +++ Sources/MeiliSearch/Keys.swift | 3 +++ Sources/MeiliSearch/Model/Health.swift | 3 +++ Sources/MeiliSearch/Model/Index.swift | 3 +++ Sources/MeiliSearch/Model/Key.swift | 3 +++ Sources/MeiliSearch/Model/KeyParams.swift | 3 +++ Sources/MeiliSearch/Model/PackageVersion.swift | 3 +++ Sources/MeiliSearch/Model/SearchParameters.swift | 3 +++ Sources/MeiliSearch/Model/SearchResult.swift | 3 +++ Sources/MeiliSearch/Model/Setting.swift | 3 +++ Sources/MeiliSearch/Model/Stat.swift | 3 +++ Sources/MeiliSearch/Model/Task.swift | 3 +++ Sources/MeiliSearch/Model/Version.swift | 3 +++ Sources/MeiliSearch/Model/WaitOptions.swift | 3 +++ Sources/MeiliSearch/Request.swift | 2 +- Sources/MeiliSearch/Search.swift | 3 +++ Sources/MeiliSearch/Settings.swift | 3 +++ Sources/MeiliSearch/Stats.swift | 3 +++ Sources/MeiliSearch/System.swift | 3 +++ Sources/MeiliSearch/Tasks.swift | 3 +++ Tests/MeiliSearchIntegrationTests/DocumentsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/DumpsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/IndexesTests.swift | 4 ++++ Tests/MeiliSearchIntegrationTests/KeysTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/SearchTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/SettingsTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/Support/Movie.swift | 3 +++ Tests/MeiliSearchIntegrationTests/TaskTests.swift | 3 +++ Tests/MeiliSearchIntegrationTests/Utils.swift | 3 +++ Tests/MeiliSearchUnitTests/DocumentsTests.swift | 3 +++ Tests/MeiliSearchUnitTests/MockURLSession.swift | 3 +++ Tests/MeiliSearchUnitTests/PackageVersionTests.swift | 3 +++ Tests/MeiliSearchUnitTests/Utils.swift | 3 +++ 40 files changed, 113 insertions(+), 4 deletions(-) diff --git a/Sources/MeiliSearch/Client.swift b/Sources/MeiliSearch/Client.swift index fb31df70..7e2f32ba 100755 --- a/Sources/MeiliSearch/Client.swift +++ b/Sources/MeiliSearch/Client.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** A `MeiliSearch` instance represents a Meilisearch client used to easily integrate diff --git a/Sources/MeiliSearch/Config.swift b/Sources/MeiliSearch/Config.swift index b040250b..5dec4234 100755 --- a/Sources/MeiliSearch/Config.swift +++ b/Sources/MeiliSearch/Config.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Constants.swift b/Sources/MeiliSearch/Constants.swift index 5220be37..f1394a59 100644 --- a/Sources/MeiliSearch/Constants.swift +++ b/Sources/MeiliSearch/Constants.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Constants { static let customJSONDecoder: JSONDecoder = { diff --git a/Sources/MeiliSearch/Documents.swift b/Sources/MeiliSearch/Documents.swift index 81baeb0d..dacfe4e8 100755 --- a/Sources/MeiliSearch/Documents.swift +++ b/Sources/MeiliSearch/Documents.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Documents { // MARK: Properties diff --git a/Sources/MeiliSearch/Dumps.swift b/Sources/MeiliSearch/Dumps.swift index 1894a900..41c40798 100644 --- a/Sources/MeiliSearch/Dumps.swift +++ b/Sources/MeiliSearch/Dumps.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** The dumps route allows the creation of database dumps. Dumps are `.tar.gz` files that diff --git a/Sources/MeiliSearch/Error.swift b/Sources/MeiliSearch/Error.swift index b7b3a505..a049e619 100644 --- a/Sources/MeiliSearch/Error.swift +++ b/Sources/MeiliSearch/Error.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Formatter.swift b/Sources/MeiliSearch/Formatter.swift index bbd59b78..39c50999 100644 --- a/Sources/MeiliSearch/Formatter.swift +++ b/Sources/MeiliSearch/Formatter.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif extension Formatter { diff --git a/Sources/MeiliSearch/Indexes.swift b/Sources/MeiliSearch/Indexes.swift index b0aaa9ac..7ae4dea0 100755 --- a/Sources/MeiliSearch/Indexes.swift +++ b/Sources/MeiliSearch/Indexes.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif public struct Indexes { // MARK: Properties diff --git a/Sources/MeiliSearch/Keys.swift b/Sources/MeiliSearch/Keys.swift index afd0a4d6..aa32adec 100644 --- a/Sources/MeiliSearch/Keys.swift +++ b/Sources/MeiliSearch/Keys.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Keys { // MARK: Properties diff --git a/Sources/MeiliSearch/Model/Health.swift b/Sources/MeiliSearch/Model/Health.swift index 9d503301..2fcd2400 100644 --- a/Sources/MeiliSearch/Model/Health.swift +++ b/Sources/MeiliSearch/Model/Health.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Health` instances represent the status of the Meilisearch server. diff --git a/Sources/MeiliSearch/Model/Index.swift b/Sources/MeiliSearch/Model/Index.swift index cb42a012..fb1ff0bb 100755 --- a/Sources/MeiliSearch/Model/Index.swift +++ b/Sources/MeiliSearch/Model/Index.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Index` instances is an entity that gathers a set of documents with its own settings. diff --git a/Sources/MeiliSearch/Model/Key.swift b/Sources/MeiliSearch/Model/Key.swift index 600126dd..ea3bbcb4 100644 --- a/Sources/MeiliSearch/Model/Key.swift +++ b/Sources/MeiliSearch/Model/Key.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Each key has a given set of permissions on the API routes. diff --git a/Sources/MeiliSearch/Model/KeyParams.swift b/Sources/MeiliSearch/Model/KeyParams.swift index b1c6ab71..936eaf6b 100644 --- a/Sources/MeiliSearch/Model/KeyParams.swift +++ b/Sources/MeiliSearch/Model/KeyParams.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `KeyParams` contains all the parameters to create an API key. diff --git a/Sources/MeiliSearch/Model/PackageVersion.swift b/Sources/MeiliSearch/Model/PackageVersion.swift index 6a15f1a3..e4b910c0 100644 --- a/Sources/MeiliSearch/Model/PackageVersion.swift +++ b/Sources/MeiliSearch/Model/PackageVersion.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif internal struct PackageVersion { /// This is the current version of the meilisearch-swift package diff --git a/Sources/MeiliSearch/Model/SearchParameters.swift b/Sources/MeiliSearch/Model/SearchParameters.swift index d354d4e6..38da79dd 100644 --- a/Sources/MeiliSearch/Model/SearchParameters.swift +++ b/Sources/MeiliSearch/Model/SearchParameters.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `SearchParameters` instances represent query setup for a search request. diff --git a/Sources/MeiliSearch/Model/SearchResult.swift b/Sources/MeiliSearch/Model/SearchResult.swift index 51ecf592..b14b8dca 100644 --- a/Sources/MeiliSearch/Model/SearchResult.swift +++ b/Sources/MeiliSearch/Model/SearchResult.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `SearchResult` instances represent the result of a search. diff --git a/Sources/MeiliSearch/Model/Setting.swift b/Sources/MeiliSearch/Model/Setting.swift index 4f18b4b2..8f52c578 100644 --- a/Sources/MeiliSearch/Model/Setting.swift +++ b/Sources/MeiliSearch/Model/Setting.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Settings object provided byb the user diff --git a/Sources/MeiliSearch/Model/Stat.swift b/Sources/MeiliSearch/Model/Stat.swift index 8bd27707..d82d968a 100644 --- a/Sources/MeiliSearch/Model/Stat.swift +++ b/Sources/MeiliSearch/Model/Stat.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `AllStats` instances represent stat of all Indexes. diff --git a/Sources/MeiliSearch/Model/Task.swift b/Sources/MeiliSearch/Model/Task.swift index 31817515..ecd479c4 100644 --- a/Sources/MeiliSearch/Model/Task.swift +++ b/Sources/MeiliSearch/Model/Task.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Task` instances represent the current transaction status, use the `uid` value to diff --git a/Sources/MeiliSearch/Model/Version.swift b/Sources/MeiliSearch/Model/Version.swift index 1eb94b5d..7b68f2b0 100644 --- a/Sources/MeiliSearch/Model/Version.swift +++ b/Sources/MeiliSearch/Model/Version.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `Version` instances represent the current version of the Meilisearch server. diff --git a/Sources/MeiliSearch/Model/WaitOptions.swift b/Sources/MeiliSearch/Model/WaitOptions.swift index 41dd33cd..f95c5ab6 100644 --- a/Sources/MeiliSearch/Model/WaitOptions.swift +++ b/Sources/MeiliSearch/Model/WaitOptions.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** `WaitOptions` struct represent the options used during a waitForTask call. diff --git a/Sources/MeiliSearch/Request.swift b/Sources/MeiliSearch/Request.swift index 5740e666..96e5e047 100755 --- a/Sources/MeiliSearch/Request.swift +++ b/Sources/MeiliSearch/Request.swift @@ -1,6 +1,6 @@ import Foundation #if canImport(FoundationNetworking) - import FoundationNetworking + import FoundationNetworking #endif /** diff --git a/Sources/MeiliSearch/Search.swift b/Sources/MeiliSearch/Search.swift index ec346178..e6d2582f 100644 --- a/Sources/MeiliSearch/Search.swift +++ b/Sources/MeiliSearch/Search.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Search { // MARK: Properties diff --git a/Sources/MeiliSearch/Settings.swift b/Sources/MeiliSearch/Settings.swift index 276ef1a3..6beef90c 100644 --- a/Sources/MeiliSearch/Settings.swift +++ b/Sources/MeiliSearch/Settings.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Settings is a list of all the customization possible for an index. diff --git a/Sources/MeiliSearch/Stats.swift b/Sources/MeiliSearch/Stats.swift index a8490e97..0b4b7f98 100644 --- a/Sources/MeiliSearch/Stats.swift +++ b/Sources/MeiliSearch/Stats.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct Stats { // MARK: Properties diff --git a/Sources/MeiliSearch/System.swift b/Sources/MeiliSearch/System.swift index 89ea625b..2ae61673 100755 --- a/Sources/MeiliSearch/System.swift +++ b/Sources/MeiliSearch/System.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif struct System { // MARK: Properties diff --git a/Sources/MeiliSearch/Tasks.swift b/Sources/MeiliSearch/Tasks.swift index a33bc951..2f760196 100644 --- a/Sources/MeiliSearch/Tasks.swift +++ b/Sources/MeiliSearch/Tasks.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif /** Tasks contains information related to asynchronous tasks in MeiliSearch diff --git a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift index 9bad5937..ff664ee3 100755 --- a/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DocumentsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping // swiftlint:disable force_try diff --git a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift index 9eab30cb..4ff96dbf 100644 --- a/Tests/MeiliSearchIntegrationTests/DumpsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/DumpsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class DumpsTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift index 7b4fe226..607e8316 100644 --- a/Tests/MeiliSearchIntegrationTests/IndexesTests.swift +++ b/Tests/MeiliSearchIntegrationTests/IndexesTests.swift @@ -1,5 +1,9 @@ @testable import MeiliSearch import XCTest +import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class IndexesTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/KeysTests.swift b/Tests/MeiliSearchIntegrationTests/KeysTests.swift index d02d30af..61b3cd6b 100644 --- a/Tests/MeiliSearchIntegrationTests/KeysTests.swift +++ b/Tests/MeiliSearchIntegrationTests/KeysTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class KeysTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/SearchTests.swift b/Tests/MeiliSearchIntegrationTests/SearchTests.swift index cf7e59ab..0f125b11 100644 --- a/Tests/MeiliSearchIntegrationTests/SearchTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SearchTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif private let books: [Book] = [ Book(id: 123, title: "Pride and Prejudice", comment: "A great book", genres: ["Classic Regency nove"]), diff --git a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift index 43707a82..04a7a95b 100644 --- a/Tests/MeiliSearchIntegrationTests/SettingsTests.swift +++ b/Tests/MeiliSearchIntegrationTests/SettingsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class SettingsTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/Support/Movie.swift b/Tests/MeiliSearchIntegrationTests/Support/Movie.swift index b25fc67e..14b47935 100644 --- a/Tests/MeiliSearchIntegrationTests/Support/Movie.swift +++ b/Tests/MeiliSearchIntegrationTests/Support/Movie.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif public struct Movie: Codable, Equatable { let id: Int diff --git a/Tests/MeiliSearchIntegrationTests/TaskTests.swift b/Tests/MeiliSearchIntegrationTests/TaskTests.swift index 8ff7bee0..8856823c 100644 --- a/Tests/MeiliSearchIntegrationTests/TaskTests.swift +++ b/Tests/MeiliSearchIntegrationTests/TaskTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_try class TasksTests: XCTestCase { diff --git a/Tests/MeiliSearchIntegrationTests/Utils.swift b/Tests/MeiliSearchIntegrationTests/Utils.swift index a8d010c2..aeeb3980 100644 --- a/Tests/MeiliSearchIntegrationTests/Utils.swift +++ b/Tests/MeiliSearchIntegrationTests/Utils.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest @testable import MeiliSearch diff --git a/Tests/MeiliSearchUnitTests/DocumentsTests.swift b/Tests/MeiliSearchUnitTests/DocumentsTests.swift index 40036312..58397f01 100755 --- a/Tests/MeiliSearchUnitTests/DocumentsTests.swift +++ b/Tests/MeiliSearchUnitTests/DocumentsTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import XCTest import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping // swiftlint:disable force_try diff --git a/Tests/MeiliSearchUnitTests/MockURLSession.swift b/Tests/MeiliSearchUnitTests/MockURLSession.swift index 52b652ca..e187436a 100644 --- a/Tests/MeiliSearchUnitTests/MockURLSession.swift +++ b/Tests/MeiliSearchUnitTests/MockURLSession.swift @@ -1,5 +1,8 @@ @testable import MeiliSearch import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif // swiftlint:disable force_unwrapping class MockURLSession: URLSessionProtocol { diff --git a/Tests/MeiliSearchUnitTests/PackageVersionTests.swift b/Tests/MeiliSearchUnitTests/PackageVersionTests.swift index 08bb36a0..3cb3ec8b 100644 --- a/Tests/MeiliSearchUnitTests/PackageVersionTests.swift +++ b/Tests/MeiliSearchUnitTests/PackageVersionTests.swift @@ -1,6 +1,9 @@ @testable import MeiliSearch import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest class PackageVersionTests: XCTestCase { diff --git a/Tests/MeiliSearchUnitTests/Utils.swift b/Tests/MeiliSearchUnitTests/Utils.swift index da37246f..9608fb02 100644 --- a/Tests/MeiliSearchUnitTests/Utils.swift +++ b/Tests/MeiliSearchUnitTests/Utils.swift @@ -1,4 +1,7 @@ import Foundation +#if canImport(FoundationNetworking) + import FoundationNetworking +#endif import XCTest @testable import MeiliSearch From 4b02ac8036abcb6192d65bdcab6bc24fa049e02b Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Thu, 4 Aug 2022 17:30:09 -0300 Subject: [PATCH 13/13] Add linux build to Ci --- .github/workflows/pre-release-tests.yml | 9 ++++++--- .github/workflows/tests.yml | 9 ++++++--- bors.toml | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pre-release-tests.yml b/.github/workflows/pre-release-tests.yml index 0e54d3eb..a0c364b5 100644 --- a/.github/workflows/pre-release-tests.yml +++ b/.github/workflows/pre-release-tests.yml @@ -9,9 +9,12 @@ on: branches: [bump-meilisearch-v*] jobs: - integeration_tests: - name: integration-tests - runs-on: macos-11 + integration_tests: + name: integration-tests on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] env: DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 08a6d36f..61b77c88 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,12 +10,15 @@ on: - main jobs: - integeration_tests: + integration_tests: # Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR) # Will still run for each push to bump-meilisearch-v* if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v') - name: integration-tests - runs-on: macos-latest + name: integration-tests on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] env: DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer GITHUB_PAT: ${{ secrets.MEILIBOT_PAT_REPO }} diff --git a/bors.toml b/bors.toml index 9b0e9575..ba719a56 100644 --- a/bors.toml +++ b/bors.toml @@ -1,3 +1,7 @@ -status = ['integration-tests', 'linter-check'] +status = [ + 'integration-tests on macos-11', + 'integration-tests on ubuntu-20.04', + 'linter-check' +] # 1 hour timeout timeout-sec = 3600