Skip to content

Commit 3fcb78b

Browse files
committed
Migrate to GitHub Actions
Migrate CI to use GitHub Actions. Motivation: To migrate to GitHub actions and centralised infrastructure. Modifications: Changes of note: * Adopt swift-format using rules from SwiftNIO * Remove scripts and docker files which are no longer needed Result: Feature parity with old CI.
1 parent b0bf94f commit 3fcb78b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+612
-757
lines changed

.github/workflows/main.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
schedule:
7+
- cron: "0 8,20 * * *"
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit tests
12+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
13+
with:
14+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
15+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
16+
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
18+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

.github/workflows/pull_request.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
soundness:
9+
name: Soundness
10+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11+
with:
12+
license_header_check_project_name: "SwiftNIO"
13+
unit-tests:
14+
name: Unit tests
15+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
16+
with:
17+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
18+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
19+
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
20+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
21+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
22+
23+
integration-tests:
24+
name: Integration test
25+
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
26+
with:
27+
name: "Integration test"
28+
matrix_linux_command: "apt-get update -yq && apt-get install -yq lsof dnsutils netcat-openbsd net-tools expect curl jq && ./scripts/integration_tests.sh"
29+
30+
benchmarks:
31+
name: Benchmarks
32+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
33+
with:
34+
benchmark_package_path: "Benchmarks"
35+
36+
cxx-interop:
37+
name: Cxx interop
38+
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
39+
40+
swift-6-language-mode:
41+
name: Swift 6 Language Mode
42+
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
43+
if: false # Disabled for now.
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR label
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, reopened, synchronize]
6+
7+
jobs:
8+
semver-label-check:
9+
name: Semantic Version label check
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 1
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- name: Check for Semantic Version label
18+
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main

.licenseignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
Snippets/*
34+
dev/git.commit.template
35+
.unacceptablelanguageignore

.swift-format

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
"noAssignmentInExpressions" : {
22+
"allowedFunctions" : [
23+
"XCTAssertNoThrow",
24+
"XCTAssertThrowsError"
25+
]
26+
},
27+
"rules" : {
28+
"AllPublicDeclarationsHaveDocumentation" : false,
29+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
30+
"AlwaysUseLowerCamelCase" : false,
31+
"AmbiguousTrailingClosureOverload" : true,
32+
"BeginDocumentationCommentWithOneLineSummary" : false,
33+
"DoNotUseSemicolons" : true,
34+
"DontRepeatTypeInStaticProperties" : true,
35+
"FileScopedDeclarationPrivacy" : true,
36+
"FullyIndirectEnum" : true,
37+
"GroupNumericLiterals" : true,
38+
"IdentifiersMustBeASCII" : true,
39+
"NeverForceUnwrap" : false,
40+
"NeverUseForceTry" : false,
41+
"NeverUseImplicitlyUnwrappedOptionals" : false,
42+
"NoAccessLevelOnExtensionDeclaration" : true,
43+
"NoAssignmentInExpressions" : true,
44+
"NoBlockComments" : true,
45+
"NoCasesWithOnlyFallthrough" : true,
46+
"NoEmptyTrailingClosureParentheses" : true,
47+
"NoLabelsInCasePatterns" : true,
48+
"NoLeadingUnderscores" : false,
49+
"NoParensAroundConditions" : true,
50+
"NoVoidReturnOnFunctionSignature" : true,
51+
"OmitExplicitReturns" : true,
52+
"OneCasePerLine" : true,
53+
"OneVariableDeclarationPerLine" : true,
54+
"OnlyOneTrailingClosureArgument" : true,
55+
"OrderedImports" : true,
56+
"ReplaceForEachWithForLoop" : true,
57+
"ReturnVoidInsteadOfEmptyTuple" : true,
58+
"UseEarlyExits" : false,
59+
"UseExplicitNilCheckInConditions" : false,
60+
"UseLetInEveryBoundCaseVariable" : false,
61+
"UseShorthandTypeNames" : true,
62+
"UseSingleLinePropertyGetter" : false,
63+
"UseSynthesizedInitializer" : false,
64+
"UseTripleSlashForDocumentationComments" : true,
65+
"UseWhereClausesInForLoops" : false,
66+
"ValidateDocumentationComments" : false
67+
}
68+
}

.swiftformat

-13
This file was deleted.

Package.swift

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ let package = Package(
2626
targets: ["RawStructuredFieldValues"]
2727
),
2828
],
29-
dependencies: [
30-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
31-
],
3229
targets: [
3330
.target(
3431
name: "RawStructuredFieldValues",

Sources/RawStructuredFieldValues/ASCII.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let asciiUnderscore = UInt8(ascii: "_")
2121
let asciiZero = UInt8(ascii: "0")
2222
let asciiOne = UInt8(ascii: "1")
2323
let asciiNine = UInt8(ascii: "9")
24-
let asciiDigits = asciiZero ... asciiNine
24+
let asciiDigits = asciiZero...asciiNine
2525
let asciiDquote = UInt8(ascii: "\"")
2626
let asciiColon = UInt8(ascii: ":")
2727
let asciiSemicolon = UInt8(ascii: ";")
@@ -48,5 +48,5 @@ let asciiCapitalA = UInt8(ascii: "A")
4848
let asciiCapitalZ = UInt8(ascii: "Z")
4949
let asciiLowerA = UInt8(ascii: "a")
5050
let asciiLowerZ = UInt8(ascii: "z")
51-
let asciiCapitals = asciiCapitalA ... asciiCapitalZ
52-
let asciiLowercases = asciiLowerA ... asciiLowerZ
51+
let asciiCapitals = asciiCapitalA...asciiCapitalZ
52+
let asciiLowercases = asciiLowerA...asciiLowerZ

Sources/RawStructuredFieldValues/ComponentTypes.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,12 @@ extension String {
378378
// / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
379379
// / DIGIT / ALPHA
380380
//
381-
// The following insane case statement covers this. Tokens suck.
381+
// The following unfortunate case statement covers this. Tokens; not even once.
382382
case asciiExclamationMark, asciiOctothorpe, asciiDollar, asciiPercent,
383-
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
384-
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
385-
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
386-
asciiColon, asciiSlash:
383+
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
384+
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
385+
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
386+
asciiColon, asciiSlash:
387387
// Good
388388
()
389389
default:

Sources/RawStructuredFieldValues/FieldParser.swift

+15-10
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ extension StructuredFieldValueParser {
373373
// Unquoted dquote, this is the end of the string.
374374
endIndex = index
375375
break loop
376-
case 0x00 ... 0x1F, 0x7F...:
376+
case 0x00...0x1F, 0x7F...:
377377
// Forbidden bytes in string: string must be VCHAR and SP.
378378
throw StructuredHeaderError.invalidString
379379
default:
@@ -388,7 +388,7 @@ extension StructuredFieldValueParser {
388388
if endIndex == self.underlyingData.endIndex {
389389
throw StructuredHeaderError.invalidString
390390
}
391-
let stringSlice = self.underlyingData[self.underlyingData.startIndex ..< index]
391+
let stringSlice = self.underlyingData[self.underlyingData.startIndex..<index]
392392
self.underlyingData.formIndex(after: &index)
393393
self.underlyingData = self.underlyingData[index...]
394394

@@ -449,7 +449,10 @@ extension StructuredFieldValueParser {
449449
}
450450

451451
private mutating func _parseAToken() throws -> RFC9651BareItem {
452-
assert(asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!) || self.underlyingData.first! == asciiAsterisk)
452+
assert(
453+
asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!)
454+
|| self.underlyingData.first! == asciiAsterisk
455+
)
453456

454457
var index = self.underlyingData.startIndex
455458
loop: while index < self.underlyingData.endIndex {
@@ -461,12 +464,12 @@ extension StructuredFieldValueParser {
461464
// / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
462465
// / DIGIT / ALPHA
463466
//
464-
// The following insane case statement covers this. Tokens suck.
467+
// The following unfortunate case statement covers this. Tokens; not even once.
465468
case asciiExclamationMark, asciiOctothorpe, asciiDollar, asciiPercent,
466-
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
467-
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
468-
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
469-
asciiColon, asciiSlash:
469+
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
470+
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
471+
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
472+
asciiColon, asciiSlash:
470473
// Good, consume
471474
self.underlyingData.formIndex(after: &index)
472475
default:
@@ -551,7 +554,8 @@ extension RandomAccessCollection where Element == UInt8, SubSequence == Self {
551554
extension String {
552555
// This is the slow path, so we never inline this.
553556
@inline(never)
554-
fileprivate static func decodingEscapes<Bytes: RandomAccessCollection>(_ bytes: Bytes, escapes: Int) -> String where Bytes.Element == UInt8 {
557+
fileprivate static func decodingEscapes<Bytes: RandomAccessCollection>(_ bytes: Bytes, escapes: Int) -> String
558+
where Bytes.Element == UInt8 {
555559
// We assume the string is previously validated, so the escapes are easily removed. See the doc comment for
556560
// `StrippingStringEscapesCollection` for more details on what we're doing here.
557561
let unescapedBytes = StrippingStringEscapesCollection(bytes, escapes: escapes)
@@ -574,7 +578,8 @@ extension String {
574578
/// Until this issue is fixed (https://bugs.swift.org/browse/SR-13111) we take a different approach: we use
575579
/// `String.init(unsafeUninitializedCapacity:initializingWith)`. This is an unsafe function, so to reduce the unsafety as much
576580
/// as possible we define this safe wrapping Collection and then use `copyBytes` to implement the initialization.
577-
private struct StrippingStringEscapesCollection<BaseCollection: RandomAccessCollection> where BaseCollection.Element == UInt8 {
581+
private struct StrippingStringEscapesCollection<BaseCollection: RandomAccessCollection>
582+
where BaseCollection.Element == UInt8 {
578583
private var base: BaseCollection
579584
private var escapes: UInt
580585

Sources/RawStructuredFieldValues/FieldSerializer.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
private let validIntegerRange = Int64(-999_999_999_999_999) ... Int64(999_999_999_999_999)
15+
private let validIntegerRange = Int64(-999_999_999_999_999)...Int64(999_999_999_999_999)
1616

1717
/// A `StructuredFieldValueSerializer` is the basic parsing object for structured header field values.
1818
public struct StructuredFieldValueSerializer: Sendable {
@@ -45,7 +45,7 @@ extension StructuredFieldValueSerializer {
4545
/// Writes a structured list header field value.
4646
///
4747
/// - parameters:
48-
/// - root: The list object.
48+
/// - list: The list object.
4949
/// - throws: If the list could not be serialized.
5050
/// - returns: The bytes of the serialized header field value.
5151
public mutating func writeListFieldValue(_ list: [ItemOrInnerList]) throws -> [UInt8] {
@@ -63,7 +63,7 @@ extension StructuredFieldValueSerializer {
6363
/// Writes a structured item header field value.
6464
///
6565
/// - parameters:
66-
/// - root: The item.
66+
/// - item: The item.
6767
/// - throws: If the item could not be serialized.
6868
/// - returns: The bytes of the serialized header field value.
6969
public mutating func writeItemFieldValue(_ item: Item) throws -> [UInt8] {
@@ -179,7 +179,7 @@ extension StructuredFieldValueSerializer {
179179
self.data.append(contentsOf: String(decimal).utf8)
180180
case .string(let string):
181181
let bytes = string.utf8
182-
guard bytes.allSatisfy({ !(0x00 ... 0x1F).contains($0) && $0 != 0x7F && $0 < 0x80 }) else {
182+
guard bytes.allSatisfy({ !(0x00...0x1F).contains($0) && $0 != 0x7F && $0 < 0x80 }) else {
183183
throw StructuredHeaderError.invalidString
184184
}
185185
self.data.append(asciiDquote)
@@ -233,7 +233,7 @@ extension String {
233233
let validKey = utf8View.dropFirst().allSatisfy {
234234
switch $0 {
235235
case asciiLowercases, asciiDigits, asciiUnderscore,
236-
asciiDash, asciiPeriod, asciiAsterisk:
236+
asciiDash, asciiPeriod, asciiAsterisk:
237237
return true
238238
default:
239239
return false

Sources/RawStructuredFieldValues/PseudoDecimal.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public struct PseudoDecimal: Hashable, Sendable {
114114
// on the exponent.
115115
switch exponent {
116116
case 0 where mantissa.magnitude <= 999_999_999_999,
117-
-1 where mantissa.magnitude <= 9_999_999_999_999,
118-
-2 where mantissa.magnitude <= 99_999_999_999_999,
119-
-3 where mantissa.magnitude <= 999_999_999_999_999:
117+
-1 where mantissa.magnitude <= 9_999_999_999_999,
118+
-2 where mantissa.magnitude <= 99_999_999_999_999,
119+
-3 where mantissa.magnitude <= 999_999_999_999_999:
120120
// All acceptable
121121
()
122122
default:
@@ -128,7 +128,9 @@ public struct PseudoDecimal: Hashable, Sendable {
128128
do {
129129
try Self.validate(mantissa: mantissa, exponent: exponent)
130130
} catch {
131-
preconditionFailure("Invalid value for structured header decimal: mantissa \(mantissa) exponent \(exponent)")
131+
preconditionFailure(
132+
"Invalid value for structured header decimal: mantissa \(mantissa) exponent \(exponent)"
133+
)
132134
}
133135
}
134136

Sources/StructuredFieldValues/Decoder/BareInnerListDecoder.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ extension BareInnerListDecoder: UnkeyedDecodingContainer {
7777
}
7878
}
7979

80-
mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey {
80+
mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey>
81+
where NestedKey: CodingKey {
8182
// This is a request to decode a full item. We decode the next entry and increment the index.
8283
guard !self.isAtEnd else {
8384
throw StructuredHeaderError.indexOutOfRange

0 commit comments

Comments
 (0)