Skip to content

Commit

Permalink
Make Swift 5.2 the minimum requirement (apple#1860)
Browse files Browse the repository at this point in the history
Make Swift 5.2 the minimum requirement, dropping support for Swift 5.0 and 5.1.

Motivation:

Whenever we have problems, Swift 5.0 and 5.1 seem to be the culprits. Dropping support for these very old versions will require less maintenance and free up our time to work on new features.

Modifications:

Set the tools version in Package.swift to 5.2
Remove CI configurations for 5.0 and 5.1
Update the various readmes to reflect that this change will be rolled out in NIO 2.30.0
Result:

Swift 5.2 is the minimum version of Swift required to use NIO.
  • Loading branch information
Davidde94 authored Jun 18, 2021
1 parent 7f3a2f5 commit b0effbc
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 122 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ We require that your commit messages match our template. The easiest way to do t

git config commit.template dev/git.commit.template

The default policy for taking contributions is “Squash and Merge” - because of this the commit message format rule above applies to the PR rather than every commit contained within it.
The default policy for taking contributions is “Squash and Merge” - because of this the commit message format rule above applies to the PR rather than every commit contained within it.

### Make sure Tests work on Linux

SwiftNIO uses XCTest to run tests on both macOS and Linux. While the macOS version of XCTest is able to use the Objective-C runtime to discover tests at execution time, the Linux version is not (prior to swift 5.1).
SwiftNIO uses XCTest to run tests on both macOS and Linux. While the macOS version of XCTest is able to use the Objective-C runtime to discover tests at execution time, the Linux version is not (prior to swift 5.1).
For this reason, whenever you add new tests **you have to run a script** that generates the hooks needed to run those tests on Linux, or our CI will complain that the tests are not all present on Linux. To do this, merely execute `ruby ./scripts/generate_linux_tests.rb` at the root of the package and check the changes it made.

### Make sure your patch works for all supported versions of swift

The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.0 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose)
The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.2 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose)

### Make sure your code is performant

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.2
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It's like [Netty](https://netty.io), but written for Swift.

The SwiftNIO project is split across multiple repositories:

Repository | NIO 2 (Swift 5+) | NIO 1 (Swift 4+)
Repository | NIO 2 (Swift 5.2+) | NIO 1 (Swift 4+)
--- | --- | ---
[https://github.com/apple/swift-nio][repo-nio] <br> SwiftNIO core | `from: "2.0.0"` | `from: "1.0.0"`
[https://github.com/apple/swift-nio-ssl][repo-nio-ssl] <br> TLS (SSL) support | `from: "2.0.0"` | `from: "1.0.0"`
Expand All @@ -20,6 +20,8 @@ Repository | NIO 2 (Swift 5+) | NIO 1 (Swift 4+)
[https://github.com/apple/swift-nio-transport-services][repo-nio-transport-services] <br> first-class support for macOS, iOS, tvOS, and watchOS | `from: "1.0.0"` | `from: "0.1.0"`
[https://github.com/apple/swift-nio-ssh][repo-nio-ssh] <br> SSH support | `.upToNextMinor(from: "0.2.0")` | _n/a_

NIO 2.29.0 and older support Swift 5.0+.

### Protocol Implementations

Below you can find a list of a few protocol implementations that are done with SwiftNIO. This is a non-exhaustive list of protocols that are either part of the SwiftNIO project or are accepted into the [SSWG](https://swift.org/server)'s incubation process. All of the libraries listed below do all of their I/O in a non-blocking fashion using SwiftNIO.
Expand Down Expand Up @@ -64,7 +66,7 @@ The latest released SwiftNIO 1 version supports Swift 4.0, 4.1, 4.2, and 5.0.

#### SwiftNIO 2

The latest released SwiftNIO 2 version supports Swift 5.0, 5.1, 5.2, 5.3, and 5.4. If you have a SwiftNIO 1 application or library that you would like to migrate to SwiftNIO 2, please check out the [migration guide](docs/migration-guide-NIO1-to-NIO2.md) we prepared for you.
The latest released SwiftNIO 2 version supports Swift 5.2, 5.3, and 5.4. If you have a SwiftNIO 1 application or library that you would like to migrate to SwiftNIO 2, please check out the [migration guide](docs/migration-guide-NIO1-to-NIO2.md) we prepared for you.

### Compatibility

Expand Down Expand Up @@ -309,11 +311,11 @@ have a few prerequisites installed on your system.

#### macOS

- Xcode 10.2 or newer, Xcode 11 recommended.
- Xcode 11.4 or newer, Xcode 12 recommended.

### Linux

- Swift 5.0, 5.1, 5.2, 5.3, or 5.4 from [swift.org/download](https://swift.org/download/#releases). We always recommend to use the latest released version.
- Swift 5.2, 5.3, or 5.4 from [swift.org/download](https://swift.org/download/#releases). We always recommend to use the latest released version.
- netcat (for integration tests only)
- lsof (for integration tests only)
- shasum (for integration tests only)
Expand Down Expand Up @@ -355,7 +357,7 @@ dnf install swift-lang /usr/bin/nc /usr/bin/lsof /usr/bin/shasum
[repo-nio-ssh]: https://github.com/apple/swift-nio-ssh

### Speeding up testing
It's possible to run the test suite in parallel, it can save significant time if you have a larger multi-core machine, just add `--parallel` when running the tests. This can speed up the run time of the test suite with 30x or more.
It's possible to run the test suite in parallel, it can save significant time if you have a larger multi-core machine, just add `--parallel` when running the tests. This can speed up the run time of the test suite by 30x or more.

```
swift test --parallel
Expand Down
2 changes: 1 addition & 1 deletion dev/update-alloc-limits-to-last-completed-ci-build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ url_prefix=${1-"https://ci.swiftserver.group/job/swift-nio2-swift"}
target_repo=${2-"$here/.."}
tmpdir=$(mktemp -d /tmp/.last-build_XXXXXX)

for f in 51 52 53 54 55 -nightly; do
for f in 52 53 54 55 -nightly; do
echo "swift$f"
url="$url_prefix$f-prb/lastCompletedBuild/consoleFull"
echo "$url"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG swift_version=5.0
ARG swift_version=5.2
ARG ubuntu_version=bionic
ARG base_image=swift:$swift_version-$ubuntu_version
FROM $base_image
Expand Down
33 changes: 0 additions & 33 deletions docker/docker-compose.1804.50.yaml

This file was deleted.

65 changes: 0 additions & 65 deletions docker/docker-compose.1804.51.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ version: "3"
services:

runtime-setup:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2
build:
args:
ubuntu_version: "xenial"
ubuntu_version: "bionic"
swift_version: "5.2"

unit-tests:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2

integration-tests:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2

test:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2
environment:
- MAX_ALLOCS_ALLOWED_1000_addHandlers=47050
- MAX_ALLOCS_ALLOWED_1000_addHandlers_sync=40050
Expand Down Expand Up @@ -51,17 +51,17 @@ services:
- MAX_ALLOCS_ALLOWED_scheduling_10000_executions=20150
- MAX_ALLOCS_ALLOWED_udp_1000_reqs_1_conn=12200
- MAX_ALLOCS_ALLOWED_udp_1_reqs_1000_conn=188050
- SANITIZER_ARG=--sanitize=thread
# - SANITIZER_ARG=--sanitize=thread broken on 18.04
- INTEGRATION_TESTS_ARG=-f tests_0[013-9]

performance-test:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2

shell:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2

echo:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2

http:
image: swift-nio:16.04-5.2
image: swift-nio:18.04-5.2
2 changes: 2 additions & 0 deletions docs/migration-guide-NIO1-to-NIO2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This migration guide is our recommendation to migrate from NIO 1 to NIO 2. None

This repository also contains a fairly complete list of public [API changes](https://github.com/apple/swift-nio/blob/main/docs/public-api-changes-NIO1-to-NIO2.md) from NIO 1 to NIO 2.

### Note: As of NIO 2.30.0 the minimum version of Swift required is 5.2.

## Step 1: A warning-free compile on NIO 1 with Swift 5

To start with, we highly recommend to first get your project to compile warning-free with NIO 1 on Swift 5. The reason is that some of the warnings you might get are the result of deprecation in NIO 1 and deprecated NIO 1 API has been fully removed in NIO 2.
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_podspecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Pod::Spec.new do |s|
s.documentation_url = 'https://apple.github.io/swift-nio/docs/current/NIO/index.html'
s.module_name = '${target#Swift}'
s.swift_version = '5.0'
s.swift_version = '5.2'
s.cocoapods_version = '>=1.6.0'
s.ios.deployment_target = '10.0'
s.osx.deployment_target = '10.10'
Expand Down
7 changes: 5 additions & 2 deletions scripts/check_no_api_breakages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function build_and_do() {
function usage() {
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
echo >&2
echo >&2 "This script requires a Swift 5.1+ toolchain."
echo >&2 "This script requires a Swift 5.2+ toolchain."
echo >&2
echo >&2 "Examples:"
echo >&2
Expand Down Expand Up @@ -101,7 +101,10 @@ for old_tag in "$@"; do
--input-paths "$tmpdir/api-old/$f" -input-paths "$tmpdir/api-new/$f" 2>&1 \
> "$report" 2>&1

if ! shasum "$report" | grep -q cefc4ee5bb7bcdb7cb5a7747efa178dab3c794d5; then
# the shasum here is for an empty report, i.e. no changes
# if the shasum of the new report is different, then there's
# obviously an API change
if ! shasum "$report" | grep -q afd2a1b542b33273920d65821deddc653063c700; then
echo ERROR
echo >&2 "=============================="
echo >&2 "ERROR: public API change in $f"
Expand Down

0 comments on commit b0effbc

Please sign in to comment.