Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Make all CI checks green #68

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Main
on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
Expand All @@ -21,6 +23,12 @@ jobs:
windows_nightly_6_0_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"

benchmarks:
name: Benchmarks
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "Benchmarks"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
windows_nightly_6_0_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"

benchmarks:
name: Benchmarks
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "Benchmarks"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
26 changes: 0 additions & 26 deletions .github/workflows/scheduled.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.editorconfig
.github/*
*.md
*.txt
*.yml
*.yaml
*.json
Package.swift
**/Package.swift
Package@-*.swift
**/Package@-*.swift
Package.resolved
**/Package.resolved
Makefile
*.modulemap
**/*.modulemap
**/*.docc/*
*.xcprivacy
**/*.xcprivacy
*.symlink
**/*.symlink
Dockerfile
**/Dockerfile
Sources/CMakeLists.txt
Sources/SwiftASN1/CMakeLists.txt
dev/alloc-limits-from-test-output
dev/boxed-existentials.d
dev/git.commit.template
dev/lldb-smoker
dev/make-single-file-spm
dev/malloc-aggregation.d
dev/update-alloc-limits-to-last-completed-ci-build
Benchmarks/Benchmarks/SwiftASN1Benchmark/ca-certificates/*.crt
Benchmarks/Benchmarks/SwiftASN1Benchmark/ca-certificates/*/*.crt
62 changes: 62 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"tabWidth" : 4,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 120,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
21 changes: 0 additions & 21 deletions .swiftformat

This file was deleted.

12 changes: 11 additions & 1 deletion Benchmarks/Benchmarks/HTTPFieldsBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ import Benchmark
import HTTPTypes

let benchmarks = {
let defaultMetrics: [BenchmarkMetric] = [
.mallocCountTotal
]

Benchmark(
"Initialize HTTPFields from Dictionary Literal"
"HTTPFields.init(dictionaryLiteral)",
configuration: .init(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { _ in
let fiels: HTTPFields = [
.contentType: "application/json",
Expand Down
6 changes: 3 additions & 3 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "Benchmarks",
platforms: [
.macOS(.v13),
.macOS(.v13)
],
dependencies: [
.package(path: "../"),
Expand All @@ -20,8 +20,8 @@ let package = Package(
],
path: "Benchmarks/HTTPFieldsBenchmarks",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 14
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 14
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 14
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 14
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 14
}
9 changes: 3 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@ let package = Package(
.library(name: "HTTPTypes", targets: ["HTTPTypes"]),
.library(name: "HTTPTypesFoundation", targets: ["HTTPTypesFoundation"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
],
targets: [
.target(name: "HTTPTypes"),
.target(
name: "HTTPTypesFoundation",
dependencies: [
"HTTPTypes",
"HTTPTypes"
]
),
.testTarget(
name: "HTTPTypesTests",
dependencies: [
"HTTPTypes",
"HTTPTypes"
]
),
.testTarget(
name: "HTTPTypesFoundationTests",
dependencies: [
"HTTPTypesFoundation",
"HTTPTypesFoundation"
]
),
]
Expand Down
40 changes: 25 additions & 15 deletions Sources/HTTPTypes/HTTPField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public struct HTTPField: Sendable, Hashable {
///
/// - Parameter body: The closure to be invoked with the buffer.
/// - Returns: Result of the `body` closure.
public func withUnsafeBytesOfValue<Result>(_ body: (UnsafeBufferPointer<UInt8>) throws -> Result) rethrows -> Result {
public func withUnsafeBytesOfValue<Result>(
_ body: (UnsafeBufferPointer<UInt8>) throws -> Result
) rethrows -> Result {
try self.rawValue.withUnsafeBytes(body)
}

Expand All @@ -135,7 +137,7 @@ public struct HTTPField: Sendable, Hashable {
switch byte {
case 0x09, 0x20:
break
case 0x21 ... 0x7E, 0x80 ... 0xFF:
case 0x21...0x7E, 0x80...0xFF:
break
default:
return false
Expand All @@ -161,13 +163,15 @@ public struct HTTPField: Sendable, Hashable {
switch byte {
case 0x09, 0x20:
return byte
case 0x21 ... 0x7E, 0x80 ... 0xFF:
case 0x21...0x7E, 0x80...0xFF:
return byte
default:
return 0x20
}
}
let trimmed = bytes.reversed().drop { $0 == 0x09 || $0 == 0x20 }.reversed().drop { $0 == 0x09 || $0 == 0x20 }
let trimmed = bytes.reversed().drop { $0 == 0x09 || $0 == 0x20 }.reversed().drop {
$0 == 0x09 || $0 == 0x20
}
return ISOLatin1String(unchecked: String(decoding: trimmed, as: UTF8.self))
}
}
Expand Down Expand Up @@ -242,27 +246,33 @@ extension HTTPField: Codable {
let name = try container.decode(Name.self, forKey: .name)
let value = try container.decode(String.self, forKey: .value)
guard Self.isValidValue(value) else {
throw DecodingError.dataCorruptedError(forKey: .value, in: container, debugDescription: "HTTP field value \"\(value)\" contains invalid characters")
throw DecodingError.dataCorruptedError(
forKey: .value,
in: container,
debugDescription: "HTTP field value \"\(value)\" contains invalid characters"
)
}
self.init(name: name, uncheckedValue: ISOLatin1String(unchecked: value))
if let indexingStrategyValue = try container.decodeIfPresent(UInt8.self, forKey: .indexingStrategy),
let indexingStrategy = DynamicTableIndexingStrategy(rawValue: indexingStrategyValue) {
let indexingStrategy = DynamicTableIndexingStrategy(rawValue: indexingStrategyValue)
{
self.indexingStrategy = indexingStrategy
}
}
}

extension HTTPField {
static func isValidToken(_ token: some StringProtocol) -> Bool {
!token.isEmpty && token.utf8.allSatisfy {
switch $0 {
case 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A, 0x2B, 0x2D, 0x2E, 0x5E, 0x5F, 0x60, 0x7C, 0x7E:
return true
case 0x30 ... 0x39, 0x41 ... 0x5A, 0x61 ... 0x7A: // DIGHT, ALPHA
return true
default:
return false
!token.isEmpty
&& token.utf8.allSatisfy {
switch $0 {
case 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A, 0x2B, 0x2D, 0x2E, 0x5E, 0x5F, 0x60, 0x7C, 0x7E:
return true
case 0x30...0x39, 0x41...0x5A, 0x61...0x7A: // DIGHT, ALPHA
return true
default:
return false
}
}
}
}
}
Loading
Loading