Skip to content

Commit 6cf2301

Browse files
fpseverinogwynne
andauthored
Drop Swift 5.10 (#15)
* Update to Swift 6 * Update to Swift Testing * Small touch-ups * Update Tests/ZipTests/ZipTests.swift Co-authored-by: Gwynne Raskind <[email protected]> * Use `isEmpty` instead of `count` * Update Package.swift Co-authored-by: Gwynne Raskind <[email protected]> * Remove Foundation in Package.swift * Update README.md Co-authored-by: Gwynne Raskind <[email protected]> * Update Package.swift Co-authored-by: Gwynne Raskind <[email protected]> * Use `actions/checkout@v5` * Update Windows workflow * Try fixing Windows workflow --------- Co-authored-by: Gwynne Raskind <[email protected]>
1 parent 49e6ec8 commit 6cf2301

File tree

12 files changed

+388
-360
lines changed

12 files changed

+388
-360
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,22 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
swift-version:
26-
- 5.10
2726
- 6.0
2827
- 6.1
28+
- 6.2
2929
include:
30-
- { swift-version: 5.10, swift-branch: swift-5.10.1-release, swift-tag: 5.10.1-RELEASE }
3130
- { swift-version: 6.0, swift-branch: swift-6.0.3-release, swift-tag: 6.0.3-RELEASE }
32-
- { swift-version: 6.1, swift-branch: swift-6.1-release, swift-tag: 6.1-RELEASE }
31+
- { swift-version: 6.1, swift-branch: swift-6.1.3-release, swift-tag: 6.1.3-RELEASE }
32+
- { swift-version: 6.2, swift-branch: swift-6.2-release, swift-tag: 6.2-RELEASE }
3333
runs-on: windows-latest
3434
timeout-minutes: 60
3535
steps:
36-
- name: Configure dev environment
37-
uses: compnerd/gha-setup-vsdevenv@main
38-
with:
39-
toolset_version: 14.29
40-
winsdk: 10.0.22621.0
4136
- name: Install Windows Swift toolchain
4237
uses: compnerd/gha-setup-swift@main
4338
with:
44-
branch: ${{ matrix.swift-branch }}
45-
tag: ${{ matrix.swift-tag }}
39+
swift-version: ${{ matrix.swift-branch }}
40+
swift-build: ${{ matrix.swift-tag }}
41+
update-sdk-modules: true
4642
- name: Download zlib
4743
run: |
4844
curl -L -o zlib.zip https://www.zlib.net/zlib131.zip
@@ -57,7 +53,8 @@ jobs:
5753
cmake --build . --config Release
5854
cmake --install . --prefix ../install
5955
- name: Check out code
60-
uses: actions/checkout@v4
56+
uses: actions/checkout@v5
6157
- name: Run unit tests
6258
run: |
63-
swift test -Xcc -I'C:/Program Files (x86)/zlib/include' -Xcc -D_INTSAFE_H_INCLUDED_ -Xlinker -L'C:/Program Files (x86)/zlib/lib' -Xbuild-tools-swiftc -windows-sdk-root -Xbuild-tools-swiftc "${env:WindowsSdkDir}" -Xbuild-tools-swiftc -windows-sdk-version -Xbuild-tools-swiftc ${env:UCRTVersion} -Xswiftc -windows-sdk-root -Xswiftc "${env:WindowsSdkDir}" -Xswiftc -windows-sdk-version -Xswiftc ${env:UCRTVersion}
59+
swift test -Xcc -I'C:/Program Files (x86)/zlib/include' -Xcc -D_INTSAFE_H_INCLUDED_ -Xlinker -L'C:/Program Files (x86)/zlib/lib'
60+
#-Xbuild-tools-swiftc -windows-sdk-root -Xbuild-tools-swiftc "${env:WindowsSdkDir}" -Xbuild-tools-swiftc -windows-sdk-version -Xbuild-tools-swiftc ${env:UCRTVersion} -Xswiftc -windows-sdk-root -Xswiftc "${env:WindowsSdkDir}" -Xswiftc -windows-sdk-version -Xswiftc ${env:UCRTVersion}

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"indentation": {
66
"spaces": 4
77
},
8-
"indentConditionalCompilationBlocks": true,
8+
"indentConditionalCompilationBlocks": false,
99
"indentSwitchCaseLabels": false,
1010
"lineBreakAroundMultilineExpressionChainComponents": false,
1111
"lineBreakBeforeControlFlowKeywords": false,

Package.swift

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22
import PackageDescription
33

4-
#if canImport(Darwin) || compiler(<6.0)
5-
import Foundation
6-
#else
7-
import FoundationEssentials
8-
#endif
9-
104
let package = Package(
115
name: "Zip",
126
products: [
@@ -45,25 +39,19 @@ let package = Package(
4539

4640
var swiftSettings: [SwiftSetting] {
4741
[
48-
.enableUpcomingFeature("ExistentialAny"),
49-
.enableUpcomingFeature("ConciseMagicFile"),
50-
.enableUpcomingFeature("ForwardTrailingClosures"),
51-
.enableUpcomingFeature("DisableOutwardActorInference"),
52-
.enableUpcomingFeature("StrictConcurrency"),
53-
.enableExperimentalFeature("StrictConcurrency=complete"),
54-
.enableExperimentalFeature("AccessLevelOnImport"),
42+
.enableUpcomingFeature("ExistentialAny")
5543
]
5644
}
5745

58-
if let target = package.targets.filter({ $0.name == "CMinizip" }).first {
46+
if let target = package.targets.first(where: { $0.name == "CMinizip" }) {
5947
#if os(Windows)
60-
if ProcessInfo.processInfo.environment["ZIP_USE_DYNAMIC_ZLIB"] == nil {
61-
target.cSettings?.append(contentsOf: [.define("ZLIB_STATIC")])
62-
target.linkerSettings = [.linkedLibrary("zlibstatic")]
63-
} else {
64-
target.linkerSettings = [.linkedLibrary("zlib")]
65-
}
48+
if Context.environment["ZIP_USE_DYNAMIC_ZLIB"] == nil {
49+
target.cSettings?.append(contentsOf: [.define("ZLIB_STATIC")])
50+
target.linkerSettings = [.linkedLibrary("zlibstatic")]
51+
} else {
52+
target.linkerSettings = [.linkedLibrary("zlib")]
53+
}
6654
#else
67-
target.linkerSettings = [.linkedLibrary("z")]
55+
target.linkerSettings = [.linkedLibrary("z")]
6856
#endif
6957
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<img src="https://img.shields.io/github/actions/workflow/status/vapor-community/Zip/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration">
1010
</a>
1111
<a href="https://codecov.io/github/vapor-community/Zip">
12-
<img src="https://img.shields.io/codecov/c/github/vapor-community/Zip?style=plastic&logo=codecov&label=codecov">
12+
<img src="https://img.shields.io/codecov/c/github/vapor-community/Zip?style=plastic&logo=codecov&label=codecov" alt="Code Coverage">
1313
</a>
1414
<a href="https://swift.org">
15-
<img src="https://design.vapor.codes/images/swift59up.svg" alt="Swift 5.10+">
15+
<img src="https://design.vapor.codes/images/swift60up.svg" alt="Swift 6.0+">
1616
</a>
1717
</div>
1818
<br>
@@ -40,7 +40,7 @@ and add it to your target's dependencies:
4040

4141
### Supported Platforms
4242

43-
Zip supports all platforms supported by Swift 5.10 and later.
43+
Zip supports all platforms supported by Swift 6.0 and later.
4444

4545
To use Zip on Windows, you need to pass an available build of `zlib` to the build via extended flags. For example:
4646

Sources/Zip/Date+dosDate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#if canImport(Darwin) || compiler(<6.0)
2-
import Foundation
1+
#if canImport(FoundationEssentials)
2+
import FoundationEssentials
33
#else
4-
import FoundationEssentials
4+
import Foundation
55
#endif
66

77
extension Date {

Sources/Zip/QuickZip.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
// Copyright © 2016 Roy Marmelstein. All rights reserved.
77
//
88

9-
#if canImport(Darwin) || compiler(<6.0)
10-
import Foundation
9+
#if canImport(FoundationEssentials)
10+
import FoundationEssentials
1111
#else
12-
import FoundationEssentials
12+
import Foundation
1313
#endif
1414

1515
extension Zip {
@@ -23,7 +23,7 @@ extension Zip {
2323
///
2424
/// - Returns: `URL` of the destination folder.
2525
public class func quickUnzipFile(_ path: URL) throws -> URL {
26-
return try quickUnzipFile(path, progress: nil)
26+
try quickUnzipFile(path, progress: nil)
2727
}
2828

2929
/// Unzips a file with less configuration.
@@ -57,7 +57,7 @@ extension Zip {
5757
///
5858
/// - Returns: `URL` of the destination folder.
5959
public class func quickZipFiles(_ paths: [URL], fileName: String) throws -> URL {
60-
return try quickZipFiles(paths, fileName: fileName, progress: nil)
60+
try quickZipFiles(paths, fileName: fileName, progress: nil)
6161
}
6262

6363
/// Zips files with less configuration.

Sources/Zip/URL+nativePath.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#if canImport(Darwin) || compiler(<6.0)
2-
import Foundation
1+
#if canImport(FoundationEssentials)
2+
import FoundationEssentials
33
#else
4-
import FoundationEssentials
4+
import Foundation
55
#endif
66

77
extension URL {
88
var nativePath: String {
9-
return withUnsafeFileSystemRepresentation { String(cString: $0!) }
9+
withUnsafeFileSystemRepresentation { String(cString: $0!) }
1010
}
1111
}

Sources/Zip/Zip.docc/Documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and add it to your target's dependencies:
3131

3232
### Supported Platforms
3333

34-
Zip supports all platforms supported by Swift 5.10 and later.
34+
Zip supports all platforms supported by Swift 6.0 and later.
3535

3636
To use Zip on Windows, you need to pass an available build of `zlib` to the build via extended flags. For example:
3737

Sources/Zip/Zip.swift

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class Zip {
6666
}
6767

6868
#if os(Windows)
69-
var fileNames = Set<String>()
69+
var fileNames = Set<String>()
7070
#endif
7171

7272
var buffer = [CUnsignedChar](repeating: 0, count: 4096)
@@ -101,23 +101,23 @@ public class Zip {
101101
var pathString = String(cString: fileName)
102102

103103
#if os(Windows)
104-
// Windows Reserved Characters
105-
let reservedCharacters: CharacterSet = ["<", ">", ":", "\"", "|", "?", "*"]
106-
107-
if pathString.rangeOfCharacter(from: reservedCharacters) != nil {
108-
pathString = pathString.components(separatedBy: reservedCharacters).joined(separator: "_")
109-
110-
let pathExtension = (pathString as NSString).pathExtension
111-
let pathWithoutExtension = (pathString as NSString).deletingPathExtension
112-
var counter = 1
113-
while fileNames.contains(pathString) {
114-
let newFileName = "\(pathWithoutExtension) (\(counter))"
115-
pathString = pathExtension.isEmpty ? newFileName : newFileName.appendingPathExtension(pathExtension) ?? newFileName
116-
counter += 1
117-
}
104+
// Windows Reserved Characters
105+
let reservedCharacters: CharacterSet = ["<", ">", ":", "\"", "|", "?", "*"]
106+
107+
if pathString.rangeOfCharacter(from: reservedCharacters) != nil {
108+
pathString = pathString.components(separatedBy: reservedCharacters).joined(separator: "_")
109+
110+
let pathExtension = (pathString as NSString).pathExtension
111+
let pathWithoutExtension = (pathString as NSString).deletingPathExtension
112+
var counter = 1
113+
while fileNames.contains(pathString) {
114+
let newFileName = "\(pathWithoutExtension) (\(counter))"
115+
pathString = pathExtension.isEmpty ? newFileName : newFileName.appendingPathExtension(pathExtension) ?? newFileName
116+
counter += 1
118117
}
118+
}
119119

120-
fileNames.insert(pathString)
120+
fileNames.insert(pathString)
121121
#endif
122122

123123
guard !pathString.isEmpty else {
@@ -136,16 +136,11 @@ public class Zip {
136136
throw ZipError.unzipFail
137137
}
138138

139-
let directoryAttributes: [FileAttributeKey: Any]?
140-
#if (os(Linux) || os(Windows)) && compiler(<6.0)
141-
directoryAttributes = nil
142-
#else
143-
let creationDate = Date()
144-
directoryAttributes = [
145-
.creationDate: creationDate,
146-
.modificationDate: creationDate,
147-
]
148-
#endif
139+
let creationDate = Date()
140+
let directoryAttributes: [FileAttributeKey: Any]? = [
141+
.creationDate: creationDate,
142+
.modificationDate: creationDate,
143+
]
149144

150145
let isDirectory =
151146
fileName[Int(fileInfo.size_filename - 1)] == "/".cString(using: String.Encoding.utf8)?.first

Sources/Zip/ZipCompression.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ public enum ZipCompression: Int {
99

1010
internal var minizipCompression: Int32 {
1111
switch self {
12-
case .NoCompression:
13-
return Z_NO_COMPRESSION
14-
case .BestSpeed:
15-
return Z_BEST_SPEED
16-
case .DefaultCompression:
17-
return Z_DEFAULT_COMPRESSION
18-
case .BestCompression:
19-
return Z_BEST_COMPRESSION
12+
case .NoCompression: Z_NO_COMPRESSION
13+
case .BestSpeed: Z_BEST_SPEED
14+
case .DefaultCompression: Z_DEFAULT_COMPRESSION
15+
case .BestCompression: Z_BEST_COMPRESSION
2016
}
2117
}
2218
}

0 commit comments

Comments
 (0)