Skip to content

Commit

Permalink
1.x.x - Updates from project template (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Feb 18, 2024
1 parent c795631 commit 6a9c81a
Show file tree
Hide file tree
Showing 23 changed files with 60 additions and 75 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
groups:
dependencies:
patterns:
- "*"
- package-ecosystem: "swift"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 6
allow:
- dependency-type: all
groups:
all-dependencies:
patterns:
- "*"
4 changes: 2 additions & 2 deletions .github/workflows/api-breakage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
linux:
runs-on: ubuntu-latest
container:
image: swift:5.8
image: swift:5.9
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: SPM tests
run: swift test --enable-code-coverage
- name: Convert coverage files
Expand All @@ -42,13 +42,12 @@ jobs:
- 'swift:5.7'
- 'swift:5.8'
- 'swift:5.9'
#- 'swiftlang/swift:nightly-5.10-jammy'

container:
image: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Test
run: |
swift test --enable-code-coverage
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/codeql.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: SPM tests
run: swift test
linux:
Expand All @@ -23,7 +23,7 @@ jobs:
image: swiftlang/swift:${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Test
run: |
swift test --enable-test-discovery
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
brew install mint
mint install NickLockwood/SwiftFormat@0.48.17 --no-link
mint install NickLockwood/SwiftFormat@0.51.15 --no-link
- name: run script
run: ./scripts/validate.sh
6 changes: 3 additions & 3 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Minimum swiftformat version
--minversion 0.47.4
--minversion 0.51.0

# Swift version
--swiftversion 5.3
--swiftversion 5.7

# file options
--exclude .build

# rules
--disable redundantReturn, extensionAccessControl
--disable redundantReturn, extensionAccessControl, opaqueGenericParameters, typeSugar

# format options
--ifdef no-indent
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Sources/HBPerformance/EmbeddedApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct HBEmbeddedApplication {
// write request
let requestHead = HTTPRequestHead(version: .init(major: 1, minor: 1), method: method, uri: uri, headers: headers)
try writeInbound(.head(requestHead))
if let body = body {
if let body {
try self.writeInbound(.body(body))
}
try self.writeInbound(.end(nil))
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Legal
By submitting a pull request, you represent that you have the right to license your contribution to the community, and agree by submitting the patch
that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE.txt)).
that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE)).

## Contributor Conduct
All contributors are expected to adhere to the project's [Code of Conduct](CODE_OF_CONDUCT.md).
Expand Down Expand Up @@ -30,4 +30,4 @@ The main development branch of the repository is `main`.

### Formatting

We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.48.17.
We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.51.15.
8 changes: 4 additions & 4 deletions Sources/Hummingbird/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension HBApplication {
self.threadPoolSize = threadPoolSize
self.noHTTPServer = noHTTPServer

if let logLevel = logLevel {
if let logLevel {
self.logLevel = logLevel
} else if let logLevel = env.get("LOG_LEVEL") {
self.logLevel = Logger.Level(rawValue: logLevel) ?? .info
Expand Down Expand Up @@ -169,7 +169,7 @@ extension HBApplication {
self.threadPoolSize = threadPoolSize
self.noHTTPServer = noHTTPServer

if let logLevel = logLevel {
if let logLevel {
self.logLevel = logLevel
} else if let logLevel = env.get("LOG_LEVEL") {
self.logLevel = Logger.Level(rawValue: logLevel) ?? .info
Expand Down Expand Up @@ -223,7 +223,7 @@ extension HBApplication {
self.threadPoolSize = threadPoolSize
self.noHTTPServer = noHTTPServer

if let logLevel = logLevel {
if let logLevel {
self.logLevel = logLevel
} else if let logLevel = env.get("LOG_LEVEL") {
self.logLevel = Logger.Level(rawValue: logLevel) ?? .info
Expand Down Expand Up @@ -277,7 +277,7 @@ extension HBApplication {
self.threadPoolSize = threadPoolSize
self.noHTTPServer = noHTTPServer

if let logLevel = logLevel {
if let logLevel {
self.logLevel = logLevel
} else if let logLevel = env.get("LOG_LEVEL") {
self.logLevel = Logger.Level(rawValue: logLevel) ?? .info
Expand Down
4 changes: 2 additions & 2 deletions Sources/Hummingbird/HTTP/MediaType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public struct HBMediaType: Sendable, CustomStringConvertible {
break
}
}
if let category = category,
let subCategory = subCategory
if let category,
let subCategory
{
self.type = category
self.subType = subCategory.lowercased()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/HTTP/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ extension HBParameters {
/// Initialize parameters from parser struct
/// - Parameter query: parser holding query strings
init(fromQuery query: HBParser?) {
guard var query = query else {
guard var query else {
self.parameters = .init()
return
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Router/TrieRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct RouterPathTrie<Value> {
}
}

extension Optional where Wrapped == HBParameters {
extension Optional<HBParameters> {
mutating func set(_ s: Substring, value: Substring) {
switch self {
case .some(var parameters):
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Server/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private extension CodingKey {
}
}

private extension Array where Element == CodingKey {
private extension Array<CodingKey> {
/// returns a path key using a dot character as a separator
var pathKeyValue: String {
map(\.pathKeyValue).joined(separator: ".")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Server/ResponsePatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension HBRequest {
extension HBResponse {
/// apply `HBRequest.ResponsePatch` to `HBResponse`
mutating func apply(patch: HBRequest.ResponsePatch?) -> Self {
guard let patch = patch else { return self }
guard let patch else { return self }
if let status = patch.status {
self.status = status
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Hummingbird/Utils/FlatDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public struct FlatDictionary<Key: Hashable, Value>: Collection, ExpressibleByDic
set {
let hashKey = Self.hashKey(key)
if let index = hashKeys.firstIndex(of: hashKey) {
if let newValue = newValue {
if let newValue {
self.elements[index].value = newValue
} else {
self.elements.remove(at: index)
self.hashKeys.remove(at: index)
}
} else if let newValue = newValue {
} else if let newValue {
self.elements.append((key: key, value: newValue))
self.hashKeys.append(hashKey)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Utils/HBParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ extension Unicode.Scalar {
}
}

extension Set where Element == Unicode.Scalar {
extension Set<Unicode.Scalar> {
public init(_ string: String) {
self = Set(string.unicodeScalars)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdFoundation/Files/FileIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public struct HBFileIO {
let futureResult: EventLoopFuture<Void>
switch contents {
case .byteBuffer(let buffer):
guard let buffer = buffer else { return context.eventLoop.makeSucceededVoidFuture() }
guard let buffer else { return context.eventLoop.makeSucceededVoidFuture() }
futureResult = self.writeFile(buffer: buffer, handle: handle, on: context.eventLoop)
case .stream(let streamer):
futureResult = self.writeFile(stream: streamer, handle: handle, on: context.eventLoop)
Expand Down
12 changes: 6 additions & 6 deletions Sources/HummingbirdFoundation/Files/FileMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ public struct HBFileMiddleware: HBMiddleware {
var headers = HTTPHeaders()

// content-length
if let contentSize = contentSize {
if let contentSize {
headers.add(name: "content-length", value: String(describing: contentSize))
}
// modified-date
var modificationDateString: String?
if let modificationDate = modificationDate {
if let modificationDate {
modificationDateString = HBDateCache.rfc1123Formatter.string(from: modificationDate)
headers.add(name: "modified-date", value: modificationDateString!)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public struct HBFileMiddleware: HBMiddleware {
}
// verify if-modified-since
else if let ifModifiedSince = request.headers["if-modified-since"].first,
let modificationDate = modificationDate
let modificationDate
{
if let ifModifiedSinceDate = HBDateCache.rfc1123Formatter.date(from: ifModifiedSince) {
// round modification date of file down to seconds for comparison
Expand All @@ -170,7 +170,7 @@ public struct HBFileMiddleware: HBMiddleware {
if let ifRange = request.headers["if-range"].first, ifRange != headers["eTag"].first, ifRange != headers["modified-date"].first {
// do nothing and drop down to returning full file
} else {
if let contentSize = contentSize {
if let contentSize {
let lowerBound = max(range.lowerBound, 0)
let upperBound = min(range.upperBound, contentSize - 1)
headers.replaceOrAdd(name: "content-range", value: "bytes \(lowerBound)-\(upperBound)/\(contentSize)")
Expand All @@ -188,7 +188,7 @@ public struct HBFileMiddleware: HBMiddleware {
case .loadFile(let headers, let range):
switch request.method {
case .GET:
if let range = range {
if let range {
return self.fileIO.loadFile(path: fullPath.relativePath, range: range, context: request.context, logger: request.logger)
.map { body, _ in
return HBResponse(status: .partialContent, headers: headers, body: body)
Expand Down Expand Up @@ -276,7 +276,7 @@ extension HBFileMiddleware {
}
}

extension Sequence where Element == UInt8 {
extension Sequence<UInt8> {
/// return a hexEncoded string buffer from an array of bytes
func hexDigest() -> String {
return self.map { String(format: "%02x", $0) }.joined(separator: "")
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdJobs/JobQueueWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class HBJobQueueWorker {
}
return self.queue.pop(on: eventLoop)
.map { value in
if let value = value {
if let value {
promise.succeed(value)
task.cancel()
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/HummingbirdXCT/HBXCTAsyncTesting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct HBXCTAsyncTesting: HBXCT {
// shutdown eventloop
try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
self.asyncTestingEventLoop.shutdownGracefully { error in
if let error = error {
if let error {
cont.resume(throwing: error)
} else {
cont.resume()
Expand Down Expand Up @@ -95,7 +95,7 @@ struct HBXCTAsyncTesting: HBXCT {
// write request
let requestHead = HTTPRequestHead(version: .init(major: 1, minor: 1), method: method, uri: uri, headers: headers)
try await writeInbound(.head(requestHead))
if let body = body {
if let body {
try await self.writeInbound(.body(body))
}
try await self.writeInbound(.end(nil))
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdXCT/HBXCTEmbedded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct HBXCTEmbedded: HBXCT {
// write request
let requestHead = HTTPRequestHead(version: .init(major: 1, minor: 1), method: method, uri: uri, headers: headers)
try writeInbound(.head(requestHead))
if let body = body {
if let body {
try self.writeInbound(.body(body))
}
try self.writeInbound(.end(nil))
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##
##===----------------------------------------------------------------------===##

SWIFT_FORMAT_VERSION=0.48.17
SWIFT_FORMAT_VERSION=0.51.15

set -eu
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand Down

0 comments on commit 6a9c81a

Please sign in to comment.