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/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. 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 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 dacea539..5dec4234 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/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 aa178b34..a049e619 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..39c50999 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/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/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 } 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 fcdf280b..96e5e047 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( 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..f0ef1c3a 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 @@ -24,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 9eab30cb..bb5dbe60 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 { @@ -13,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 7b4fe226..d3f3ea9d 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 { @@ -13,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/KeysTests.swift b/Tests/MeiliSearchIntegrationTests/KeysTests.swift index d02d30af..f0342e54 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 { @@ -13,14 +16,16 @@ 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(keyOrUid: $0.uid) { result in + self.client.deleteKey(keyOrUid: $0.uid) { _ in switch result { case .success: () @@ -30,11 +35,14 @@ class KeysTests: XCTestCase { } } } - 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() { @@ -119,7 +127,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 diff --git a/Tests/MeiliSearchIntegrationTests/SearchTests.swift b/Tests/MeiliSearchIntegrationTests/SearchTests.swift index cf7e59ab..bca4524f 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"]), @@ -35,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 43707a82..836ff2ea 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 { @@ -33,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/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..3d421477 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 { @@ -14,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 diff --git a/Tests/MeiliSearchIntegrationTests/Utils.swift b/Tests/MeiliSearchIntegrationTests/Utils.swift index a8d010c2..7850de18 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 @@ -16,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, 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 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 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