From 7e53749103f3636c51340d51e184a953ffa9946e Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Thu, 9 May 2024 04:19:06 +0200 Subject: [PATCH] Align supported Swift versions with rest of the ecosystem (#141) # Motivation Most of the server ecosystem follows the supported Swift versions from `swift-nio`. This means supporting the latest 3 Swift releases. # Modification This PR drops support for all Swift versions before 5.8. # Result This makes maintaining this repository easier and allows us to clean up some no longer needed stuff. --- Package@swift-4.2.swift | 43 ---- Package@swift-5.0.swift | 43 ---- Package@swift-5.1.swift | 43 ---- Package@swift-5.2.swift | 43 ---- Package@swift-5.3.swift | 43 ---- Package@swift-5.4.swift | 43 ---- Package@swift-5.5.swift | 43 ---- Sources/CoreMetrics/Metrics.swift | 6 - Sources/Metrics/Metrics.swift | 2 - Sources/MetricsTestKit/TestMetrics.swift | 10 - .../CoreMetricsTests+XCTest.swift | 69 ------ Tests/MetricsTests/MetricsTests+XCTest.swift | 37 --- Tests/MetricsTests/MetricsTests.swift | 4 - Tests/MetricsTests/TestSendable.swift | 2 - docker/docker-compose.1804.50.yaml | 16 -- docker/docker-compose.1804.51.yaml | 18 -- docker/docker-compose.1804.52.yaml | 18 -- docker/docker-compose.1804.53.yaml | 18 -- docker/docker-compose.2004.54.yaml | 18 -- docker/docker-compose.2004.55.yaml | 19 -- docker/docker-compose.2004.56.yaml | 19 -- docker/docker-compose.2004.57.yaml | 18 -- docker/docker-compose.yaml | 8 +- scripts/generate_docs.sh | 122 --------- scripts/generate_linux_tests.rb | 231 ------------------ scripts/soundness.sh | 12 - 26 files changed, 1 insertion(+), 947 deletions(-) delete mode 100644 Package@swift-4.2.swift delete mode 100644 Package@swift-5.0.swift delete mode 100644 Package@swift-5.1.swift delete mode 100644 Package@swift-5.2.swift delete mode 100644 Package@swift-5.3.swift delete mode 100644 Package@swift-5.4.swift delete mode 100644 Package@swift-5.5.swift delete mode 100644 Tests/MetricsTests/CoreMetricsTests+XCTest.swift delete mode 100644 Tests/MetricsTests/MetricsTests+XCTest.swift delete mode 100644 docker/docker-compose.1804.50.yaml delete mode 100644 docker/docker-compose.1804.51.yaml delete mode 100644 docker/docker-compose.1804.52.yaml delete mode 100644 docker/docker-compose.1804.53.yaml delete mode 100644 docker/docker-compose.2004.54.yaml delete mode 100644 docker/docker-compose.2004.55.yaml delete mode 100644 docker/docker-compose.2004.56.yaml delete mode 100644 docker/docker-compose.2004.57.yaml delete mode 100755 scripts/generate_docs.sh delete mode 100755 scripts/generate_linux_tests.rb diff --git a/Package@swift-4.2.swift b/Package@swift-4.2.swift deleted file mode 100644 index 11f748a..0000000 --- a/Package@swift-4.2.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:4.2 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.0.swift b/Package@swift-5.0.swift deleted file mode 100644 index ac536a6..0000000 --- a/Package@swift-5.0.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.0 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.1.swift b/Package@swift-5.1.swift deleted file mode 100644 index e148e61..0000000 --- a/Package@swift-5.1.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.1 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.2.swift b/Package@swift-5.2.swift deleted file mode 100644 index 7488bc1..0000000 --- a/Package@swift-5.2.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.2 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.3.swift b/Package@swift-5.3.swift deleted file mode 100644 index 23340f5..0000000 --- a/Package@swift-5.3.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.3 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.4.swift b/Package@swift-5.4.swift deleted file mode 100644 index 40e861e..0000000 --- a/Package@swift-5.4.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.4 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift deleted file mode 100644 index 5722b9c..0000000 --- a/Package@swift-5.5.swift +++ /dev/null @@ -1,43 +0,0 @@ -// swift-tools-version:5.5 -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import PackageDescription - -let package = Package( - name: "swift-metrics", - products: [ - .library(name: "CoreMetrics", targets: ["CoreMetrics"]), - .library(name: "Metrics", targets: ["Metrics"]), - .library(name: "MetricsTestKit", targets: ["MetricsTestKit"]), - ], - targets: [ - .target( - name: "CoreMetrics", - dependencies: [] - ), - .target( - name: "Metrics", - dependencies: ["CoreMetrics"] - ), - .target( - name: "MetricsTestKit", - dependencies: ["Metrics"] - ), - .testTarget( - name: "MetricsTests", - dependencies: ["Metrics", "MetricsTestKit"] - ), - ] -) diff --git a/Sources/CoreMetrics/Metrics.swift b/Sources/CoreMetrics/Metrics.swift index 8a343fa..196fd3a 100644 --- a/Sources/CoreMetrics/Metrics.swift +++ b/Sources/CoreMetrics/Metrics.swift @@ -1253,7 +1253,6 @@ public final class NOOPMetricsHandler: MetricsFactory, CounterHandler, FloatingP // MARK: - Sendable support helpers -#if compiler(>=5.6) extension MetricsSystem: Sendable {} extension Counter: Sendable {} extension FloatingPointCounter: Sendable {} @@ -1263,10 +1262,5 @@ extension Timer: Sendable {} extension Meter: Sendable {} // ideally we would not be using @unchecked here, but concurrency-safety checks do not recognize locks extension AccumulatingRoundingFloatingPointCounter: @unchecked Sendable {} -#endif -#if compiler(>=5.6) @preconcurrency public protocol _SwiftMetricsSendableProtocol: Sendable {} -#else -public protocol _SwiftMetricsSendableProtocol {} -#endif diff --git a/Sources/Metrics/Metrics.swift b/Sources/Metrics/Metrics.swift index c916c76..d3da910 100644 --- a/Sources/Metrics/Metrics.swift +++ b/Sources/Metrics/Metrics.swift @@ -75,7 +75,6 @@ extension Timer { } } -#if swift(>=5.7) extension Timer { /// Convenience for recording a duration based on ``Duration``. /// @@ -99,4 +98,3 @@ extension Timer { self.recordNanoseconds(nanoseconds.partialValue) } } -#endif diff --git a/Sources/MetricsTestKit/TestMetrics.swift b/Sources/MetricsTestKit/TestMetrics.swift index 30c1941..d57c0f5 100644 --- a/Sources/MetricsTestKit/TestMetrics.swift +++ b/Sources/MetricsTestKit/TestMetrics.swift @@ -576,26 +576,16 @@ extension NSLock { // MARK: - Errors -#if compiler(>=5.6) public enum TestMetricsError: Error { case missingMetric(label: String, dimensions: [(String, String)]) case illegalMetricType(metric: Sendable, expected: String) } -#else -public enum TestMetricsError: Error { - case missingMetric(label: String, dimensions: [(String, String)]) - case illegalMetricType(metric: Any, expected: String) -} -#endif - // MARK: - Sendable support -#if compiler(>=5.6) // ideally we would not be using @unchecked here, but concurrency-safety checks do not recognize locks extension TestMetrics: @unchecked Sendable {} extension TestCounter: @unchecked Sendable {} extension TestMeter: @unchecked Sendable {} extension TestRecorder: @unchecked Sendable {} extension TestTimer: @unchecked Sendable {} -#endif diff --git a/Tests/MetricsTests/CoreMetricsTests+XCTest.swift b/Tests/MetricsTests/CoreMetricsTests+XCTest.swift deleted file mode 100644 index abdf4c9..0000000 --- a/Tests/MetricsTests/CoreMetricsTests+XCTest.swift +++ /dev/null @@ -1,69 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// -// -// CoreMetricsTests+XCTest.swift -// -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. -/// - -extension MetricsTests { - static var allTests: [(String, (MetricsTests) -> () throws -> Void)] { - return [ - ("testCounters", testCounters), - ("testCounterBlock", testCounterBlock), - ("testDefaultFloatingPointCounter_ignoresNan", testDefaultFloatingPointCounter_ignoresNan), - ("testDefaultFloatingPointCounter_ignoresInfinity", testDefaultFloatingPointCounter_ignoresInfinity), - ("testDefaultFloatingPointCounter_ignoresNegativeValues", testDefaultFloatingPointCounter_ignoresNegativeValues), - ("testDefaultFloatingPointCounter_ignoresZero", testDefaultFloatingPointCounter_ignoresZero), - ("testDefaultFloatingPointCounter_ceilsExtremeValues", testDefaultFloatingPointCounter_ceilsExtremeValues), - ("testDefaultFloatingPointCounter_accumulatesFloatingPointDecimalValues", testDefaultFloatingPointCounter_accumulatesFloatingPointDecimalValues), - ("testRecorders", testRecorders), - ("testRecordersInt", testRecordersInt), - ("testRecordersFloat", testRecordersFloat), - ("testRecorderBlock", testRecorderBlock), - ("testTimers", testTimers), - ("testTimerBlock", testTimerBlock), - ("testTimerVariants", testTimerVariants), - ("testTimerOverflow", testTimerOverflow), - ("testTimerHandlesUnsignedOverflow", testTimerHandlesUnsignedOverflow), - ("testGauge", testGauge), - ("testGaugeBlock", testGaugeBlock), - ("testMeter", testMeter), - ("testMeterBlock", testMeterBlock), - ("testMeterInt", testMeterInt), - ("testMeterFloat", testMeterFloat), - ("testMeterIncrement", testMeterIncrement), - ("testMeterDecrement", testMeterDecrement), - ("testDefaultMeterIgnoresNan", testDefaultMeterIgnoresNan), - ("testDefaultMeterIgnoresInfinity", testDefaultMeterIgnoresInfinity), - ("testDefaultMeterIgnoresNegativeValues", testDefaultMeterIgnoresNegativeValues), - ("testDefaultMeterIgnoresZero", testDefaultMeterIgnoresZero), - ("testMUX_Counter", testMUX_Counter), - ("testMUX_Meter", testMUX_Meter), - ("testMUX_Recorder", testMUX_Recorder), - ("testMUX_Timer", testMUX_Timer), - ("testCustomFactory", testCustomFactory), - ("testDestroyingGauge", testDestroyingGauge), - ("testDestroyingMeter", testDestroyingMeter), - ("testDestroyingCounter", testDestroyingCounter), - ("testDestroyingTimer", testDestroyingTimer), - ("testDescriptions", testDescriptions), - ] - } -} diff --git a/Tests/MetricsTests/MetricsTests+XCTest.swift b/Tests/MetricsTests/MetricsTests+XCTest.swift deleted file mode 100644 index 3c58452..0000000 --- a/Tests/MetricsTests/MetricsTests+XCTest.swift +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// -// -// MetricsTests+XCTest.swift -// -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. -/// - -extension MetricsExtensionsTests { - static var allTests: [(String, (MetricsExtensionsTests) -> () throws -> Void)] { - return [ - ("testTimerBlock", testTimerBlock), - ("testTimerWithTimeInterval", testTimerWithTimeInterval), - ("testTimerWithDispatchTime", testTimerWithDispatchTime), - ("testTimerWithDispatchTimeInterval", testTimerWithDispatchTimeInterval), - ("testTimerDuration", testTimerDuration), - ("testTimerUnits", testTimerUnits), - ("testPreferDisplayUnit", testPreferDisplayUnit), - ] - } -} diff --git a/Tests/MetricsTests/MetricsTests.swift b/Tests/MetricsTests/MetricsTests.swift index 3b590fd..de2bac9 100644 --- a/Tests/MetricsTests/MetricsTests.swift +++ b/Tests/MetricsTests/MetricsTests.swift @@ -99,7 +99,6 @@ class MetricsExtensionsTests: XCTestCase { func testTimerDuration() throws { // Wrapping only the insides of the test case so that the generated // tests on Linux in MetricsTests+XCTest don't complain that the func does not exist. - #if swift(>=5.7) guard #available(iOS 16, macOS 13, tvOS 15, watchOS 8, *) else { throw XCTSkip("Timer.record(_ duration: Duration) is not available on this platform") } @@ -123,9 +122,6 @@ class MetricsExtensionsTests: XCTestCase { XCTAssertEqual(testTimer.values.first, nanoseconds, "expected value to match") XCTAssertEqual(testTimer.values[1], Int64.max, "expected to record Int64.max if Durataion overflows") XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored") - #elseif swift(>=5.2) - throw XCTSkip("Timer.record(_ duration: Duration) is only available on Swift >=5.7") - #endif } func testTimerUnits() throws { diff --git a/Tests/MetricsTests/TestSendable.swift b/Tests/MetricsTests/TestSendable.swift index 0ab0778..255fb43 100644 --- a/Tests/MetricsTests/TestSendable.swift +++ b/Tests/MetricsTests/TestSendable.swift @@ -18,7 +18,6 @@ import MetricsTestKit import XCTest class SendableTest: XCTestCase { - #if compiler(>=5.6) func testSendableMetrics() async throws { // bootstrap with our test metrics let metrics = TestMetrics() @@ -98,5 +97,4 @@ class SendableTest: XCTestCase { XCTAssertEqual(values[0], value, "expected value to match") } } - #endif } diff --git a/docker/docker-compose.1804.50.yaml b/docker/docker-compose.1804.50.yaml deleted file mode 100644 index 25062b1..0000000 --- a/docker/docker-compose.1804.50.yaml +++ /dev/null @@ -1,16 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:18.04-5.0 - build: - args: - ubuntu_version: "bionic" - swift_version: "5.0" - - test: - image: swift-metrics:18.04-5.0 - - shell: - image: swift-metrics:18.04-5.0 diff --git a/docker/docker-compose.1804.51.yaml b/docker/docker-compose.1804.51.yaml deleted file mode 100644 index c10b821..0000000 --- a/docker/docker-compose.1804.51.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:18.04-5.1 - build: - args: - ubuntu_version: "bionic" - swift_version: "5.1" - - test: - image: swift-metrics:18.04-5.1 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:18.04-5.1 diff --git a/docker/docker-compose.1804.52.yaml b/docker/docker-compose.1804.52.yaml deleted file mode 100644 index ee6f33c..0000000 --- a/docker/docker-compose.1804.52.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:18.04-5.2 - build: - args: - ubuntu_version: "bionic" - swift_version: "5.2" - - test: - image: swift-metrics:18.04-5.2 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:18.04-5.2 diff --git a/docker/docker-compose.1804.53.yaml b/docker/docker-compose.1804.53.yaml deleted file mode 100644 index 484b1e7..0000000 --- a/docker/docker-compose.1804.53.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:18.04-5.3 - build: - args: - ubuntu_version: "bionic" - swift_version: "5.3" - - test: - image: swift-metrics:18.04-5.3 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:18.04-5.3 diff --git a/docker/docker-compose.2004.54.yaml b/docker/docker-compose.2004.54.yaml deleted file mode 100644 index d9c441b..0000000 --- a/docker/docker-compose.2004.54.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:20.04-5.4 - build: - args: - ubuntu_version: "focal" - swift_version: "5.4" - - test: - image: swift-metrics:20.04-5.4 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:20.04-5.4 diff --git a/docker/docker-compose.2004.55.yaml b/docker/docker-compose.2004.55.yaml deleted file mode 100644 index 6015f3c..0000000 --- a/docker/docker-compose.2004.55.yaml +++ /dev/null @@ -1,19 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:20.04-5.5 - build: - args: - ubuntu_version: "focal" - swift_version: "5.5" - - test: - image: swift-metrics:20.04-5.5 - environment: - - FORCE_TEST_DISCOVERY=--enable-test-discovery - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:20.04-5.5 diff --git a/docker/docker-compose.2004.56.yaml b/docker/docker-compose.2004.56.yaml deleted file mode 100644 index 1d0baea..0000000 --- a/docker/docker-compose.2004.56.yaml +++ /dev/null @@ -1,19 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:20.04-5.6 - build: - args: - ubuntu_version: "focal" - swift_version: "5.6" - - test: - image: swift-metrics:20.04-5.6 - environment: - - FORCE_TEST_DISCOVERY=--enable-test-discovery - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:20.04-5.6 diff --git a/docker/docker-compose.2004.57.yaml b/docker/docker-compose.2004.57.yaml deleted file mode 100644 index 255f1af..0000000 --- a/docker/docker-compose.2004.57.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" - -services: - - runtime-setup: - image: swift-metrics:20.04-5.7 - build: - args: - ubuntu_version: "focal" - swift_version: "5.7" - - test: - image: swift-metrics:20.04-5.7 - environment: [] - #- SANITIZER_ARG=--sanitize=thread - - shell: - image: swift-metrics:20.04-5.7 diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 147a290..b752fd6 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -26,15 +26,9 @@ services: <<: *common command: /bin/bash -xcl "./scripts/soundness.sh" - docs: - <<: *common - environment: - - CI - command: /bin/bash -xcl "./scripts/generate_docs.sh" - test: <<: *common - command: /bin/bash -xcl "swift test -Xswiftc -warnings-as-errors $${FORCE_TEST_DISCOVERY-} $${SANITIZER_ARG-}" + command: /bin/bash -xcl "swift test -Xswiftc -warnings-as-errors --enable-test-discovery $${SANITIZER_ARG-}" # util diff --git a/scripts/generate_docs.sh b/scripts/generate_docs.sh deleted file mode 100755 index 9773b2f..0000000 --- a/scripts/generate_docs.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the Swift Metrics API open source project -## -## Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## See CONTRIBUTORS.txt for the list of Swift Metrics API project authors -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## - -set -e - -my_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -root_path="$my_path/.." -version=$(git describe --abbrev=0 --tags || echo "0.0.0") -modules=(CoreMetrics Metrics) - -if [[ "$(uname -s)" == "Linux" ]]; then - # build code if required - if [[ ! -d "$root_path/.build/x86_64-unknown-linux" ]]; then - swift build - fi - # setup source-kitten if required - mkdir -p "$root_path/.build/sourcekitten" - source_kitten_source_path="$root_path/.build/sourcekitten/source" - if [[ ! -d "$source_kitten_source_path" ]]; then - git clone https://github.com/jpsim/SourceKitten.git "$source_kitten_source_path" - fi - source_kitten_path="$source_kitten_source_path/.build/debug" - if [[ ! -d "$source_kitten_path" ]]; then - rm -rf "$source_kitten_source_path/.swift-version" - cd "$source_kitten_source_path" && swift build && cd "$root_path" - fi - # generate - for module in "${modules[@]}"; do - if [[ ! -f "$root_path/.build/sourcekitten/$module.json" ]]; then - "$source_kitten_path/sourcekitten" doc --spm --module-name $module > "$root_path/.build/sourcekitten/$module.json" - fi - done -fi - -[[ -d docs/$version ]] || mkdir -p docs/$version -[[ -d swift-metrics.xcodeproj ]] || swift package generate-xcodeproj - -# run jazzy -if ! command -v jazzy > /dev/null; then - gem install jazzy --no-ri --no-rdoc -fi - -jazzy_dir="$root_path/.build/jazzy" -rm -rf "$jazzy_dir" -mkdir -p "$jazzy_dir" - -module_switcher="$jazzy_dir/README.md" -jazzy_args=(--clean - --author 'SwiftMetrics team' - --readme "$module_switcher" - --author_url https://github.com/apple/swift-metrics - --github_url https://github.com/apple/swift-metrics - --github-file-prefix https://github.com/apple/swift-metrics/tree/$version - --theme fullwidth - --xcodebuild-arguments -scheme,swift-metrics-Package) -cat > "$module_switcher" <<"EOF" -# SwiftMetrics Docs - -SwiftMetrics is a Swift metrics API package. - -To get started with SwiftMetrics, [`import Metrics`](../CoreMetrics/index.html). The most important types are: - -* [`Counter`](https://apple.github.io/swift-metrics/docs/current/CoreMetrics/Classes/Counter.html) -* [`Timer`](https://apple.github.io/swift-metrics/docs/current/CoreMetrics/Classes/Timer.html) -* [`Recorder`](https://apple.github.io/swift-metrics/docs/current/CoreMetrics/Classes/Recorder.html) -* [`Gauge`](https://apple.github.io/swift-metrics/docs/current/CoreMetrics/Classes/Gauge.html) - -SwiftMetrics contains multiple modules: -EOF - -for module in "${modules[@]}"; do - echo " - [$module](../$module/index.html)" >> "$module_switcher" -done - -for module in "${modules[@]}"; do - echo "processing $module" - args=("${jazzy_args[@]}" --output "$jazzy_dir/docs/$version/$module" --docset-path "$jazzy_dir/docset/$version/$module" - --module "$module" --module-version $version - --root-url "https://apple.github.io/swift-metrics/docs/$version/$module/") - if [[ -f "$root_path/.build/sourcekitten/$module.json" ]]; then - args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json") - fi - jazzy "${args[@]}" -done - -# push to github pages -if [[ $PUSH == true ]]; then - BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) - GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD) - git fetch origin +gh-pages:gh-pages - git checkout gh-pages - rm -rf "docs/$version" - rm -rf "docs/current" - cp -r "$jazzy_dir/docs/$version" docs/ - cp -r "docs/$version" docs/current - git add --all docs - echo '' > index.html - git add index.html - touch .nojekyll - git add .nojekyll - changes=$(git diff-index --name-only HEAD) - if [[ -n "$changes" ]]; then - echo -e "changes detected\n$changes" - git commit --author="$GIT_AUTHOR" -m "publish $version docs" - git push origin gh-pages - else - echo "no changes detected" - fi - git checkout -f $BRANCH_NAME -fi diff --git a/scripts/generate_linux_tests.rb b/scripts/generate_linux_tests.rb deleted file mode 100755 index eef6ecd..0000000 --- a/scripts/generate_linux_tests.rb +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env ruby - -# -# process_test_files.rb -# -# Copyright 2016 Tony Stone -# -# 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. -# -# Created by Tony Stone on 5/4/16. -# -require 'getoptlong' -require 'fileutils' -require 'pathname' - -include FileUtils - -# -# This ruby script will auto generate LinuxMain.swift and the +XCTest.swift extension files for Swift Package Manager on Linux platforms. -# -# See https://github.com/apple/swift-corelibs-xctest/blob/master/Documentation/Linux.md -# -def header(fileName) - string = <<-eos -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Metrics API open source project -// -// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift Metrics API 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. -/// - eos - - string - .sub('', File.basename(fileName)) - .sub('', Time.now.to_s) -end - -def createExtensionFile(fileName, classes) - extensionFile = fileName.sub! '.swift', '+XCTest.swift' - print 'Creating file: ' + extensionFile + "\n" - - File.open(extensionFile, 'w') do |file| - file.write header(extensionFile) - file.write "\n" - - for classArray in classes - file.write 'extension ' + classArray[0] + " {\n" - file.write ' static var allTests: [(String, (' + classArray[0] + ") -> () throws -> Void)] {\n" - file.write " return [\n" - - for funcName in classArray[1] - file.write ' ("' + funcName + '", ' + funcName + "),\n" - end - - file.write " ]\n" - file.write " }\n" - file.write "}\n" - end - end -end - -def createLinuxMain(testsDirectory, allTestSubDirectories, files) - fileName = testsDirectory + '/LinuxMain.swift' - print 'Creating file: ' + fileName + "\n" - - File.open(fileName, 'w') do |file| - file.write header(fileName) - file.write "\n" - - file.write "#if os(Linux) || os(FreeBSD)\n" - for testSubDirectory in allTestSubDirectories.sort { |x, y| x <=> y } - file.write '@testable import ' + testSubDirectory + "\n" - end - file.write "\n" - file.write "XCTMain([\n" - - testCases = [] - for classes in files - for classArray in classes - testCases << classArray[0] - end - end - - for testCase in testCases.sort { |x, y| x <=> y } - file.write ' testCase(' + testCase + ".allTests),\n" - end - file.write "])\n" - file.write "#endif\n" - end -end - -def parseSourceFile(fileName) - puts 'Parsing file: ' + fileName + "\n" - - classes = [] - currentClass = nil - inIfLinux = false - inElse = false - ignore = false - - # - # Read the file line by line - # and parse to find the class - # names and func names - # - File.readlines(fileName).each do |line| - if inIfLinux - if /\#else/.match(line) - inElse = true - ignore = true - else - if /\#end/.match(line) - inElse = false - inIfLinux = false - ignore = false - end - end - else - if /\#if[ \t]+os\(Linux\)/.match(line) - inIfLinux = true - ignore = false - end - end - - next if ignore - # Match class or func - match = line[/class[ \t]+[a-zA-Z0-9_]*(?=[ \t]*:[ \t]*XCTestCase)|func[ \t]+test[a-zA-Z0-9_]*(?=[ \t]*\(\))/, 0] - if match - - if match[/class/, 0] == 'class' - className = match.sub(/^class[ \t]+/, '') - # - # Create a new class / func structure - # and add it to the classes array. - # - currentClass = [className, []] - classes << currentClass - else # Must be a func - funcName = match.sub(/^func[ \t]+/, '') - # - # Add each func name the the class / func - # structure created above. - # - currentClass[1] << funcName - end - end - end - classes -end - -# -# Main routine -# -# - -testsDirectory = 'Tests' - -options = GetoptLong.new(['--tests-dir', GetoptLong::OPTIONAL_ARGUMENT]) -options.quiet = true - -begin - options.each do |option, value| - case option - when '--tests-dir' - testsDirectory = value - end - end -rescue GetoptLong::InvalidOption -end - -allTestSubDirectories = [] -allFiles = [] - -Dir[testsDirectory + '/*'].each do |subDirectory| - next unless File.directory?(subDirectory) - directoryHasClasses = false - Dir[subDirectory + '/*Test{s,}.swift'].each do |fileName| - next unless File.file? fileName - fileClasses = parseSourceFile(fileName) - - # - # If there are classes in the - # test source file, create an extension - # file for it. - # - next unless fileClasses.count > 0 - createExtensionFile(fileName, fileClasses) - directoryHasClasses = true - allFiles << fileClasses - end - - if directoryHasClasses - allTestSubDirectories << Pathname.new(subDirectory).split.last.to_s - end -end - -# -# Last step is the create a LinuxMain.swift file that -# references all the classes and funcs in the source files. -# -if allFiles.count > 0 - createLinuxMain(testsDirectory, allTestSubDirectories, allFiles) -end -# eof diff --git a/scripts/soundness.sh b/scripts/soundness.sh index 123d70b..21ee5e5 100755 --- a/scripts/soundness.sh +++ b/scripts/soundness.sh @@ -35,18 +35,6 @@ function replace_acceptable_years() { sed -e 's/20[12][789012]-20[12][89012]/YEARS/' -e 's/20[12][89012]/YEARS/' } -printf "=> Checking linux tests... " -FIRST_OUT="$(git status --porcelain)" -ruby "$here/../scripts/generate_linux_tests.rb" > /dev/null -SECOND_OUT="$(git status --porcelain)" -if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then - printf "\033[0;31mmissing changes!\033[0m\n" - git --no-pager diff - exit 1 -else - printf "\033[0;32mokay.\033[0m\n" -fi - printf "=> Checking for unacceptable language... " # This greps for unacceptable terminology. The square bracket[s] are so that # "git grep" doesn't find the lines that greps :).