Просмотр исходного кода

Merge pull request #54 from norio-nomura/drop-old-swift

Drop Swift 4.1 or earlier
Norio Nomura 5 лет назад
Родитель
Сommit
b2f616efbc

+ 3 - 3
.github/workflows/swiftpm.yml

@@ -18,10 +18,10 @@ on:
       - 'Tests/*/*'
 
 jobs:
-  macOS:
+  Xcode:
     strategy:
       matrix:
-        xcode: ['9.4.1','10','10.1','10.2','10.2.1','10.3','11']
+        xcode: ['10','10.1','10.2','10.2.1','10.3','11']
     runs-on: macOS-10.14
     steps:
       - uses: actions/checkout@v1
@@ -32,7 +32,7 @@ jobs:
   Linux:
     strategy:
       matrix:
-        tag: ['4.1', '4.2', '5.0', '5.1']
+        tag: ['4.2', '5.0', '5.1']
     runs-on: ubuntu-latest
     container:
       image: norionomura/swift:${{ matrix.tag }}

+ 18 - 32
.github/workflows/xcodebuild.yml

@@ -23,49 +23,35 @@ jobs:
   xcodebuild:
     strategy:
       matrix:
-        xcode:
-          - version: '9.4.1'
-          - version: '10'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
-          - version: '10.1'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
-          - version: '10.2'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
-          - version: '10.2.1'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
-          - version: '10.3'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
-          - version: '11'
-            flag_for_test: -enableCodeCoverage YES -parallel-testing-enabled NO
+        developer_dir:
+          - '/Applications/Xcode_10.app'
+          - '/Applications/Xcode_10.1.app'
+          - '/Applications/Xcode_10.2.app'
+          - '/Applications/Xcode_10.2.1.app'
+          - '/Applications/Xcode_10.3.app'
+          - '/Applications/Xcode_11.app'
+        xcode_flags: ['-scheme Base32 -enableCodeCoverage YES -parallel-testing-enabled NO test']
+        xcode_flags_without_test: ['-scheme Base32 build']
     runs-on: macOS-10.14
     steps:
       - uses: actions/checkout@v1
       - run: xcodebuild -version
-        env: 
-          DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
+        env: { 'DEVELOPER_DIR': '${{ matrix.developer_dir }}' }
       - name: macOS
-        env:
-          DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
-        run: xcodebuild -scheme Base32 ${{ matrix.xcode.flag_for_test }} test | xcpretty
+        env: { 'DEVELOPER_DIR': '${{ matrix.developer_dir }}' }
+        run: xcodebuild ${{ matrix.xcode_flags }} | xcpretty
         shell: bash
       - name: iPhone Simulator
-        env:
-          DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
-        run: > 
-          xcodebuild -scheme Base32 ${{ matrix.xcode.flag_for_test }} test
-          -sdk iphonesimulator -destination "name=iPhone 8" | xcpretty
+        env: { 'DEVELOPER_DIR': '${{ matrix.developer_dir }}' }
+        run: xcodebuild ${{ matrix.xcode_flags }} -sdk iphonesimulator -destination "name=iPhone 8" | xcpretty
         shell: bash
       - name: Apple TV Simulator
-        env:
-          DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
-        run: >
-          xcodebuild -scheme Base32 ${{ matrix.xcode.flag_for_test }} test
-          -sdk appletvsimulator -destination "name=Apple TV 4K" | xcpretty
+        env: { 'DEVELOPER_DIR': '${{ matrix.developer_dir }}' }
+        run: xcodebuild ${{ matrix.xcode_flags }} -sdk appletvsimulator -destination "name=Apple TV 4K" | xcpretty
         shell: bash
       - name: watchOS Simulator
-        env:
-          DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
-        run: xcodebuild -scheme Base32 build -sdk watchsimulator | xcpretty
+        env: { 'DEVELOPER_DIR': '${{ matrix.developer_dir }}' }
+        run: xcodebuild ${{ matrix.xcode_flags_without_test }} -sdk watchsimulator | xcpretty
         shell: bash
       - if: matrix.xcode.version == '10.3'
         run: curl -s https://codecov.io/bash | bash -s -- -t ${{ secrets.CODECOV_TOKEN }}

+ 1 - 1
.swift-version

@@ -1 +1 @@
-4.0
+4.2

+ 3 - 2
Package.swift

@@ -1,4 +1,4 @@
-// swift-tools-version:4.0
+// swift-tools-version:4.2
 import PackageDescription
 
 var package = Package(
@@ -9,7 +9,8 @@ var package = Package(
     targets: [
         .target(name: "Base32"),
         .testTarget(name: "Base32Tests", dependencies: ["Base32"])
-    ]
+    ],
+    swiftLanguageVersions: [.v4, .v4_2, .version("5")]
 )
 
 #if os(macOS)

+ 0 - 18
Package@swift-4.2.swift

@@ -1,18 +0,0 @@
-// swift-tools-version:4.2
-import PackageDescription
-
-var package = Package(
-    name: "Base32",
-    products: [
-      .library(name: "Base32", targets: ["Base32"])
-    ],
-    targets: [
-        .target(name: "Base32"),
-        .testTarget(name: "Base32Tests", dependencies: ["Base32"])
-    ],
-    swiftLanguageVersions: [.v4, .v4_2]
-)
-
-#if os(macOS)
-    package.targets.append(.testTarget(name: "SecEncodeTransformTests", dependencies: ["Base32"]))
-#endif

+ 0 - 18
Package@swift-5.swift

@@ -1,18 +0,0 @@
-// swift-tools-version:5.0
-import PackageDescription
-
-var package = Package(
-    name: "Base32",
-    products: [
-      .library(name: "Base32", targets: ["Base32"])
-    ],
-    targets: [
-        .target(name: "Base32"),
-        .testTarget(name: "Base32Tests", dependencies: ["Base32"])
-    ],
-    swiftLanguageVersions: [.v4, .v4_2, .v5]
-)
-
-#if os(macOS)
-    package.targets.append(.testTarget(name: "SecEncodeTransformTests", dependencies: ["Base32"]))
-#endif

+ 0 - 8
Sources/Base32/Base32.swift

@@ -224,18 +224,10 @@ private func base32encode(_ data: UnsafeRawPointer, _ length: Int, _ table: [Int
     
     // return
     if let base32Encoded = String(validatingUTF8: resultBuffer) {
-#if swift(>=4.1)
         resultBuffer.deallocate()
-#else
-        resultBuffer.deallocate(capacity: resultBufferSize)
-#endif
         return base32Encoded
     } else {
-#if swift(>=4.1)
         resultBuffer.deallocate()
-#else
-        resultBuffer.deallocate(capacity: resultBufferSize)
-#endif
         fatalError("internal error")
     }
 }

+ 0 - 20
Sources/Base32/shim.swift

@@ -1,16 +1,5 @@
 import Foundation
 
-#if !swift(>=4.2)
-extension Collection {
-    public func firstIndex(
-        where predicate: (Element) throws -> Bool
-    ) rethrows -> Index? {
-        return try index(where: predicate)
-    }
-}
-#endif
-
-#if swift(>=4.2)
 #if !compiler(>=5)
 extension Data {
     func withUnsafeBytes<Result>(_ apply: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result {
@@ -20,12 +9,3 @@ extension Data {
     }
 }
 #endif
-#else
-extension Data {
-    func withUnsafeBytes<Result>(_ apply: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result {
-        return try withUnsafeBytes {
-            try apply(UnsafeRawBufferPointer(start: $0, count: count))
-        }
-    }
-}
-#endif