Skip to content

Commit 17c0afb

Browse files
authored
Update for new NIOSSL (#132)
* Bump to Swift 5.6 minimum and update README * The usual CI cleanup * Require a more recent NIO, switch to NIOCore instead of NIO, use EventLoopGroup.any() instead of .next(), make EventLoopGroupProvider an alias for NIO's version, use annotated exports * Ditch unneeded Concurrency checks (which also incidentally enables back-deployment to 10.15) * Update SSLTestHelpers to reflect the current state of the original upstream (which basically just means using OpaquePointer instead of UMP<EVP_PKEY>, partly because EVP_PKEY is no longer visible from CNIOBoringSSL * Add API breakage allowlist for this branch * Add test coverage for all the connect methods, binary frames, and ping intervals.
1 parent 2166cbe commit 17c0afb

17 files changed

+627
-471
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
API breakage: import NIO has been renamed to import NIOCore
2+
API breakage: import NIO has been renamed to import NIOPosix
3+

.github/workflows/main-codecov.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/projectboard.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,7 @@ on:
55
types: [reopened, closed, labeled, unlabeled, assigned, unassigned]
66

77
jobs:
8-
setup_matrix_input:
9-
runs-on: ubuntu-latest
10-
11-
steps:
12-
- id: set-matrix
13-
run: |
14-
output=$(curl ${{ github.event.issue.url }}/labels | jq '.[] | .name') || output=""
15-
16-
echo '======================'
17-
echo 'Process incoming data'
18-
echo '======================'
19-
json=$(echo $output | sed 's/"\s"/","/g')
20-
echo $json
21-
echo "::set-output name=matrix::$(echo $json)"
22-
outputs:
23-
issueTags: ${{ steps.set-matrix.outputs.matrix }}
24-
25-
Manage_project_issues:
26-
needs: setup_matrix_input
27-
uses: vapor/ci/.github/workflows/issues-to-project-board.yml@main
28-
with:
29-
labelsJson: ${{ needs.setup_matrix_input.outputs.issueTags }}
30-
secrets:
31-
PROJECT_BOARD_AUTOMATION_PAT: "${{ secrets.PROJECT_BOARD_AUTOMATION_PAT }}"
8+
update_project_boards:
9+
name: Update project boards
10+
uses: vapor/ci/.github/workflows/update-project-boards-for-issue.yml@reusable-workflows
11+
secrets: inherit

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
name: test
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
25
on:
3-
- pull_request
6+
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
7+
push: { branches: [ main ] }
8+
49
jobs:
10+
511
vapor-integration:
12+
if: ${{ !(github.event.pull_request.draft || false) }}
613
runs-on: ubuntu-latest
7-
container:
8-
image: swift:5.7
14+
container: swift:5.8-jammy
915
steps:
1016
- name: Check out package
1117
uses: actions/checkout@v3
@@ -14,8 +20,7 @@ jobs:
1420
uses: actions/checkout@v3
1521
with: { repository: 'vapor/vapor', path: 'vapor' }
1622
- name: Use local package in Vapor
17-
run: |
18-
swift package --package-path vapor edit websocket-kit --path websocket-kit
23+
run: swift package --package-path vapor edit websocket-kit --path websocket-kit
1924
- name: Run Vapor tests
2025
run: swift test --package-path vapor
2126

@@ -24,6 +29,4 @@ jobs:
2429
with:
2530
with_coverage: true
2631
with_tsan: false
27-
coverage_ignores: '/Tests/'
2832
with_public_api_check: ${{ github.event_name == 'pull_request' }}
29-

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version:5.6
22
import PackageDescription
33

44
let package = Package(
55
name: "websocket-kit",
66
platforms: [
77
.macOS(.v10_15),
88
.iOS(.v13),
9+
.watchOS(.v6),
910
.tvOS(.v13),
1011
],
1112
products: [
1213
.library(name: "WebSocketKit", targets: ["WebSocketKit"]),
1314
],
1415
dependencies: [
15-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.33.0"),
16+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.53.0"),
1617
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.16.0"),
17-
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.14.0"),
18+
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.24.0"),
1819
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.11.4"),
1920
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
2021
],
2122
targets: [
2223
.target(name: "WebSocketKit", dependencies: [
23-
.product(name: "NIO", package: "swift-nio"),
2424
.product(name: "NIOCore", package: "swift-nio"),
2525
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
2626
.product(name: "NIOExtras", package: "swift-nio-extras"),

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
<a href="LICENSE">
1616
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
1717
</a>
18-
<a href="https://github.com/vapor/websocket-kit/actions">
19-
<img src="https://github.com/vapor/websocket-kit/workflows/test/badge.svg" alt="Continuous Integration">
18+
<a href="https://github.com/vapor/websocket-kit/actions/workflows/test.yml">
19+
<img src="https://github.com/vapor/websocket-kit/actions/workflows/test.yml/badge.svg?event=push" alt="Continuous Integration">
2020
</a>
2121
<a href="https://swift.org">
22-
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
22+
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6">
23+
</a>
24+
<a href="https://swift.org">
25+
<img src="http://img.shields.io/badge/swift-5.8-brightgreen.svg" alt="Swift 5.8">
2326
</a>
2427
</p>

Sources/WebSocketKit/Concurrency/WebSocket+Concurrency.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#if compiler(>=5.5) && canImport(_Concurrency)
21
import NIOCore
32
import NIOWebSocket
43
import Foundation
54
import NIOHTTP1
65

7-
@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *)
86
extension WebSocket {
97
public func send<S>(_ text: S) async throws
108
where S: Collection, S.Element == Character
@@ -142,5 +140,3 @@ extension WebSocket {
142140
).get()
143141
}
144142
}
145-
146-
#endif

Sources/WebSocketKit/Exports.swift

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
#if !BUILDING_DOCC
1+
#if swift(>=5.8)
22

3-
@_exported import struct NIO.ByteBuffer
4-
@_exported import protocol NIO.Channel
5-
@_exported import protocol NIO.EventLoop
6-
@_exported import protocol NIO.EventLoopGroup
7-
@_exported import struct NIO.EventLoopPromise
8-
@_exported import class NIO.EventLoopFuture
3+
@_documentation(visibility: internal) @_exported import struct NIOCore.ByteBuffer
4+
@_documentation(visibility: internal) @_exported import protocol NIOCore.Channel
5+
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop
6+
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoopGroup
7+
@_documentation(visibility: internal) @_exported import struct NIOCore.EventLoopPromise
8+
@_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture
9+
10+
@_documentation(visibility: internal) @_exported import struct NIOHTTP1.HTTPHeaders
11+
12+
@_documentation(visibility: internal) @_exported import struct Foundation.URL
13+
14+
#else
15+
16+
@_exported import struct NIOCore.ByteBuffer
17+
@_exported import protocol NIOCore.Channel
18+
@_exported import protocol NIOCore.EventLoop
19+
@_exported import protocol NIOCore.EventLoopGroup
20+
@_exported import struct NIOCore.EventLoopPromise
21+
@_exported import class NIOCore.EventLoopFuture
922

1023
@_exported import struct NIOHTTP1.HTTPHeaders
1124

1225
@_exported import struct Foundation.URL
1326

14-
#endif
27+
#endif

Sources/WebSocketKit/HTTPUpgradeRequestHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import NIO
1+
import NIOCore
22
import NIOHTTP1
33

44
final class HTTPUpgradeRequestHandler: ChannelInboundHandler, RemovableChannelHandler {

Sources/WebSocketKit/WebSocket+Connect.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension WebSocket {
2020
onUpgrade: @escaping (WebSocket) -> ()
2121
) -> EventLoopFuture<Void> {
2222
guard let url = URL(string: url) else {
23-
return eventLoopGroup.next().makeFailedFuture(WebSocketClient.Error.invalidURL)
23+
return eventLoopGroup.any().makeFailedFuture(WebSocketClient.Error.invalidURL)
2424
}
2525
return self.connect(
2626
to: url,
@@ -174,7 +174,7 @@ extension WebSocket {
174174
onUpgrade: @escaping (WebSocket) -> ()
175175
) -> EventLoopFuture<Void> {
176176
guard let url = URL(string: url) else {
177-
return eventLoopGroup.next().makeFailedFuture(WebSocketClient.Error.invalidURL)
177+
return eventLoopGroup.any().makeFailedFuture(WebSocketClient.Error.invalidURL)
178178
}
179179
let scheme = url.scheme ?? "ws"
180180
return self.connect(

0 commit comments

Comments
 (0)