From 4355b3a00fadc6fa3f2b446f7da4c6532b09d999 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Thu, 26 Oct 2023 10:04:55 +0200 Subject: [PATCH] Enable more CI warnings (#347) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable more CI warnings ### Motivation Fixes https://github.com/apple/swift-openapi-generator/issues/332 and re-enables warnings as errors as we don't have deprecation warnings in our tests anymore. ### Modifications Enabled a few previously disabled warnings/errors. ### Result Stricter CI. ### Test Plan The CI on this PR. Reviewed by: PeterAdams-A Builds: ✔︎ pull request validation (5.10) - Build finished. ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (compatibility test) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (integration test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. https://github.com/apple/swift-openapi-generator/pull/347 --- .../Extensions/Foundation.swift | 8 +++++++- Sources/swift-openapi-generator/Extensions.swift | 15 +++++++++++---- docker/docker-compose.2204.510.yaml | 5 +---- docker/docker-compose.2204.58.yaml | 16 ++-------------- docker/docker-compose.2204.59.yaml | 5 +---- docker/docker-compose.2204.main.yaml | 16 ++-------------- 6 files changed, 24 insertions(+), 41 deletions(-) diff --git a/Sources/_OpenAPIGeneratorCore/Extensions/Foundation.swift b/Sources/_OpenAPIGeneratorCore/Extensions/Foundation.swift index b11b0252..2d6dc601 100644 --- a/Sources/_OpenAPIGeneratorCore/Extensions/Foundation.swift +++ b/Sources/_OpenAPIGeneratorCore/Extensions/Foundation.swift @@ -13,6 +13,12 @@ //===----------------------------------------------------------------------===// import Foundation +#if compiler(>=5.11) +extension FileHandle: @retroactive TextOutputStream {} +#else +extension FileHandle: TextOutputStream {} +#endif + extension InMemoryInputFile { /// Creates a new in-memory file by reading the contents at the specified path. /// - Parameter url: The path to the file to read. @@ -23,7 +29,7 @@ extension InMemoryInputFile { /// File handle to stderr. let stdErrHandle = FileHandle.standardError -extension FileHandle: TextOutputStream { +extension FileHandle { /// Writes the given string to the file handle. /// /// This method writes the provided string to the file handle using its UTF-8 diff --git a/Sources/swift-openapi-generator/Extensions.swift b/Sources/swift-openapi-generator/Extensions.swift index 60778331..e847da49 100644 --- a/Sources/swift-openapi-generator/Extensions.swift +++ b/Sources/swift-openapi-generator/Extensions.swift @@ -16,7 +16,17 @@ import ArgumentParser import _OpenAPIGeneratorCore import Yams -extension URL: ExpressibleByArgument { +#if compiler(>=5.11) +extension URL: @retroactive ExpressibleByArgument {} +extension GeneratorMode: @retroactive ExpressibleByArgument {} +extension FeatureFlag: @retroactive ExpressibleByArgument {} +#else +extension URL: ExpressibleByArgument {} +extension GeneratorMode: ExpressibleByArgument {} +extension FeatureFlag: ExpressibleByArgument {} +#endif + +extension URL { /// Creates a `URL` instance from a string argument. /// @@ -25,9 +35,6 @@ extension URL: ExpressibleByArgument { public init?(argument: String) { self.init(fileURLWithPath: argument) } } -extension GeneratorMode: ExpressibleByArgument {} -extension FeatureFlag: ExpressibleByArgument {} - extension CaseIterable where Self: RawRepresentable, Self.RawValue == String { /// A string representation of the raw values of all the cases, diff --git a/docker/docker-compose.2204.510.yaml b/docker/docker-compose.2204.510.yaml index c6defa41..893d6826 100644 --- a/docker/docker-compose.2204.510.yaml +++ b/docker/docker-compose.2204.510.yaml @@ -11,10 +11,7 @@ services: image: *image environment: - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors - # SwiftSyntax currently imports a module it does not explicitly depend - # on and so we must disable this for the time being. - # - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error + - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete - shell: image: *image diff --git a/docker/docker-compose.2204.58.yaml b/docker/docker-compose.2204.58.yaml index 8e6f7ef9..b2b4c827 100644 --- a/docker/docker-compose.2204.58.yaml +++ b/docker/docker-compose.2204.58.yaml @@ -11,20 +11,8 @@ services: test: image: *image environment: - # Because OpenAPI supports deprecation, the generated code could include - # deprecated symbols, which will produce warnings. - # - # We'll disable -warnings-as-errors for now and revisit this when we - # refactor the compilation of the generated code into a separate - # pipeline. - # - # - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors - - # SwiftSyntax currently imports a module it does not explicitly depend - # on and so we must disable this for the time being. - # - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - + - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors + - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete - shell: image: *image diff --git a/docker/docker-compose.2204.59.yaml b/docker/docker-compose.2204.59.yaml index b26c61fb..d5a60644 100644 --- a/docker/docker-compose.2204.59.yaml +++ b/docker/docker-compose.2204.59.yaml @@ -12,10 +12,7 @@ services: image: *image environment: - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors - # SwiftSyntax currently imports a module it does not explicitly depend - # on and so we must disable this for the time being. - # - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error + - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete - shell: image: *image diff --git a/docker/docker-compose.2204.main.yaml b/docker/docker-compose.2204.main.yaml index 9b940b98..d59e7ce2 100644 --- a/docker/docker-compose.2204.main.yaml +++ b/docker/docker-compose.2204.main.yaml @@ -11,20 +11,8 @@ services: test: image: *image environment: - # Because OpenAPI supports deprecation, the generated code could include - # deprecated symbols, which will produce warnings. - # - # We'll disable -warnings-as-errors for now and revisit this when we - # refactor the compilation of the generated code into a separate - # pipeline. - # - # - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors - - # SwiftSyntax currently imports a module it does not explicitly depend - # on and so we must disable this for the time being. - # - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - + - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors + - IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error - STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete - shell: image: *image