From 9d705b8c410ddc0ff940bc91b47359358cfdf8bc Mon Sep 17 00:00:00 2001 From: vamsii777 Date: Fri, 27 Mar 2026 13:44:54 +0530 Subject: [PATCH 1/2] Add Swift 6 Sendable support and CI matrix --- .github/workflows/tests.yml | 21 ++++++++++++++------- Sources/DIGIPIN/DIGIPIN.swift | 6 +++--- Tests/DIGIPINTests/DIGIPINTests.swift | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05df236..35bb99b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,20 +17,27 @@ jobs: strategy: fail-fast: false matrix: - swift: ["6.0"] + include: + - swift: "5.10" + xcode: "15.4" + - swift: "6.0" + xcode: "16.1" steps: - uses: actions/checkout@v4 with: submodules: recursive - - - name: Select Xcode for Swift ${{ matrix.swift }} - run: | - sudo xcode-select -s /Applications/Xcode_16.1.app - swift --version + + - name: Select Xcode ${{ matrix.xcode }} + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode }} + + - name: Show Swift version + run: swift --version - name: Build run: swift build - name: Run tests - run: swift test \ No newline at end of file + run: swift test diff --git a/Sources/DIGIPIN/DIGIPIN.swift b/Sources/DIGIPIN/DIGIPIN.swift index 6401be9..809fb96 100644 --- a/Sources/DIGIPIN/DIGIPIN.swift +++ b/Sources/DIGIPIN/DIGIPIN.swift @@ -1,7 +1,7 @@ import Foundation /// Errors that can occur during DIGIPIN encoding or decoding. -public enum DIGIPINError: Error, Equatable, CustomStringConvertible { +public enum DIGIPINError: Error, Equatable, CustomStringConvertible, Sendable { /// The provided coordinates are outside the supported bounds for India. case outOfBounds /// The provided DIGIPIN code is invalid or malformed. @@ -22,7 +22,7 @@ public enum DIGIPINError: Error, Equatable, CustomStringConvertible { } /// Represents a geographic coordinate (latitude and longitude). -public struct Coordinate: Equatable, CustomStringConvertible { +public struct Coordinate: Equatable, CustomStringConvertible, Sendable { /// Latitude in decimal degrees (WGS84). public let latitude: Double /// Longitude in decimal degrees (WGS84). @@ -43,7 +43,7 @@ public struct Coordinate: Equatable, CustomStringConvertible { } /// DIGIPIN encoder/decoder for India Post's Digital Postal Index Number system. -public struct DIGIPIN { +public struct DIGIPIN: Sendable { // MARK: - Constants /// The official 4x4 DIGIPIN grid used at all levels. diff --git a/Tests/DIGIPINTests/DIGIPINTests.swift b/Tests/DIGIPINTests/DIGIPINTests.swift index 0f8fdfb..9eeceaa 100644 --- a/Tests/DIGIPINTests/DIGIPINTests.swift +++ b/Tests/DIGIPINTests/DIGIPINTests.swift @@ -185,4 +185,21 @@ final class DIGIPINTests: XCTestCase { XCTFail("Third code should fail with invalidDIGIPIN") } } + + func testDIGIPINCanBeStoredInSendableType() throws { + struct LocationService: Sendable { + let maxDistanceKm: Double + let digipin = DIGIPIN() + + func code(for coordinate: Coordinate) throws -> String { + try digipin.generateDIGIPIN(for: coordinate) + } + } + + let service = LocationService(maxDistanceKm: 5) + let coordinate = Coordinate(latitude: 28.622788, longitude: 77.213033) + + XCTAssertEqual(service.maxDistanceKm, 5) + XCTAssertEqual(try service.code(for: coordinate), "39J-49L-L8T4") + } } From 4d089dcc7c2e5c2479622501c347dd28a5b11c70 Mon Sep 17 00:00:00 2001 From: vamsii777 Date: Fri, 27 Mar 2026 13:49:46 +0530 Subject: [PATCH 2/2] Fix CI matrix for available Xcode versions --- .github/workflows/tests.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 35bb99b..fe9bb8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,15 +12,17 @@ permissions: jobs: macos-tests: - name: macOS Tests (Swift ${{ matrix.swift }}) + name: macOS Tests (${{ matrix.name }}) runs-on: macos-latest strategy: fail-fast: false matrix: include: - - swift: "5.10" - xcode: "15.4" - - swift: "6.0" + - name: "Xcode 16.0" + swift: "6.0" + xcode: "16.0" + - name: "Xcode 16.1" + swift: "6.0" xcode: "16.1" steps: