Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume

### Setup <!-- omit in TOC -->

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
```
Expand Down Expand Up @@ -62,9 +72,7 @@ If you want to fix your linting errors:
swift run swiftlint --fix
```

### On Xcode <!-- omit in TOC -->

### Setup <!-- omit in TOC -->
### Setup on Xcode <!-- omit in TOC -->

To build the project, if it's not already done, click on the play button in the top left corner of Xcode.

Expand Down
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Client.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
A `MeiliSearch` instance represents a Meilisearch client used to easily integrate
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Config.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
A `Config` instance represents the config used by MeiliSearch instance.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Constants.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct Constants {
static let customJSONDecoder: JSONDecoder = {
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Documents.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct Documents {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Dumps.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Error.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Represent all error types in the client.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Formatter.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

extension Formatter {
static let iso8601: DateFormatter = {
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Indexes.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

public struct Indexes {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Keys.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct Keys {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Health.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`Health` instances represent the status of the Meilisearch server.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Index.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Key.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Each key has a given set of permissions on the API routes.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/KeyParams.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`KeyParams` contains all the parameters to create an API key.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/PackageVersion.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/SearchParameters.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`SearchParameters` instances represent query setup for a search request.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/SearchResult.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`SearchResult` instances represent the result of a search.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Setting.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Settings object provided byb the user
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Stat.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`AllStats` instances represent stat of all Indexes.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Task.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`Task` instances represent the current transaction status, use the `uid` value to
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/Version.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`Version` instances represent the current version of the Meilisearch server.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Model/WaitOptions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
`WaitOptions` struct represent the options used during a waitForPendingUpdate call.
Expand Down
5 changes: 3 additions & 2 deletions Sources/MeiliSearch/Request.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Protocol that allows custom implementation of the HTTP layer.
Expand Down Expand Up @@ -68,7 +71,6 @@ public final class Request {
param: String? = nil,
headers: [String: String] = [:],
_ completion: @escaping (Result<Data?, Swift.Error>) -> Void) {
autoreleasepool {
var urlString: String = config.url(api: api)
if let param: String = param, !param.isEmpty {
urlString += param
Expand All @@ -90,7 +92,6 @@ public final class Request {
}

task.resume()
}
}

func post(
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Search.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct Search {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Settings.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Settings is a list of all the customization possible for an index.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Stats.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct Stats {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/System.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

struct System {
// MARK: Properties
Expand Down
3 changes: 3 additions & 0 deletions Sources/MeiliSearch/Tasks.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/**
Tasks contains information related to asynchronous tasks in MeiliSearch
Expand Down
5 changes: 4 additions & 1 deletion Tests/MeiliSearchIntegrationTests/DocumentsTests.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Tests/MeiliSearchIntegrationTests/DumpsTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@testable import MeiliSearch
import XCTest
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

// swiftlint:disable force_try
class DumpsTests: XCTestCase {
Expand All @@ -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)
}
}

Expand Down
6 changes: 5 additions & 1 deletion Tests/MeiliSearchIntegrationTests/IndexesTests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@testable import MeiliSearch
import XCTest
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

// swiftlint:disable force_try
class IndexesTests: XCTestCase {
Expand All @@ -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)

Expand Down
Loading