diff --git a/.swiftformat b/.swiftformat index 1084e4c54..e639ee783 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,10 +1,12 @@ # file options +--exclude .build + # format options ---self insert ---patternlet inline ---stripunusedargs unnamed-only +--self insert +--patternlet inline +--stripunusedargs unnamed-only --comments ignore # rules diff --git a/Sources/AsyncHTTPClient/HTTPHandler.swift b/Sources/AsyncHTTPClient/HTTPHandler.swift index 20c6fec7f..45810daf2 100644 --- a/Sources/AsyncHTTPClient/HTTPHandler.swift +++ b/Sources/AsyncHTTPClient/HTTPHandler.swift @@ -19,7 +19,6 @@ import NIOHTTP1 import NIOSSL extension HTTPClient { - /// Represent request body. public struct Body { /// Chunk provider. @@ -333,7 +332,7 @@ extension HTTPClientResponseDelegate { public func didSendRequest(task: HTTPClient.Task) {} - public func didReceiveHead(task: HTTPClient.Task, _: HTTPResponseHead) -> EventLoopFuture { return task.eventLoop.makeSucceededFuture(()) } + public func didReceiveHead(task: HTTPClient.Task, _: HTTPResponseHead) -> EventLoopFuture { return task.eventLoop.makeSucceededFuture(()) } public func didReceivePart(task: HTTPClient.Task, _: ByteBuffer) -> EventLoopFuture { return task.eventLoop.makeSucceededFuture(()) } diff --git a/Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift b/Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift index 486a4e249..7c19cde2c 100644 --- a/Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift +++ b/Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift @@ -194,4 +194,3 @@ class HTTPClientInternalTests: XCTestCase { XCTAssertEqual(delegate.reads, 3) } } - diff --git a/Tests/AsyncHTTPClientTests/HTTPClientTests.swift b/Tests/AsyncHTTPClientTests/HTTPClientTests.swift index 8e0a61230..c6a7f664b 100644 --- a/Tests/AsyncHTTPClientTests/HTTPClientTests.swift +++ b/Tests/AsyncHTTPClientTests/HTTPClientTests.swift @@ -44,7 +44,7 @@ class HTTPClientTests: XCTestCase { let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/get").wait() XCTAssertEqual(.ok, response.status) } - + func testGetWithSharedEventLoopGroup() throws { let httpBin = HttpBin() let elg = MultiThreadedEventLoopGroup(numberOfThreads: 8) @@ -53,12 +53,12 @@ class HTTPClientTests: XCTestCase { try! elg.syncShutdownGracefully() httpBin.shutdown() } - + let delegate = TestHTTPDelegate() let request = try HTTPClient.Request(url: "http://localhost:\(httpBin.port)/events/10/1") let task = httpClient.execute(request: request, delegate: delegate) let expectedEventLoop = task.eventLoop - task.futureResult.whenComplete { (_) in + task.futureResult.whenComplete { _ in XCTAssertTrue(expectedEventLoop.inEventLoop) } try task.wait() @@ -154,7 +154,7 @@ class HTTPClientTests: XCTestCase { let hostName = try decoder.decode([String: String].self, from: responseData)["data"] XCTAssert(hostName == "127.0.0.1") } - + func testPercentEncoded() throws { let httpBin = HttpBin() let httpClient = HTTPClient(eventLoopGroupProvider: .createNew) @@ -162,7 +162,7 @@ class HTTPClientTests: XCTestCase { try! httpClient.syncShutdown() httpBin.shutdown() } - + let response = try httpClient.get(url: "http://localhost:\(httpBin.port)/percent%20encoded").wait() XCTAssertEqual(.ok, response.status) } diff --git a/docker/Dockerfile b/docker/Dockerfile index b177481f3..9fb59d73c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,6 +23,13 @@ RUN gem install jazzy --no-ri --no-rdoc RUN mkdir -p $HOME/.tools RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile -# script to allow mapping framepointers on linux +# script to allow mapping framepointers on linux (until part of the toolchain) RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.tools/symbolicate-linux-fatal RUN chmod 755 $HOME/.tools/symbolicate-linux-fatal + +# swiftformat (until part of the toolchain) + +ARG swiftformat_version=0.40.11 +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/scripts/sanity.sh b/scripts/sanity.sh index 999cb0d4d..04f1c5f2e 100755 --- a/scripts/sanity.sh +++ b/scripts/sanity.sh @@ -28,10 +28,23 @@ else printf "\033[0;32mokay.\033[0m\n" fi -printf "=> Checking license headers... " +printf "=> Checking format... " +FIRST_OUT="$(git status --porcelain)" +swiftformat . > /dev/null 2>&1 +SECOND_OUT="$(git status --porcelain)" +if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then + printf "\033[0;31mformatting issues!\033[0m\n" + git --no-pager diff + exit 1 +else + printf "\033[0;32mokay.\033[0m\n" +fi + +printf "=> Checking license headers\n" tmp=$(mktemp /tmp/.async-http-client-sanity_XXXXXX) for language in swift-or-c bash dtrace; do + printf " * $language... " declare -a matching_files declare -a exceptions expections=( )