Skip to content

Commit f46277f

Browse files
committed
[CI] Make all CI checks green
# Motivation We just adopted GH actions and want to make sure all the CI checks are green. # Modification This PR makes the necessary changes to pass all checks. Including: - Adding a licenseignore file - Moving `swift-format` and adopting the config that we use in all other swift on server repos. # Result Green CI.
1 parent f9a647b commit f46277f

29 files changed

+541
-207
lines changed

.github/workflows/main.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
1515
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
1616
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
17-
windows_6_0_enabled: true
18-
windows_nightly_6_0_enabled: true
19-
windows_nightly_main_enabled: true
20-
windows_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
21-
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
22-
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
18+
benchmarks:
19+
name: Benchmarks
20+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
21+
with:
22+
benchmark_package_path: "Benchmarks"
2323

2424
cxx-interop:
2525
name: Cxx interop

.github/workflows/pull_request.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
2121
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
2222
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
23-
windows_6_0_enabled: true
24-
windows_nightly_6_0_enabled: true
25-
windows_nightly_main_enabled: true
26-
windows_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
27-
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
28-
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
23+
24+
benchmarks:
25+
name: Benchmarks
26+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
27+
with:
28+
benchmark_package_path: "Benchmarks"
2929

3030
cxx-interop:
3131
name: Cxx interop

.github/workflows/scheduled.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
1515
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
1616
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
17-
windows_6_0_enabled: true
18-
windows_nightly_6_0_enabled: true
19-
windows_nightly_main_enabled: true
20-
windows_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
21-
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
22-
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
18+
benchmarks:
19+
name: Benchmarks
20+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
21+
with:
22+
benchmark_package_path: "Benchmarks"
2323

2424
cxx-interop:
2525
name: Cxx interop

.licenseignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.editorconfig
11+
.github/*
12+
*.md
13+
*.txt
14+
*.yml
15+
*.yaml
16+
*.json
17+
Package.swift
18+
**/Package.swift
19+
Package@-*.swift
20+
**/Package@-*.swift
21+
Package.resolved
22+
**/Package.resolved
23+
Makefile
24+
*.modulemap
25+
**/*.modulemap
26+
**/*.docc/*
27+
*.xcprivacy
28+
**/*.xcprivacy
29+
*.symlink
30+
**/*.symlink
31+
Dockerfile
32+
**/Dockerfile
33+
Sources/CMakeLists.txt
34+
Sources/SwiftASN1/CMakeLists.txt
35+
dev/alloc-limits-from-test-output
36+
dev/boxed-existentials.d
37+
dev/git.commit.template
38+
dev/lldb-smoker
39+
dev/make-single-file-spm
40+
dev/malloc-aggregation.d
41+
dev/update-alloc-limits-to-last-completed-ci-build
42+
Benchmarks/Benchmarks/SwiftASN1Benchmark/ca-certificates/*.crt
43+
Benchmarks/Benchmarks/SwiftASN1Benchmark/ca-certificates/*/*.crt

.swift-format

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"version" : 1,
3+
"indentation" : {
4+
"spaces" : 4
5+
},
6+
"tabWidth" : 4,
7+
"fileScopedDeclarationPrivacy" : {
8+
"accessLevel" : "private"
9+
},
10+
"spacesAroundRangeFormationOperators" : false,
11+
"indentConditionalCompilationBlocks" : false,
12+
"indentSwitchCaseLabels" : false,
13+
"lineBreakAroundMultilineExpressionChainComponents" : false,
14+
"lineBreakBeforeControlFlowKeywords" : false,
15+
"lineBreakBeforeEachArgument" : true,
16+
"lineBreakBeforeEachGenericRequirement" : true,
17+
"lineLength" : 120,
18+
"maximumBlankLines" : 1,
19+
"respectsExistingLineBreaks" : true,
20+
"prioritizeKeepingFunctionOutputTogether" : true,
21+
"rules" : {
22+
"AllPublicDeclarationsHaveDocumentation" : false,
23+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
24+
"AlwaysUseLowerCamelCase" : false,
25+
"AmbiguousTrailingClosureOverload" : true,
26+
"BeginDocumentationCommentWithOneLineSummary" : false,
27+
"DoNotUseSemicolons" : true,
28+
"DontRepeatTypeInStaticProperties" : true,
29+
"FileScopedDeclarationPrivacy" : true,
30+
"FullyIndirectEnum" : true,
31+
"GroupNumericLiterals" : true,
32+
"IdentifiersMustBeASCII" : true,
33+
"NeverForceUnwrap" : false,
34+
"NeverUseForceTry" : false,
35+
"NeverUseImplicitlyUnwrappedOptionals" : false,
36+
"NoAccessLevelOnExtensionDeclaration" : true,
37+
"NoAssignmentInExpressions" : true,
38+
"NoBlockComments" : true,
39+
"NoCasesWithOnlyFallthrough" : true,
40+
"NoEmptyTrailingClosureParentheses" : true,
41+
"NoLabelsInCasePatterns" : true,
42+
"NoLeadingUnderscores" : false,
43+
"NoParensAroundConditions" : true,
44+
"NoVoidReturnOnFunctionSignature" : true,
45+
"OmitExplicitReturns" : true,
46+
"OneCasePerLine" : true,
47+
"OneVariableDeclarationPerLine" : true,
48+
"OnlyOneTrailingClosureArgument" : true,
49+
"OrderedImports" : true,
50+
"ReplaceForEachWithForLoop" : true,
51+
"ReturnVoidInsteadOfEmptyTuple" : true,
52+
"UseEarlyExits" : false,
53+
"UseExplicitNilCheckInConditions" : false,
54+
"UseLetInEveryBoundCaseVariable" : false,
55+
"UseShorthandTypeNames" : true,
56+
"UseSingleLinePropertyGetter" : false,
57+
"UseSynthesizedInitializer" : false,
58+
"UseTripleSlashForDocumentationComments" : true,
59+
"UseWhereClausesInForLoops" : false,
60+
"ValidateDocumentationComments" : false
61+
}
62+
}

.swiftformat

-21
This file was deleted.

Benchmarks/Benchmarks/HTTPFieldsBenchmarks/Benchmarks.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ import Benchmark
1616
import HTTPTypes
1717

1818
let benchmarks = {
19+
let defaultMetrics: [BenchmarkMetric] = [
20+
.mallocCountTotal
21+
]
22+
1923
Benchmark(
20-
"Initialize HTTPFields from Dictionary Literal"
24+
"HTTPFields.init(dictionaryLiteral:) ",
25+
configuration: .init(
26+
metrics: defaultMetrics,
27+
scalingFactor: .kilo,
28+
maxDuration: .seconds(10_000_000),
29+
maxIterations: 10
30+
)
2131
) { _ in
2232
let fiels: HTTPFields = [
2333
.contentType: "application/json",

Benchmarks/Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55
let package = Package(
66
name: "Benchmarks",
77
platforms: [
8-
.macOS(.v13),
8+
.macOS(.v13)
99
],
1010
dependencies: [
1111
.package(path: "../"),
@@ -20,8 +20,8 @@ let package = Package(
2020
],
2121
path: "Benchmarks/HTTPFieldsBenchmarks",
2222
plugins: [
23-
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
23+
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
2424
]
25-
),
25+
)
2626
]
2727
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mallocCountTotal" : 8000
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mallocCountTotal" : 8000
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mallocCountTotal" : 8000
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mallocCountTotal" : 8000
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mallocCountTotal" : 8000
3+
}

Package.swift

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,24 @@ let package = Package(
88
.library(name: "HTTPTypes", targets: ["HTTPTypes"]),
99
.library(name: "HTTPTypesFoundation", targets: ["HTTPTypesFoundation"]),
1010
],
11-
dependencies: [
12-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
13-
],
1411
targets: [
1512
.target(name: "HTTPTypes"),
1613
.target(
1714
name: "HTTPTypesFoundation",
1815
dependencies: [
19-
"HTTPTypes",
16+
"HTTPTypes"
2017
]
2118
),
2219
.testTarget(
2320
name: "HTTPTypesTests",
2421
dependencies: [
25-
"HTTPTypes",
22+
"HTTPTypes"
2623
]
2724
),
2825
.testTarget(
2926
name: "HTTPTypesFoundationTests",
3027
dependencies: [
31-
"HTTPTypesFoundation",
28+
"HTTPTypesFoundation"
3229
]
3330
),
3431
]

Sources/HTTPTypes/HTTPField.swift

+25-15
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ public struct HTTPField: Sendable, Hashable {
112112
///
113113
/// - Parameter body: The closure to be invoked with the buffer.
114114
/// - Returns: Result of the `body` closure.
115-
public func withUnsafeBytesOfValue<Result>(_ body: (UnsafeBufferPointer<UInt8>) throws -> Result) rethrows -> Result {
115+
public func withUnsafeBytesOfValue<Result>(
116+
_ body: (UnsafeBufferPointer<UInt8>) throws -> Result
117+
) rethrows -> Result {
116118
try self.rawValue.withUnsafeBytes(body)
117119
}
118120

@@ -135,7 +137,7 @@ public struct HTTPField: Sendable, Hashable {
135137
switch byte {
136138
case 0x09, 0x20:
137139
break
138-
case 0x21 ... 0x7E, 0x80 ... 0xFF:
140+
case 0x21...0x7E, 0x80...0xFF:
139141
break
140142
default:
141143
return false
@@ -161,13 +163,15 @@ public struct HTTPField: Sendable, Hashable {
161163
switch byte {
162164
case 0x09, 0x20:
163165
return byte
164-
case 0x21 ... 0x7E, 0x80 ... 0xFF:
166+
case 0x21...0x7E, 0x80...0xFF:
165167
return byte
166168
default:
167169
return 0x20
168170
}
169171
}
170-
let trimmed = bytes.reversed().drop { $0 == 0x09 || $0 == 0x20 }.reversed().drop { $0 == 0x09 || $0 == 0x20 }
172+
let trimmed = bytes.reversed().drop { $0 == 0x09 || $0 == 0x20 }.reversed().drop {
173+
$0 == 0x09 || $0 == 0x20
174+
}
171175
return ISOLatin1String(unchecked: String(decoding: trimmed, as: UTF8.self))
172176
}
173177
}
@@ -242,27 +246,33 @@ extension HTTPField: Codable {
242246
let name = try container.decode(Name.self, forKey: .name)
243247
let value = try container.decode(String.self, forKey: .value)
244248
guard Self.isValidValue(value) else {
245-
throw DecodingError.dataCorruptedError(forKey: .value, in: container, debugDescription: "HTTP field value \"\(value)\" contains invalid characters")
249+
throw DecodingError.dataCorruptedError(
250+
forKey: .value,
251+
in: container,
252+
debugDescription: "HTTP field value \"\(value)\" contains invalid characters"
253+
)
246254
}
247255
self.init(name: name, uncheckedValue: ISOLatin1String(unchecked: value))
248256
if let indexingStrategyValue = try container.decodeIfPresent(UInt8.self, forKey: .indexingStrategy),
249-
let indexingStrategy = DynamicTableIndexingStrategy(rawValue: indexingStrategyValue) {
257+
let indexingStrategy = DynamicTableIndexingStrategy(rawValue: indexingStrategyValue)
258+
{
250259
self.indexingStrategy = indexingStrategy
251260
}
252261
}
253262
}
254263

255264
extension HTTPField {
256265
static func isValidToken(_ token: some StringProtocol) -> Bool {
257-
!token.isEmpty && token.utf8.allSatisfy {
258-
switch $0 {
259-
case 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A, 0x2B, 0x2D, 0x2E, 0x5E, 0x5F, 0x60, 0x7C, 0x7E:
260-
return true
261-
case 0x30 ... 0x39, 0x41 ... 0x5A, 0x61 ... 0x7A: // DIGHT, ALPHA
262-
return true
263-
default:
264-
return false
266+
!token.isEmpty
267+
&& token.utf8.allSatisfy {
268+
switch $0 {
269+
case 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A, 0x2B, 0x2D, 0x2E, 0x5E, 0x5F, 0x60, 0x7C, 0x7E:
270+
return true
271+
case 0x30...0x39, 0x41...0x5A, 0x61...0x7A: // DIGHT, ALPHA
272+
return true
273+
default:
274+
return false
275+
}
265276
}
266-
}
267277
}
268278
}

0 commit comments

Comments
 (0)