From 7a04c412960251e4f7fcb3a4ff15a29e4d06d599 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Mon, 18 Nov 2024 16:04:19 +0000 Subject: [PATCH 1/3] Follow-up cleanup of GitHub Actions migration **Motivation:** Make use of more common GitHub Actions migration workflows and repository style changes. **Modifications:** * Unit tests workflows make use of the NIO `unit-tests` workflow with additional checks enabled * Introduce `main.yml` which runs workflows on each commit to `main` and periodically to catch any regressions in merges or from upstream. * Enable nightly CI runs as a signal for upcoming failures as is done in other Swift on Server ecosystem repositories. * Remove the docker files which are no longer used and contained outdated pipelines. * Bring the Samples up to Swift 5.9 and add a CI pipeline to ensure their continued ability to compile. **Result:** More in common with other GitHub Actions adoptions, compiling Samples. --- .github/workflows/main.yml | 25 +++++++++++ .github/workflows/pull_request.yml | 23 +++++----- CONTRIBUTING.md | 3 +- Samples/Package.swift | 16 +++---- .../SWIMNIOSampleNode.swift | 2 +- Samples/Tests/LinuxMain.swift | 31 -------------- docker/Dockerfile | 34 --------------- docker/docker-compose.2204.510.yaml | 33 --------------- docker/docker-compose.2204.59.yaml | 34 --------------- docker/docker-compose.2204.60.yaml | 33 --------------- docker/docker-compose.2204.main.yaml | 34 --------------- docker/docker-compose.yaml | 42 ------------------- 12 files changed, 47 insertions(+), 263 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 Samples/Tests/LinuxMain.swift delete mode 100644 docker/Dockerfile delete mode 100644 docker/docker-compose.2204.510.yaml delete mode 100644 docker/docker-compose.2204.59.yaml delete mode 100644 docker/docker-compose.2204.60.yaml delete mode 100644 docker/docker-compose.2204.main.yaml delete mode 100644 docker/docker-compose.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8a87db8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +name: Main + +on: + push: + branches: [main] + schedule: + - cron: "0 8,20 * * *" + +jobs: + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_arguments_override: "--explicit-target-dependency-import-check error" + linux_5_10_arguments_override: "--explicit-target-dependency-import-check error" + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + + samples: + name: Samples + uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main + with: + name: "Samples" + matrix_linux_command: "cd Samples/ && swift build --explicit-target-dependency-import-check error" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8db9983..7d6b62d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,16 +14,17 @@ jobs: unit-tests: name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_arguments_override: "--explicit-target-dependency-import-check error" + linux_5_10_arguments_override: "--explicit-target-dependency-import-check error" + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + + samples: + name: Samples uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main with: - name: "Unit tests" - matrix_linux_command: "swift test" - matrix_linux_5_9_enabled: false - matrix_linux_5_10_enabled: true - matrix_linux_6_0_enabled: true - matrix_linux_6_0_command_override: "swift test" - matrix_linux_nightly_6_0_enabled: true - matrix_linux_nightly_main_enabled: true - matrix_windows_6_0_enabled: false - matrix_windows_nightly_6_0_enabled: false - matrix_windows_nightly_main_enabled: false + name: "Samples" + matrix_linux_command: "cd Samples/ && swift build --explicit-target-dependency-import-check error" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36b8791..a82d598 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,8 +70,7 @@ We require that your commit messages match our template. The easiest way to do t ### Run CI checks locally -You can run the Github Actions workflows locally using -[act](https://github.com/nektos/act). For detailed steps on how to do this please see [https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally](https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally). +You can run the GitHub Actions workflows locally using [act](https://github.com/nektos/act). For detailed steps on how to do this please see [https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally](https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally). ## How to contribute your work diff --git a/Samples/Package.swift b/Samples/Package.swift index 2c21db1..001eb2e 100644 --- a/Samples/Package.swift +++ b/Samples/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -7,11 +7,11 @@ var targets: [PackageDescription.Target] = [ .target( name: "SWIMNIOSampleCluster", dependencies: [ - "SWIM", - "SWIMNIOExample", - "SwiftPrometheus", - "Lifecycle", - "ArgumentParser", + .product(name: "SWIM", package: "swift-cluster-membership"), + .product(name: "SWIMNIOExample", package: "swift-cluster-membership"), + .product(name: "SwiftPrometheus", package: "SwiftPrometheus"), + .product(name: "Lifecycle", package: "swift-service-lifecycle"), + .product(name: "ArgumentParser", package: "swift-argument-parser"), ], path: "Sources/SWIMNIOSampleCluster" ), @@ -22,7 +22,7 @@ var targets: [PackageDescription.Target] = [ .testTarget( name: "NoopTests", dependencies: [ - "SWIM" + .product(name: "SWIM", package: "swift-cluster-membership") ], path: "Tests/NoopTests" ), @@ -42,7 +42,7 @@ var dependencies: [Package.Dependency] = [ let package = Package( name: "swift-cluster-membership-samples", platforms: [ - .macOS(.v10_12) + .macOS(.v13) ], products: [ .executable( diff --git a/Samples/Sources/SWIMNIOSampleCluster/SWIMNIOSampleNode.swift b/Samples/Sources/SWIMNIOSampleCluster/SWIMNIOSampleNode.swift index 419807b..0318b54 100644 --- a/Samples/Sources/SWIMNIOSampleCluster/SWIMNIOSampleNode.swift +++ b/Samples/Sources/SWIMNIOSampleCluster/SWIMNIOSampleNode.swift @@ -55,7 +55,7 @@ struct SampleSWIMNIONode { } final class SWIMNIOSampleHandler: ChannelInboundHandler { - public typealias InboundIn = SWIM.MemberStatusChangedEvent + typealias InboundIn = SWIM.MemberStatusChangedEvent let log = Logger(label: "SWIMNIOSample") diff --git a/Samples/Tests/LinuxMain.swift b/Samples/Tests/LinuxMain.swift deleted file mode 100644 index 1a6038c..0000000 --- a/Samples/Tests/LinuxMain.swift +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Cluster Membership open source project -// -// Copyright (c) 2020 Apple Inc. and the Swift Cluster Membership project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Cluster Membership project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import XCTest - -/// -/// NOTE: This file was generated by generate_linux_tests.rb -/// -/// Do NOT edit this file directly as it will be regenerated automatically when needed. -/// - -#if os(Linux) || os(FreeBSD) -@testable import NoopTests - -XCTMain( - [ - testCase(SampleTest.allTests) - ] -) -#endif diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index ff03aec..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -ARG swift_version=5.0 -ARG ubuntu_version=bionic -ARG base_image=swift:$swift_version-$ubuntu_version -FROM $base_image -# needed to do again after FROM due to docker limitation -ARG swift_version -ARG ubuntu_version - -# set as UTF-8 -RUN apt-get update && apt-get install -y locales locales-all -ENV LC_ALL en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US.UTF-8 - -# dependencies -RUN apt-get update && apt-get install -y wget -RUN apt-get update && apt-get install -y lsof dnsutils netcat-openbsd net-tools curl jq # used by integration tests - -# ruby and jazzy for docs generation -RUN apt-get update && apt-get install -y ruby ruby-dev libsqlite3-dev build-essential -# jazzy no longer works on older version of ubuntu as ruby is too old. -RUN if [ "${ubuntu_version}" = "focal" ] ; then echo "gem: --no-document" > ~/.gemrc ; fi -RUN if [ "${ubuntu_version}" = "focal" ] ; then gem install jazzy ; fi - -# tools -RUN mkdir -p $HOME/.tools -RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile - -# swiftformat (until part of the toolchain) - -ARG swiftformat_version=0.44.6 -RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format -RUN cd $HOME/.tools/swift-format && swift build -c release -RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat diff --git a/docker/docker-compose.2204.510.yaml b/docker/docker-compose.2204.510.yaml deleted file mode 100644 index ef5b149..0000000 --- a/docker/docker-compose.2204.510.yaml +++ /dev/null @@ -1,33 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-distributed-actors:22.04-5.10 - build: - args: - base_image: "swiftlang/swift:nightly-5.10-jammy" - - unit-tests: - image: swift-distributed-actors:22.04-5.10 - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - unit-tests-until-failure: - image: swift-distributed-actors:22.04-5.10 - - integration-tests: - image: swift-distributed-actors:22.04-5.10 - command: /bin/bash -cl "swift package --disable-sandbox multi-node test" - - test: - image: swift-distributed-actors:22.04-5.10 - command: /bin/bash -cl "swift test" - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - bench: - image: swift-distributed-actors:22.04-5.10 - - shell: - image: swift-distributed-actors:22.04-5.10 diff --git a/docker/docker-compose.2204.59.yaml b/docker/docker-compose.2204.59.yaml deleted file mode 100644 index ea0f8e8..0000000 --- a/docker/docker-compose.2204.59.yaml +++ /dev/null @@ -1,34 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-cluster-membership:22.04-5.9 - build: - args: - base_image: "swiftlang/swift:nightly-5.9-jammy" - - unit-tests: - image: swift-cluster-membership:22.04-5.9 - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - unit-tests-until-failure: - image: swift-cluster-membership:22.04-5.9 - - integration-tests: - image: swift-cluster-membership:22.04-5.9 - - test: - image: swift-cluster-membership:22.04-5.9 - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - bench: - image: swift-cluster-membership:22.04-5.9 - - shell: - image: swift-cluster-membership:22.04-5.9 - - sample-crash: - image: swift-cluster-membership:22.04-5.9 diff --git a/docker/docker-compose.2204.60.yaml b/docker/docker-compose.2204.60.yaml deleted file mode 100644 index 311a2dc..0000000 --- a/docker/docker-compose.2204.60.yaml +++ /dev/null @@ -1,33 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-distributed-actors:22.04-6.0 - build: - args: - base_image: "swiftlang/swift:nightly-6.0-jammy" - - unit-tests: - image: swift-distributed-actors:22.04-6.0 - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - unit-tests-until-failure: - image: swift-distributed-actors:22.04-6.0 - - integration-tests: - image: swift-distributed-actors:22.04-6.0 - command: /bin/bash -cl "swift package --disable-sandbox multi-node test" - - test: - image: swift-distributed-actors:22.04-6.0 - command: /bin/bash -cl "swift test" - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - bench: - image: swift-distributed-actors:22.04-6.0 - - shell: - image: swift-distributed-actors:22.04-6.0 diff --git a/docker/docker-compose.2204.main.yaml b/docker/docker-compose.2204.main.yaml deleted file mode 100644 index 15149a5..0000000 --- a/docker/docker-compose.2204.main.yaml +++ /dev/null @@ -1,34 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-cluster-membership:22.04-main - build: - args: - base_image: "swiftlang/swift:nightly-main-jammy" - - unit-tests: - image: swift-cluster-membership:22.04-main - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - unit-tests-until-failure: - image: swift-cluster-membership:22.04-main - - integration-tests: - image: swift-cluster-membership:22.04-main - - test: - image: swift-cluster-membership:22.04-main - environment: - - EXPLICIT_TARGET_DEPENDENCY_IMPORT_CHECK=--explicit-target-dependency-import-check error - - bench: - image: swift-cluster-membership:22.04-main - - shell: - image: swift-cluster-membership:22.04-main - - sample-crash: - image: swift-cluster-membership:22.04-main diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml deleted file mode 100644 index f308ca0..0000000 --- a/docker/docker-compose.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# this file is not designed to be run directly -# instead, use the docker-compose.. files -# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.1604.51.yaml run test -version: "3" - -services: - - runtime-setup: - image: swift-cluster-membership:default - build: - context: . - dockerfile: Dockerfile - - common: &common - image: swift-cluster-membership:default - depends_on: [runtime-setup] - volumes: - - ~/.ssh:/root/.ssh - - ..:/code:z - working_dir: /code - cap_drop: - - CAP_NET_RAW - - CAP_NET_BIND_SERVICE - environment: - - MAX_ALLOCS_ALLOWED_example=1000 - - unit-tests: - <<: *common - command: /bin/bash -cl "swift test" - - integration-tests: - <<: *common - command: /bin/bash -cl "./scripts/integration_tests.sh" - - test: - <<: *common - command: /bin/bash -cl "swift test -Xswiftc -DTESTS_LEAKS && ./scripts/integration_tests.sh" - # command: /bin/bash -cl "WARNINGS_AS_ERRORS=yes swift test -Xswiftc -DTESTS_LEAKS && ./scripts/integration_tests.sh" - - shell: - <<: *common - entrypoint: /bin/bash -l From 812b9c013e01c62816486c1024d7048b32d32aa2 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Mon, 18 Nov 2024 16:28:26 +0000 Subject: [PATCH 2/3] add cxx interop workflows --- .github/workflows/pull_request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7d6b62d..493aff1 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -28,3 +28,7 @@ jobs: with: name: "Samples" matrix_linux_command: "cd Samples/ && swift build --explicit-target-dependency-import-check error" + + cxx-interop: + name: Cxx interop + uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main From 85ba73f0ab503f3cf7c631b3dc7628d59bfabd2a Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Mon, 18 Nov 2024 16:28:39 +0000 Subject: [PATCH 3/3] enable API breakage checks --- .github/workflows/pull_request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 493aff1..3b3a78c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,6 @@ jobs: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: - api_breakage_check_enabled: false license_header_check_project_name: "Swift Cluster Membership" unit-tests: