From a921ecb7a0c63019dab1ed32ae4d9eb97d76b51d Mon Sep 17 00:00:00 2001 From: Dhaya <154633+dhayab@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:52:56 +0200 Subject: [PATCH] fix: conform pagemap extension to sequence protocol (#321) --- .editorconfig | 8 ++++++++ .github/workflows/pods.yml | 6 +++--- .github/workflows/swift.yml | 17 ++++++++++++++--- .gitignore | 3 +++ Cartfile | 1 + InstantSearch.podspec | 1 + Package.swift | 4 +++- .../InstantSearchCore/Pagination/PageMap.swift | 5 +++-- .../MultiIndex/MultiIndexSearcher.swift | 2 +- .../Connector/SortByConnector+Controller.swift | 4 ++-- .../SortBy/Connector/SortByConnector.swift | 8 ++++---- .../Unit/DecodingErrorPrettyPrinterTests.swift | 7 ++++++- 12 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..dd7255e8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/workflows/pods.yml b/.github/workflows/pods.yml index 8cf4728d..68594b0c 100644 --- a/.github/workflows/pods.yml +++ b/.github/workflows/pods.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - name: Select Xcode version run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer' - - name: lint Insights + - name: lint Core run: pod lib lint --subspec="Core" --allow-warnings lint-UI: runs-on: macos-12 @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v2 - name: Select Xcode version run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer' - - name: lint Insights + - name: lint UI run: pod lib lint --subspec="UI" --allow-warnings lint-SwiftUI: runs-on: macos-12 @@ -31,5 +31,5 @@ jobs: - uses: actions/checkout@v2 - name: Select Xcode version run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer' - - name: lint Insights + - name: lint SwiftUI run: pod lib lint --subspec="SwiftUI" --allow-warnings \ No newline at end of file diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 485a2ba5..d2b73de9 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -8,13 +8,24 @@ jobs: env: ALGOLIA_APPLICATION_ID_1: ${{ secrets.ALGOLIA_APPLICATION_ID_1 }} ALGOLIA_ADMIN_KEY_1: ${{ secrets.ALGOLIA_ADMIN_KEY_1 }} - ALGOLIA_PLACES_APPLICATION_ID: ${{ secrets.ALGOLIA_PLACES_APPLICATION_ID }} - ALGOLIA_PLACES_API_KEY: ${{ secrets.ALGOLIA_PLACES_API_KEY }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Select Xcode version run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer' - name: Build project run: swift build - name: Run tests run: swift test + test-xcode-16: + runs-on: macos-14 + env: + ALGOLIA_APPLICATION_ID_1: ${{ secrets.ALGOLIA_APPLICATION_ID_1 }} + ALGOLIA_ADMIN_KEY_1: ${{ secrets.ALGOLIA_ADMIN_KEY_1 }} + steps: + - uses: actions/checkout@v4 + - name: Select Xcode version + run: sudo xcode-select -s '/Applications/Xcode_16.0.app/Contents/Developer' + - name: Build project + run: swift build + - name: Run tests + run: swift test diff --git a/.gitignore b/.gitignore index b2106bba..e06b2bb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ ## OS X Finder .DS_Store +## Environment variables +.env + ## Build generated build/ DerivedData diff --git a/Cartfile b/Cartfile index c2c1e414..f5d5bf3c 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,4 @@ github "apple/swift-log" ~> 1.4 github "algolia/algoliasearch-client-swift" ~> 8.18 +github "apple/swift-protobuf" == 1.20.0 github "algolia/instantsearch-telemetry-native" ~> 0.1.3 diff --git a/InstantSearch.podspec b/InstantSearch.podspec index e23fc3e2..826e9df5 100644 --- a/InstantSearch.podspec +++ b/InstantSearch.podspec @@ -30,6 +30,7 @@ Pod::Spec.new do |s| ss.dependency 'AlgoliaSearchClient', '~> 8.18' ss.dependency 'Logging' ss.dependency 'InstantSearch/Insights' + ss.dependency 'SwiftProtobuf', '1.20.0' ss.dependency 'InstantSearchTelemetry', '~> 0.1.3' ss.ios.deployment_target = '14.0' ss.osx.deployment_target = '11.0' diff --git a/Package.swift b/Package.swift index 2ed1ca05..0bd775f2 100644 --- a/Package.swift +++ b/Package.swift @@ -35,9 +35,11 @@ let package = Package( from: "8.18.2"), .package(url: "https://github.com/apple/swift-log", from: "1.5.4"), + .package(url: "https://github.com/apple/swift-protobuf", + .exact("1.20.0")), .package(name: "InstantSearchTelemetry", url: "https://github.com/algolia/instantsearch-telemetry-native", - from: "0.1.3") + .exact("0.1.3")) ], targets: [ .target( diff --git a/Sources/InstantSearchCore/Pagination/PageMap.swift b/Sources/InstantSearchCore/Pagination/PageMap.swift index 097321b6..8caac614 100644 --- a/Sources/InstantSearchCore/Pagination/PageMap.swift +++ b/Sources/InstantSearchCore/Pagination/PageMap.swift @@ -82,8 +82,9 @@ struct PageMap { // MARK: SequenceType extension PageMap: Sequence { - public func makeIterator() -> IndexingIterator { - return IndexingIterator(_elements: self) + public func makeIterator() -> IndexingIterator<[Item?]> { + let elements = (self.startIndex..