Skip to content

Commit 4dd6c81

Browse files
authored
travis: update CI environments (#202)
* travis: update CI environments * Add BlueSocketTestCommonLibrary, BlueSocketTestClient, BlueSocketTestServer - Add a library component to make it easier to do tests and profiling under streaming loads (multiple client connections, lots of data, etc.) * Removed Swift 4.x, bumped minimum swift version requirement to 5.1 * keep build at Swift 5.0; update CI to only test from 5.1.5 on up * Only attempt to build command-line for Swift 5.2+ * Ensure tools and dependencies only build for Swift 5.2+ * Address various lint errors * Update README with version details and latest iOS related issues
1 parent 7cedc53 commit 4dd6c81

18 files changed

Lines changed: 797 additions & 98 deletions

.swiftlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ disabled_rules:
55
- trailing_newline
66
- force_cast
77
- function_body_length
8-
- variable_name
8+
- identifier_name
99
- line_length
1010
- trailing_whitespace
1111
- type_name

.travis.yml

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,32 @@ matrix:
1515
dist: xenial
1616
sudo: required
1717
services: docker
18-
env: DOCKER_IMAGE=swift:4.0.3 SWIFT_SNAPSHOT=4.0.3
18+
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu16.04:5.1.5 SWIFT_SNAPSHOT=5.1.5
1919
- os: linux
20-
dist: xenial
21-
sudo: required
22-
services: docker
23-
env: DOCKER_IMAGE=swift:4.1.3 SWIFT_SNAPSHOT=4.1.3
24-
- os: linux
25-
dist: xenial
26-
sudo: required
27-
services: docker
28-
env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
29-
- os: linux
30-
dist: xenial
31-
sudo: required
32-
services: docker
33-
env: DOCKER_IMAGE=swift:5.0.3-xenial SWIFT_SNAPSHOT=5.0.3
34-
- os: linux
35-
dist: xenial
20+
dist: bionic
3621
sudo: required
3722
services: docker
38-
env: DOCKER_IMAGE=swift:5.1
23+
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.4 SWIFT_SNAPSHOT=5.4
3924
- os: linux
4025
dist: xenial
4126
sudo: required
4227
services: docker
43-
env: DOCKER_IMAGE=swift:5.1 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
44-
- os: osx
45-
osx_image: xcode9.2
46-
sudo: required
47-
env: SWIFT_SNAPSHOT=4.0.3
48-
- os: osx
49-
osx_image: xcode9.4
50-
sudo: required
51-
env: SWIFT_SNAPSHOT=4.1.2
28+
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:latest SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
5229
- os: osx
53-
osx_image: xcode10.1
30+
osx_image: xcode11
5431
sudo: required
55-
env: SWIFT_SNAPSHOT=4.2.1
32+
env: SWIFT_SNAPSHOT=5.1.5 JAZZY_ELIGIBLE=true
5633
- os: osx
57-
osx_image: xcode10.2
34+
osx_image: xcode12.2
5835
sudo: required
59-
env: SWIFT_SNAPSHOT=5.0.1 JAZZY_ELIGIBLE=true
36+
#env: SWIFT_SNAPSHOT=5.1.5
6037
- os: osx
61-
osx_image: xcode11
62-
sudo: required
63-
- os: osx
64-
osx_image: xcode11
38+
osx_image: xcode12.5
6539
sudo: required
6640
env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
6741

6842
before_install:
69-
- git clone https://github.com/IBM-Swift/Package-Builder.git
43+
- git clone https://github.com/Kitura/Package-Builder.git
7044

7145
script:
7246
- ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR

Package.swift

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@
1818

1919
import PackageDescription
2020

21-
#if os(Linux) || os(macOS) || os(iOS) || os(tvOS)
22-
let package = Package(
23-
name: "Socket",
24-
products: [
21+
struct BuildInfo {
22+
let product: [Product]
23+
let dependencies: [Package.Dependency]
24+
let targets: [Target]
25+
}
26+
27+
28+
let libraryBuildInfo = BuildInfo(
29+
product: [
2530
.library(
2631
name: "Socket",
2732
targets: ["Socket"]),
33+
34+
.library(
35+
name: "BlueSocketTestCommonLibrary",
36+
targets: ["BlueSocketTestCommonLibrary"]),
2837
],
2938
dependencies: [],
3039
targets: [
@@ -35,10 +44,74 @@ let package = Package(
3544
),
3645
.testTarget(
3746
name: "SocketTests",
38-
dependencies: ["Socket"]
47+
dependencies: ["Socket", "BlueSocketTestCommonLibrary"]
48+
),
49+
50+
.target(
51+
name: "BlueSocketTestCommonLibrary",
52+
dependencies: [ "Socket" ]
3953
),
4054
]
4155
)
56+
57+
let toolsBuildInfo = BuildInfo(
58+
product: [
59+
.executable(
60+
name: "BlueSocketTestServer",
61+
targets: ["BlueSocketTestServer"]),
62+
.executable(
63+
name: "BlueSocketTestClient",
64+
targets: ["BlueSocketTestClient"]),
65+
],
66+
dependencies: [
67+
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.1"),
68+
],
69+
targets: [
70+
.target(name: "BlueSocketTestServer",
71+
dependencies: ["BlueSocketTestCommonLibrary", "ArgumentParser", ]
72+
),
73+
.target(name: "BlueSocketTestClient",
74+
dependencies: ["BlueSocketTestCommonLibrary", "ArgumentParser" ]
75+
),
76+
]
77+
)
78+
79+
var products: [Product] = [
80+
.library(
81+
name: "Socket",
82+
targets: ["Socket"]),
83+
84+
.library(
85+
name: "BlueSocketTestCommonLibrary",
86+
targets: ["BlueSocketTestCommonLibrary"]),
87+
]
88+
#if swift(>=5.2)
89+
products.append(contentsOf: [
90+
.executable(
91+
name: "BlueSocketTestServer",
92+
targets: ["BlueSocketTestServer"]),
93+
.executable(
94+
name: "BlueSocketTestClient",
95+
targets: ["BlueSocketTestClient"])
96+
])
97+
#endif
98+
99+
let buildInfo: BuildInfo
100+
#if swift(>=5.2)
101+
buildInfo = BuildInfo(product: libraryBuildInfo.product + toolsBuildInfo.product,
102+
dependencies: libraryBuildInfo.dependencies + toolsBuildInfo.dependencies,
103+
targets: libraryBuildInfo.targets + toolsBuildInfo.targets)
104+
#else
105+
buildInfo = BuildInfo(product: libraryBuildInfo.product, dependencies: libraryBuildInfo.dependencies, targets: libraryBuildInfo.targets)
106+
#endif
107+
108+
#if os(Linux) || os(macOS) || os(iOS) || os(tvOS)
109+
let package = Package(
110+
name: "Socket",
111+
products: buildInfo.product,
112+
dependencies: buildInfo.dependencies,
113+
targets: buildInfo.targets
114+
)
42115
#else
43116
fatalError("Unsupported OS")
44117
#endif

Package@swift-4.swift

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

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,36 @@ Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS,
2222

2323
### Swift
2424

25-
* Swift Open Source `swift-4.0.0-RELEASE` toolchain (**Minimum REQUIRED for latest release**)
26-
* Swift Open Source `swift-4.2-RELEASE` toolchain (**Recommended**)
27-
* Swift toolchain included in *Xcode Version 10.0 (10A255) or higher*.
25+
* Swift Open Source `swift-5.1-RELEASE` toolchain (**Minimum REQUIRED for latest release**)
26+
* Swift Open Source `swift-5.4-RELEASE` toolchain (**Recommended**)
27+
* Swift toolchain included in *Xcode Version 12.5 (12E262) or higher*.
2828

2929
### macOS
3030

3131
* macOS 10.11.6 (*El Capitan*) or higher.
32-
* Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
33-
* Xcode Version 10.0 (10A255) or higher using the included toolchain (*Recommended*).
32+
* Xcode Version 11 or higher using one of the above toolchains.
33+
* Xcode Version 12 or higher using the included toolchain (*Recommended*).
3434

3535
### iOS
3636

3737
* iOS 10.0 or higher
38-
* Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
39-
* Xcode Version 10.0 (10A255) or higher using the included toolchain (*Recommended*).
38+
* Xcode Version 11 or higher using one of the above toolchains.
39+
* Xcode Version 12 or higher using the included toolchain (*Recommended*).
40+
41+
Note:
42+
43+
If creating a UDP server on iOS, you may need to follow a few steps:
44+
45+
* [Request multicast entitlement from Apple ](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast
46+
)
47+
* Add the Multicast Network capability to your App identifier
48+
* For more details, see discussion in [Issue 194](https://github.com/Kitura/BlueSocket/issues/194)
49+
4050

4151
### Linux
4252

43-
* Ubuntu 16.04 (or 16.10 but only tested on 16.04).
44-
* One of the Swift Open Source toolchain listed above.
53+
* Ubuntu 16.04 or 18.04
54+
* One of the Swift Open Source toolchains listed above.
4555

4656
### Other Platforms
4757

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// main.swift
3+
// BlueSocket
4+
//
5+
// Created by Sung, Danny on 2021-04-12.
6+
// Copyright © 2021 Kitura project. All rights reserved.
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
import Foundation
22+
import ArgumentParser
23+
import BlueSocketTestCommonLibrary
24+
25+
let defaultPort = 10217
26+
let defaultMaxBytes = 1_000_000
27+
let defaultNumConnections = 1
28+
29+
struct TestClient: ParsableCommand {
30+
@Option(name: [.customShort("p"), .customLong("port")], help: "TCP Port to connect to (Default: \(defaultPort))")
31+
var port: Int = defaultPort
32+
33+
@Option(name: [.customShort("b"), .customLong("bytes")], help: "Number of bytes to send (Default: \(defaultMaxBytes))")
34+
var maxBytes: Int = defaultMaxBytes
35+
36+
@Option(name: [.customShort("c"), .customLong("connections")], help: "Number of simultaneous connections (Default: \(defaultNumConnections))")
37+
var numConnections: Int = defaultNumConnections
38+
39+
func run() throws {
40+
print("Connecting to port: \(port)")
41+
42+
var clientList: [ClientController] = []
43+
44+
for _ in 0..<numConnections {
45+
let client = try ClientController(port: port, maxBytes: maxBytes)
46+
clientList.append(client)
47+
}
48+
49+
while clientList.activeClients.count > 0 {
50+
clientList.process()
51+
}
52+
53+
for client in clientList {
54+
print("Wrote \(client.bytesWritten) bytes Read \(client.bytesRead) bytes")
55+
print("\(client.state)")
56+
}
57+
}
58+
}
59+
60+
TestClient.main()
61+
62+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Array+ClientController.swift
3+
// BlueSocket
4+
//
5+
// Created by Sung, Danny on 2021-04-12.
6+
// Copyright © 2021 Kitura project. All rights reserved.
7+
//
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
import Foundation
22+
23+
public extension Array where Element == ClientController {
24+
var activeClients: [ClientController] {
25+
self.filter { !$0.isDone }
26+
}
27+
28+
func process() {
29+
self.forEach { $0.process() }
30+
}
31+
32+
var hasFailures: Bool {
33+
let failedClients = self.filter { $0.isFailed }
34+
return failedClients.count > 0
35+
}
36+
}

0 commit comments

Comments
 (0)