diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84d6cdeb..9840f203 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,19 +14,19 @@ jobs: 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_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" linux_6_2_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_next_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" windows_6_0_enabled: true windows_6_1_enabled: true + windows_6_2_enabled: true windows_nightly_next_enabled: true windows_nightly_main_enabled: true windows_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + windows_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 158af6d2..4599d126 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -20,35 +20,19 @@ jobs: name: Unit tests uses: apple/swift-nio/.github/workflows/unit_tests.yml@main with: - - # NOTE: Aug 5, 2025. We've determined SPM has bugs for `condition: .when(platforms: [.somePlatform])` - # that incorrectly ignore the condition and import anyways for unintended platforms. - # - # See https://github.com/apple/swift-distributed-tracing/actions/runs/16578688393/job/46920025183?pr=174 - # for an example of the resulting build failure. - # - # This is documented as a bug in Swift 5.10, resolved in Swift 6. - # See FB14859516. - # See also https://forums.swift.org/t/do-swiftpm-conditional-target-dependencies-work/74047 - # - # Given this, the explicit target dependency check is disabled for Swift versions before Swift 6. - - # Intentionally disabled: - # - # 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_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" linux_6_2_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_next_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" windows_6_0_enabled: true windows_6_1_enabled: true + windows_6_2_enabled: true windows_nightly_next_enabled: true windows_nightly_main_enabled: true windows_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + windows_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" diff --git a/Package.swift b/Package.swift index 2ebaf7bb..056a2a25 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.9 +// swift-tools-version:6.0 import PackageDescription let package = Package( diff --git a/Sources/Tracing/Tracer.swift b/Sources/Tracing/Tracer.swift index b7692bba..30baf6bb 100644 --- a/Sources/Tracing/Tracer.swift +++ b/Sources/Tracing/Tracer.swift @@ -321,7 +321,6 @@ public func withSpan( /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). -#if compiler(>=6.0) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext public func withSpan( _ operationName: String, @@ -346,11 +345,8 @@ public func withSpan( try await operation(anySpan) } } -#endif -#if compiler(>=6.0) @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") -#endif /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. /// @@ -413,7 +409,6 @@ public func withSpan( /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). -#if compiler(>=6.0) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext public func withSpan( _ operationName: String, @@ -437,11 +432,8 @@ public func withSpan( try await operation(anySpan) } } -#endif -#if compiler(>=6.0) @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") -#endif @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. @@ -502,7 +494,6 @@ public func withSpan( /// - operation: The operation that this span should be measuring /// - Returns: the value returned by `operation` /// - Throws: the error the `operation` has thrown (if any) -#if compiler(>=6.0) @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func withSpan( _ operationName: String, @@ -527,11 +518,8 @@ public func withSpan( try await operation(anySpan) } } -#endif -#if compiler(>=6.0) @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") -#endif /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. /// diff --git a/Sources/Tracing/TracerProtocol+Legacy.swift b/Sources/Tracing/TracerProtocol+Legacy.swift index 7bf2a68d..ae08b882 100644 --- a/Sources/Tracing/TracerProtocol+Legacy.swift +++ b/Sources/Tracing/TracerProtocol+Legacy.swift @@ -296,6 +296,7 @@ extension LegacyTracer { /// /// - Parameters: /// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on. + /// - instant: the time instant at which the span started. /// - context: The `ServiceContext` providing information on where to start the new ``Span``. /// - kind: The ``SpanKind`` of the new ``Span``. /// - isolation: Defaulted parameter for inheriting isolation of calling actor. @@ -305,7 +306,6 @@ extension LegacyTracer { /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). - #if compiler(>=6.0) public func withAnySpan( _ operationName: String, at instant: @autoclosure () -> Instant, @@ -336,12 +336,9 @@ extension LegacyTracer { throw error // rethrow } } - #endif - #if compiler(>=6.0) // swift-format-ignore: Spacing // fights with formatter @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") - #endif /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. /// @@ -411,7 +408,6 @@ extension LegacyTracer { /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). - #if compiler(>=6.0) public func withAnySpan( _ operationName: String, context: @autoclosure () -> ServiceContext = .current ?? .topLevel, @@ -441,12 +437,9 @@ extension LegacyTracer { throw error // rethrow } } - #endif - #if compiler(>=6.0) // swift-format-ignore: Spacing // fights with formatter @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") - #endif /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. /// @@ -629,7 +622,6 @@ extension Tracer { /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). - #if compiler(>=6.0) public func withAnySpan( _ operationName: String, at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now, @@ -653,12 +645,9 @@ extension Tracer { try await operation(span) } } - #endif - #if compiler(>=6.0) // swift-format-ignore: Spacing // fights with formatter @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") - #endif /// Start a new span and automatically end when the operation completes, /// including recording the error in case the operation throws. /// diff --git a/Sources/Tracing/TracerProtocol.swift b/Sources/Tracing/TracerProtocol.swift index dc08f483..1d4f045a 100644 --- a/Sources/Tracing/TracerProtocol.swift +++ b/Sources/Tracing/TracerProtocol.swift @@ -251,7 +251,6 @@ extension Tracer { /// - operationName: The name of the operation being traced. This may be a handler function, a database call, and so on. /// - context: The `ServiceContext` providing information on where to start the new ``Span``. /// - kind: The ``SpanKind`` of the new ``Span``. - /// - instant: the time instant at which the span started. /// - isolation: Defaulted parameter for inheriting isolation of calling actor. /// - function: The function name in which the span started. /// - fileID: The `fileID` where the span started. @@ -259,7 +258,6 @@ extension Tracer { /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). - #if compiler(>=6.0) public func withSpan( _ operationName: String, context: @autoclosure () -> ServiceContext = .current ?? .topLevel, @@ -289,12 +287,9 @@ extension Tracer { throw error // rethrow } } - #endif - #if compiler(>=6.0) // swift-format-ignore: Spacing // fights with formatter @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") - #endif public func withSpan( _ operationName: String, context: @autoclosure () -> ServiceContext = .current ?? .topLevel, @@ -347,7 +342,6 @@ extension Tracer { /// - operation: The operation that this span measures. /// - Returns: the value returned by `operation`. /// - Throws: the error the `operation` throws (if any). - #if compiler(>=6.0) public func withSpan( _ operationName: String, context: @autoclosure () -> ServiceContext = .current ?? .topLevel, @@ -378,12 +372,9 @@ extension Tracer { throw error // rethrow } } - #endif - #if compiler(>=6.0) // swift-format-ignore: Spacing // fights with formatter @_disfavoredOverload @available(*, deprecated, message: "Prefer #isolation version of this API") - #endif /// Start a new span and automatically end it when the operation completes, /// including recording the error in case the operation throws. /// diff --git a/Tests/TracingTests/DynamicTracepointTracerTests.swift b/Tests/TracingTests/DynamicTracepointTracerTests.swift index aa41f426..5acb1bad 100644 --- a/Tests/TracingTests/DynamicTracepointTracerTests.swift +++ b/Tests/TracingTests/DynamicTracepointTracerTests.swift @@ -174,7 +174,6 @@ final class DynamicTracepointTestTracer: LegacyTracer { } private func shouldRecord(tracepoint: TracepointID) -> Bool { - #if canImport(_Concurrency) if self.isActive(tracepoint: tracepoint) { // this tracepoint was specifically activated! return true @@ -193,9 +192,6 @@ final class DynamicTracepointTestTracer: LegacyTracer { // there is some active trace already, so we should record as well // TODO: this logic may need to become smarter return true - #else - return false - #endif } func isActive(tracepoint: TracepointID) -> Bool { diff --git a/Tests/TracingTests/TracerTests.swift b/Tests/TracingTests/TracerTests.swift index 607b725f..16c8b9d5 100644 --- a/Tests/TracingTests/TracerTests.swift +++ b/Tests/TracingTests/TracerTests.swift @@ -108,7 +108,6 @@ final class TracerTests: XCTestCase { } func testWithSpan_automaticBaggagePropagation_sync() throws { - #if canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else { throw XCTSkip("Task locals are not supported on this platform.") } @@ -133,11 +132,9 @@ final class TracerTests: XCTestCase { XCTAssertEqual(value, "world") XCTAssertTrue(spanEnded) - #endif } func testWithSpan_automaticBaggagePropagation_sync_throws() throws { - #if canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else { throw XCTSkip("Task locals are not supported on this platform.") } @@ -163,11 +160,9 @@ final class TracerTests: XCTestCase { return } XCTFail("Should have thrown") - #endif } func testWithSpan_automaticBaggagePropagation_async() throws { - #if canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else { throw XCTSkip("Task locals are not supported on this platform.") } @@ -194,7 +189,6 @@ final class TracerTests: XCTestCase { XCTAssertEqual(value, "world") XCTAssertTrue(spanEnded.withValue { $0 }) } - #endif } func testWithSpan_enterFromNonAsyncCode_passBaggage_asyncOperation() throws { @@ -321,7 +315,6 @@ final class TracerTests: XCTestCase { } func testWithSpan_recordErrorWithAttributes() throws { - #if canImport(_Concurrency) guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else { throw XCTSkip("Task locals are not supported on this platform.") } @@ -348,7 +341,6 @@ final class TracerTests: XCTestCase { XCTAssertEqual(error as! ExampleSpanError, errorToThrow) let attrs = endedSpan!.recordedErrors.first!.1 XCTAssertEqual(attrs, attrsForError) - #endif } func testWithSpanSignatures() {