diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c59ce1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +trim_trailing_whitespace = true + +# 4 space indentation +[*.swift] +indent_style = space +indent_size = 4 \ No newline at end of file diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 925b17f..5394a25 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -7,11 +7,11 @@ on: jobs: doc: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Publish Jazzy Docs uses: steven0351/publish-jazzy-docs@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7090a36..89d0484 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,14 +10,16 @@ on: jobs: test: - runs-on: macos-11 + runs-on: macos-latest steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Lint code - run: swiftlint lint + - name: Lint PR code + uses: stanfordbdhg/action-swiftlint@v4 + env: + DIFF_BASE: ${{ github.base_ref }} - name: Run tests - run: swift test --enable-test-discovery + run: swift test diff --git a/Sources/SimpleHTTP/Interceptor/CompositeInterceptor.swift b/Sources/SimpleHTTP/Interceptor/CompositeInterceptor.swift index 4b1c168..4fe98a5 100644 --- a/Sources/SimpleHTTP/Interceptor/CompositeInterceptor.swift +++ b/Sources/SimpleHTTP/Interceptor/CompositeInterceptor.swift @@ -1,5 +1,4 @@ import Foundation -import Combine /// Use an Array of `Interceptor` as a single `Interceptor` public struct CompositeInterceptor: ExpressibleByArrayLiteral, Sequence { diff --git a/Sources/SimpleHTTP/Interceptor/Interceptor.swift b/Sources/SimpleHTTP/Interceptor/Interceptor.swift index be3a8be..5486e2a 100644 --- a/Sources/SimpleHTTP/Interceptor/Interceptor.swift +++ b/Sources/SimpleHTTP/Interceptor/Interceptor.swift @@ -1,5 +1,4 @@ import Foundation -import Combine public typealias Interceptor = RequestInterceptor & ResponseInterceptor diff --git a/Sources/SimpleHTTPFoundation/Foundation/URLRequest/URLRequest+URL.swift b/Sources/SimpleHTTPFoundation/Foundation/URLRequest/URLRequest+URL.swift index 2e69001..854efd8 100644 --- a/Sources/SimpleHTTPFoundation/Foundation/URLRequest/URLRequest+URL.swift +++ b/Sources/SimpleHTTPFoundation/Foundation/URLRequest/URLRequest+URL.swift @@ -1,5 +1,9 @@ import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + extension URLRequest { /// Return a new URLRequest whose path is relative to `baseURL` public func relativeTo(_ baseURL: URL) -> URLRequest { diff --git a/Sources/SimpleHTTPFoundation/Foundation/URLSession+Async.swift b/Sources/SimpleHTTPFoundation/Foundation/URLSession+Async.swift index db5a0b7..a64ee86 100644 --- a/Sources/SimpleHTTPFoundation/Foundation/URLSession+Async.swift +++ b/Sources/SimpleHTTPFoundation/Foundation/URLSession+Async.swift @@ -1,5 +1,9 @@ import Foundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + extension URLSession { @available(iOS, deprecated: 15.0, message: "Use built-in API instead") public func data(for urlRequest: URLRequest) async throws -> (Data, URLResponse) { diff --git a/Tests/SimpleHTTPFoundationTests/Foundation/URLRequest/URLRequestTests+URL.swift b/Tests/SimpleHTTPFoundationTests/Foundation/URLRequest/URLRequestTests+URL.swift index 3d18b40..c7f0365 100644 --- a/Tests/SimpleHTTPFoundationTests/Foundation/URLRequest/URLRequestTests+URL.swift +++ b/Tests/SimpleHTTPFoundationTests/Foundation/URLRequest/URLRequestTests+URL.swift @@ -2,6 +2,10 @@ import Foundation import XCTest @testable import SimpleHTTPFoundation +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif + class URLRequestURLTests: XCTestCase { func test_relativeTo_requestURLHasBaseURL() { let request = URLRequest(url: URL(string: "path")!) diff --git a/Tests/SimpleHTTPTests/Response/URLDataResponseTests.swift b/Tests/SimpleHTTPTests/Response/URLDataResponseTests.swift index 635a56c..1ac6d9c 100644 --- a/Tests/SimpleHTTPTests/Response/URLDataResponseTests.swift +++ b/Tests/SimpleHTTPTests/Response/URLDataResponseTests.swift @@ -1,13 +1,7 @@ import XCTest -import Combine @testable import SimpleHTTP class URLDataResponseTests: XCTestCase { - var cancellables: Set = [] - - override func tearDown() { - cancellables = [] - } func test_validate_responseIsError_dataIsEmpty_converterIsNotCalled() throws { let response = URLDataResponse(data: Data(), response: HTTPURLResponse.notFound) diff --git a/Tests/SimpleHTTPTests/Session/SessionTests.swift b/Tests/SimpleHTTPTests/Session/SessionTests.swift index c147cb4..fee414f 100644 --- a/Tests/SimpleHTTPTests/Session/SessionTests.swift +++ b/Tests/SimpleHTTPTests/Session/SessionTests.swift @@ -1,5 +1,4 @@ import XCTest -import Combine @testable import SimpleHTTP class SessionAsyncTests: XCTestCase {