Skip to content

Commit b57bcb9

Browse files
authored
Raise minimum supported Swift version from 5.4 to 5.5 (#630)
Motivation: SwiftNIO periodically drops support for older Swift versions. Now that 5.7 has been released, 5.4 will be dropped. Modifications: - Remove 5.4 specific Package.swift and docker-compose - Update the 5.7 docker-compose to use the released 5.7 and move from focal (2004) to jammy (2204) - Update tools version in [email protected] to 5.5 (from 5.4) - Add supported versions section to README Results: Minimum Swift version is 5.5
1 parent 03b3e7b commit b57bcb9

9 files changed

+96
-166
lines changed

[email protected]

-73
This file was deleted.

[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version:5.5
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the AsyncHTTPClient open source project

README.md

+26-15
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ httpClient.execute(request: request, deadline: .now() + .milliseconds(1))
152152
```
153153

154154
### Streaming
155-
When dealing with larger amount of data, it's critical to stream the response body instead of aggregating in-memory.
155+
When dealing with larger amount of data, it's critical to stream the response body instead of aggregating in-memory.
156156
The following example demonstrates how to count the number of bytes in a streaming response body:
157157

158158
#### Using Swift Concurrency
@@ -172,7 +172,7 @@ do {
172172
for try await buffer in response.body {
173173
// for this example, we are just interested in the size of the fragment
174174
receivedBytes += buffer.readableBytes
175-
175+
176176
if let expectedBytes = expectedBytes {
177177
// if the body size is known, we calculate a progress indicator
178178
let progress = Double(receivedBytes) / Double(expectedBytes)
@@ -181,9 +181,9 @@ do {
181181
}
182182
print("did receive \(receivedBytes) bytes")
183183
} catch {
184-
print("request failed:", error)
184+
print("request failed:", error)
185185
}
186-
// it is important to shutdown the httpClient after all requests are done, even if one failed
186+
// it is important to shutdown the httpClient after all requests are done, even if one failed
187187
try await httpClient.shutdown()
188188
```
189189

@@ -211,17 +211,17 @@ class CountingDelegate: HTTPClientResponseDelegate {
211211
}
212212

213213
func didReceiveHead(
214-
task: HTTPClient.Task<Response>,
214+
task: HTTPClient.Task<Response>,
215215
_ head: HTTPResponseHead
216216
) -> EventLoopFuture<Void> {
217-
// this is executed when we receive HTTP response head part of the request
218-
// (it contains response code and headers), called once in case backpressure
217+
// this is executed when we receive HTTP response head part of the request
218+
// (it contains response code and headers), called once in case backpressure
219219
// is needed, all reads will be paused until returned future is resolved
220220
return task.eventLoop.makeSucceededFuture(())
221221
}
222222

223223
func didReceiveBodyPart(
224-
task: HTTPClient.Task<Response>,
224+
task: HTTPClient.Task<Response>,
225225
_ buffer: ByteBuffer
226226
) -> EventLoopFuture<Void> {
227227
// this is executed when we receive parts of the response body, could be called zero or more times
@@ -283,8 +283,8 @@ Connecting to servers bound to socket paths is easy:
283283
```swift
284284
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
285285
httpClient.execute(
286-
.GET,
287-
socketPath: "/tmp/myServer.socket",
286+
.GET,
287+
socketPath: "/tmp/myServer.socket",
288288
urlPath: "/path/to/resource"
289289
).whenComplete (...)
290290
```
@@ -293,21 +293,21 @@ Connecting over TLS to a unix domain socket path is possible as well:
293293
```swift
294294
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
295295
httpClient.execute(
296-
.POST,
297-
secureSocketPath: "/tmp/myServer.socket",
298-
urlPath: "/path/to/resource",
296+
.POST,
297+
secureSocketPath: "/tmp/myServer.socket",
298+
urlPath: "/path/to/resource",
299299
body: .string("hello")
300300
).whenComplete (...)
301301
```
302302

303303
Direct URLs can easily be constructed to be executed in other scenarios:
304304
```swift
305305
let socketPathBasedURL = URL(
306-
httpURLWithSocketPath: "/tmp/myServer.socket",
306+
httpURLWithSocketPath: "/tmp/myServer.socket",
307307
uri: "/path/to/resource"
308308
)
309309
let secureSocketPathBasedURL = URL(
310-
httpsURLWithSocketPath: "/tmp/myServer.socket",
310+
httpsURLWithSocketPath: "/tmp/myServer.socket",
311311
uri: "/path/to/resource"
312312
)
313313
```
@@ -326,3 +326,14 @@ let client = HTTPClient(
326326
## Security
327327

328328
Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security process.
329+
330+
## Supported Versions
331+
332+
The most recent versions of AsyncHTTPClient support Swift 5.5 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:
333+
334+
AsyncHTTPClient | Minimum Swift Version
335+
--------------------|----------------------
336+
`1.0.0 ..< 1.5.0` | 5.0
337+
`1.5.0 ..< 1.10.0` | 5.2
338+
`1.10.0 ..< 1.13.0` | 5.4
339+
`1.13.0 ...` | 5.5

Tests/LinuxMain.swift

+41-36
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,45 @@ import XCTest
2525
#if os(Linux) || os(FreeBSD)
2626
@testable import AsyncHTTPClientTests
2727

28-
XCTMain([
29-
testCase(AsyncAwaitEndToEndTests.allTests),
30-
testCase(HTTP1ClientChannelHandlerTests.allTests),
31-
testCase(HTTP1ConnectionStateMachineTests.allTests),
32-
testCase(HTTP1ConnectionTests.allTests),
33-
testCase(HTTP1ProxyConnectHandlerTests.allTests),
34-
testCase(HTTP2ClientRequestHandlerTests.allTests),
35-
testCase(HTTP2ClientTests.allTests),
36-
testCase(HTTP2ConnectionTests.allTests),
37-
testCase(HTTP2IdleHandlerTests.allTests),
38-
testCase(HTTPClientCookieTests.allTests),
39-
testCase(HTTPClientInternalTests.allTests),
40-
testCase(HTTPClientNIOTSTests.allTests),
41-
testCase(HTTPClientReproTests.allTests),
42-
testCase(HTTPClientRequestTests.allTests),
43-
testCase(HTTPClientSOCKSTests.allTests),
44-
testCase(HTTPClientTests.allTests),
45-
testCase(HTTPClientUncleanSSLConnectionShutdownTests.allTests),
46-
testCase(HTTPConnectionPoolTests.allTests),
47-
testCase(HTTPConnectionPool_FactoryTests.allTests),
48-
testCase(HTTPConnectionPool_HTTP1ConnectionsTests.allTests),
49-
testCase(HTTPConnectionPool_HTTP1StateMachineTests.allTests),
50-
testCase(HTTPConnectionPool_HTTP2ConnectionsTests.allTests),
51-
testCase(HTTPConnectionPool_HTTP2StateMachineTests.allTests),
52-
testCase(HTTPConnectionPool_ManagerTests.allTests),
53-
testCase(HTTPConnectionPool_RequestQueueTests.allTests),
54-
testCase(HTTPRequestStateMachineTests.allTests),
55-
testCase(LRUCacheTests.allTests),
56-
testCase(RequestBagTests.allTests),
57-
testCase(RequestValidationTests.allTests),
58-
testCase(SOCKSEventsHandlerTests.allTests),
59-
testCase(SSLContextCacheTests.allTests),
60-
testCase(TLSEventsHandlerTests.allTests),
61-
testCase(TransactionTests.allTests),
62-
testCase(Transaction_StateMachineTests.allTests),
63-
])
28+
@main
29+
struct LinuxMain {
30+
static func main() {
31+
XCTMain([
32+
testCase(AsyncAwaitEndToEndTests.allTests),
33+
testCase(HTTP1ClientChannelHandlerTests.allTests),
34+
testCase(HTTP1ConnectionStateMachineTests.allTests),
35+
testCase(HTTP1ConnectionTests.allTests),
36+
testCase(HTTP1ProxyConnectHandlerTests.allTests),
37+
testCase(HTTP2ClientRequestHandlerTests.allTests),
38+
testCase(HTTP2ClientTests.allTests),
39+
testCase(HTTP2ConnectionTests.allTests),
40+
testCase(HTTP2IdleHandlerTests.allTests),
41+
testCase(HTTPClientCookieTests.allTests),
42+
testCase(HTTPClientInternalTests.allTests),
43+
testCase(HTTPClientNIOTSTests.allTests),
44+
testCase(HTTPClientReproTests.allTests),
45+
testCase(HTTPClientRequestTests.allTests),
46+
testCase(HTTPClientSOCKSTests.allTests),
47+
testCase(HTTPClientTests.allTests),
48+
testCase(HTTPClientUncleanSSLConnectionShutdownTests.allTests),
49+
testCase(HTTPConnectionPoolTests.allTests),
50+
testCase(HTTPConnectionPool_FactoryTests.allTests),
51+
testCase(HTTPConnectionPool_HTTP1ConnectionsTests.allTests),
52+
testCase(HTTPConnectionPool_HTTP1StateMachineTests.allTests),
53+
testCase(HTTPConnectionPool_HTTP2ConnectionsTests.allTests),
54+
testCase(HTTPConnectionPool_HTTP2StateMachineTests.allTests),
55+
testCase(HTTPConnectionPool_ManagerTests.allTests),
56+
testCase(HTTPConnectionPool_RequestQueueTests.allTests),
57+
testCase(HTTPRequestStateMachineTests.allTests),
58+
testCase(LRUCacheTests.allTests),
59+
testCase(RequestBagTests.allTests),
60+
testCase(RequestValidationTests.allTests),
61+
testCase(SOCKSEventsHandlerTests.allTests),
62+
testCase(SSLContextCacheTests.allTests),
63+
testCase(TLSEventsHandlerTests.allTests),
64+
testCase(TransactionTests.allTests),
65+
testCase(Transaction_StateMachineTests.allTests),
66+
])
67+
}
68+
}
6469
#endif

docker/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG swift_version=5.4
2-
ARG ubuntu_version=bionic
1+
ARG swift_version=5.7
2+
ARG ubuntu_version=jammy
33
ARG base_image=swift:$swift_version-$ubuntu_version
44
FROM $base_image
55
# needed to do again after FROM due to docker limitation

docker/docker-compose.1804.54.yaml

-19
This file was deleted.

docker/docker-compose.2004.57.yaml

-17
This file was deleted.

docker/docker-compose.2204.57.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: async-http-client:22.04-5.7
7+
build:
8+
args:
9+
ubuntu_version: "jammy"
10+
swift_version: "5.7"
11+
12+
test:
13+
image: async-http-client:22.04-5.7
14+
environment: []
15+
#- SANITIZER_ARG=--sanitize=thread
16+
17+
shell:
18+
image: async-http-client:22.04-5.7

scripts/generate_linux_tests.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
9999
file.write '@testable import ' + testSubDirectory + "\n"
100100
end
101101
file.write "\n"
102-
file.write "XCTMain([\n"
102+
file.write "@main\n"
103+
file.write "struct LinuxMain {\n"
104+
file.write " static func main() {\n"
105+
file.write " XCTMain([\n"
103106

104107
testCases = []
105108
for classes in files
@@ -109,9 +112,11 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
109112
end
110113

111114
for testCase in testCases.sort { |x, y| x <=> y }
112-
file.write ' testCase(' + testCase + ".allTests),\n"
115+
file.write ' testCase(' + testCase + ".allTests),\n"
113116
end
114-
file.write "])\n"
117+
file.write " ])\n"
118+
file.write " }\n"
119+
file.write "}\n"
115120
file.write "#endif\n"
116121
end
117122
end

0 commit comments

Comments
 (0)