Skip to content

Commit

Permalink
travis: update CI environments (#202)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dannys42 committed Jun 17, 2021
1 parent 7cedc53 commit 4dd6c81
Show file tree
Hide file tree
Showing 18 changed files with 797 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ disabled_rules:
- trailing_newline
- force_cast
- function_body_length
- variable_name
- identifier_name
- line_length
- trailing_whitespace
- type_name
Expand Down
46 changes: 10 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,32 @@ matrix:
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:4.0.3 SWIFT_SNAPSHOT=4.0.3
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu16.04:5.1.5 SWIFT_SNAPSHOT=5.1.5
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:4.1.3 SWIFT_SNAPSHOT=4.1.3
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:5.0.3-xenial SWIFT_SNAPSHOT=5.0.3
- os: linux
dist: xenial
dist: bionic
sudo: required
services: docker
env: DOCKER_IMAGE=swift:5.1
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:5.4 SWIFT_SNAPSHOT=5.4
- os: linux
dist: xenial
sudo: required
services: docker
env: DOCKER_IMAGE=swift:5.1 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
- os: osx
osx_image: xcode9.2
sudo: required
env: SWIFT_SNAPSHOT=4.0.3
- os: osx
osx_image: xcode9.4
sudo: required
env: SWIFT_SNAPSHOT=4.1.2
env: DOCKER_IMAGE=docker.kitura.net/kitura/swift-ci-ubuntu18.04:latest SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
- os: osx
osx_image: xcode10.1
osx_image: xcode11
sudo: required
env: SWIFT_SNAPSHOT=4.2.1
env: SWIFT_SNAPSHOT=5.1.5 JAZZY_ELIGIBLE=true
- os: osx
osx_image: xcode10.2
osx_image: xcode12.2
sudo: required
env: SWIFT_SNAPSHOT=5.0.1 JAZZY_ELIGIBLE=true
#env: SWIFT_SNAPSHOT=5.1.5
- os: osx
osx_image: xcode11
sudo: required
- os: osx
osx_image: xcode11
osx_image: xcode12.5
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT

before_install:
- git clone https://github.com/IBM-Swift/Package-Builder.git
- git clone https://github.com/Kitura/Package-Builder.git

script:
- ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR
83 changes: 78 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@

import PackageDescription

#if os(Linux) || os(macOS) || os(iOS) || os(tvOS)
let package = Package(
name: "Socket",
products: [
struct BuildInfo {
let product: [Product]
let dependencies: [Package.Dependency]
let targets: [Target]
}


let libraryBuildInfo = BuildInfo(
product: [
.library(
name: "Socket",
targets: ["Socket"]),

.library(
name: "BlueSocketTestCommonLibrary",
targets: ["BlueSocketTestCommonLibrary"]),
],
dependencies: [],
targets: [
Expand All @@ -35,10 +44,74 @@ let package = Package(
),
.testTarget(
name: "SocketTests",
dependencies: ["Socket"]
dependencies: ["Socket", "BlueSocketTestCommonLibrary"]
),

.target(
name: "BlueSocketTestCommonLibrary",
dependencies: [ "Socket" ]
),
]
)

let toolsBuildInfo = BuildInfo(
product: [
.executable(
name: "BlueSocketTestServer",
targets: ["BlueSocketTestServer"]),
.executable(
name: "BlueSocketTestClient",
targets: ["BlueSocketTestClient"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.1"),
],
targets: [
.target(name: "BlueSocketTestServer",
dependencies: ["BlueSocketTestCommonLibrary", "ArgumentParser", ]
),
.target(name: "BlueSocketTestClient",
dependencies: ["BlueSocketTestCommonLibrary", "ArgumentParser" ]
),
]
)

var products: [Product] = [
.library(
name: "Socket",
targets: ["Socket"]),

.library(
name: "BlueSocketTestCommonLibrary",
targets: ["BlueSocketTestCommonLibrary"]),
]
#if swift(>=5.2)
products.append(contentsOf: [
.executable(
name: "BlueSocketTestServer",
targets: ["BlueSocketTestServer"]),
.executable(
name: "BlueSocketTestClient",
targets: ["BlueSocketTestClient"])
])
#endif

let buildInfo: BuildInfo
#if swift(>=5.2)
buildInfo = BuildInfo(product: libraryBuildInfo.product + toolsBuildInfo.product,
dependencies: libraryBuildInfo.dependencies + toolsBuildInfo.dependencies,
targets: libraryBuildInfo.targets + toolsBuildInfo.targets)
#else
buildInfo = BuildInfo(product: libraryBuildInfo.product, dependencies: libraryBuildInfo.dependencies, targets: libraryBuildInfo.targets)
#endif

#if os(Linux) || os(macOS) || os(iOS) || os(tvOS)
let package = Package(
name: "Socket",
products: buildInfo.product,
dependencies: buildInfo.dependencies,
targets: buildInfo.targets
)
#else
fatalError("Unsupported OS")
#endif
44 changes: 0 additions & 44 deletions [email protected]

This file was deleted.

28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,36 @@ Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS,

### Swift

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

### macOS

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

### iOS

* iOS 10.0 or higher
* Xcode Version 9.0 (9A325) or higher using one of the above toolchains.
* Xcode Version 10.0 (10A255) or higher using the included toolchain (*Recommended*).
* Xcode Version 11 or higher using one of the above toolchains.
* Xcode Version 12 or higher using the included toolchain (*Recommended*).

Note:

If creating a UDP server on iOS, you may need to follow a few steps:

* [Request multicast entitlement from Apple ](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_multicast
)
* Add the Multicast Network capability to your App identifier
* For more details, see discussion in [Issue 194](https://github.com/Kitura/BlueSocket/issues/194)


### Linux

* Ubuntu 16.04 (or 16.10 but only tested on 16.04).
* One of the Swift Open Source toolchain listed above.
* Ubuntu 16.04 or 18.04
* One of the Swift Open Source toolchains listed above.

### Other Platforms

Expand Down
62 changes: 62 additions & 0 deletions Sources/BlueSocketTestClient/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// main.swift
// BlueSocket
//
// Created by Sung, Danny on 2021-04-12.
// Copyright © 2021 Kitura project. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import ArgumentParser
import BlueSocketTestCommonLibrary

let defaultPort = 10217
let defaultMaxBytes = 1_000_000
let defaultNumConnections = 1

struct TestClient: ParsableCommand {
@Option(name: [.customShort("p"), .customLong("port")], help: "TCP Port to connect to (Default: \(defaultPort))")
var port: Int = defaultPort

@Option(name: [.customShort("b"), .customLong("bytes")], help: "Number of bytes to send (Default: \(defaultMaxBytes))")
var maxBytes: Int = defaultMaxBytes

@Option(name: [.customShort("c"), .customLong("connections")], help: "Number of simultaneous connections (Default: \(defaultNumConnections))")
var numConnections: Int = defaultNumConnections

func run() throws {
print("Connecting to port: \(port)")

var clientList: [ClientController] = []

for _ in 0..<numConnections {
let client = try ClientController(port: port, maxBytes: maxBytes)
clientList.append(client)
}

while clientList.activeClients.count > 0 {
clientList.process()
}

for client in clientList {
print("Wrote \(client.bytesWritten) bytes Read \(client.bytesRead) bytes")
print("\(client.state)")
}
}
}

TestClient.main()


36 changes: 36 additions & 0 deletions Sources/BlueSocketTestCommonLibrary/Array+ClientController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Array+ClientController.swift
// BlueSocket
//
// Created by Sung, Danny on 2021-04-12.
// Copyright © 2021 Kitura project. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

public extension Array where Element == ClientController {
var activeClients: [ClientController] {
self.filter { !$0.isDone }
}

func process() {
self.forEach { $0.process() }
}

var hasFailures: Bool {
let failedClients = self.filter { $0.isFailed }
return failedClients.count > 0
}
}
Loading

0 comments on commit 4dd6c81

Please sign in to comment.