Skip to content

Commit f69f8e1

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 f069b10 commit f69f8e1

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

+609
-755
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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_8_enabled: false
15+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
16+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
17+
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
18+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
19+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

.github/workflows/pull_request.yml

Lines changed: 43 additions & 0 deletions
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.
Lines changed: 18 additions & 0 deletions
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

Lines changed: 35 additions & 0 deletions
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

Lines changed: 68 additions & 0 deletions
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

Lines changed: 0 additions & 13 deletions
This file was deleted.

Package.swift

Lines changed: 0 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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: ";")
@@ -47,5 +47,5 @@ let asciiCapitalA = UInt8(ascii: "A")
4747
let asciiCapitalZ = UInt8(ascii: "Z")
4848
let asciiLowerA = UInt8(ascii: "a")
4949
let asciiLowerZ = UInt8(ascii: "z")
50-
let asciiCapitals = asciiCapitalA ... asciiCapitalZ
51-
let asciiLowercases = asciiLowerA ... asciiLowerZ
50+
let asciiCapitals = asciiCapitalA...asciiCapitalZ
51+
let asciiLowercases = asciiLowerA...asciiLowerZ

Sources/RawStructuredFieldValues/ComponentTypes.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,12 @@ extension String {
372372
// / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
373373
// / DIGIT / ALPHA
374374
//
375-
// The following insane case statement covers this. Tokens suck.
375+
// The following unfortunate case statement covers this. Tokens; not even once.
376376
case asciiExclamationMark, asciiOctothorpe, asciiDollar, asciiPercent,
377-
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
378-
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
379-
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
380-
asciiColon, asciiSlash:
377+
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
378+
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
379+
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
380+
asciiColon, asciiSlash:
381381
// Good
382382
()
383383
default:

Sources/RawStructuredFieldValues/FieldParser.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ extension StructuredFieldValueParser {
350350
// Unquoted dquote, this is the end of the string.
351351
endIndex = index
352352
break loop
353-
case 0x00 ... 0x1F, 0x7F...:
353+
case 0x00...0x1F, 0x7F...:
354354
// Forbidden bytes in string: string must be VCHAR and SP.
355355
throw StructuredHeaderError.invalidString
356356
default:
@@ -365,7 +365,7 @@ extension StructuredFieldValueParser {
365365
if endIndex == self.underlyingData.endIndex {
366366
throw StructuredHeaderError.invalidString
367367
}
368-
let stringSlice = self.underlyingData[self.underlyingData.startIndex ..< index]
368+
let stringSlice = self.underlyingData[self.underlyingData.startIndex..<index]
369369
self.underlyingData.formIndex(after: &index)
370370
self.underlyingData = self.underlyingData[index...]
371371

@@ -426,7 +426,10 @@ extension StructuredFieldValueParser {
426426
}
427427

428428
private mutating func _parseAToken() throws -> RFC9651BareItem {
429-
assert(asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!) || self.underlyingData.first! == asciiAsterisk)
429+
assert(
430+
asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!)
431+
|| self.underlyingData.first! == asciiAsterisk
432+
)
430433

431434
var index = self.underlyingData.startIndex
432435
loop: while index < self.underlyingData.endIndex {
@@ -438,12 +441,12 @@ extension StructuredFieldValueParser {
438441
// / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
439442
// / DIGIT / ALPHA
440443
//
441-
// The following insane case statement covers this. Tokens suck.
444+
// The following unfortunate case statement covers this. Tokens; not even once.
442445
case asciiExclamationMark, asciiOctothorpe, asciiDollar, asciiPercent,
443-
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
444-
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
445-
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
446-
asciiColon, asciiSlash:
446+
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
447+
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
448+
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
449+
asciiColon, asciiSlash:
447450
// Good, consume
448451
self.underlyingData.formIndex(after: &index)
449452
default:
@@ -522,7 +525,8 @@ extension RandomAccessCollection where Element == UInt8, SubSequence == Self {
522525
extension String {
523526
// This is the slow path, so we never inline this.
524527
@inline(never)
525-
fileprivate static func decodingEscapes<Bytes: RandomAccessCollection>(_ bytes: Bytes, escapes: Int) -> String where Bytes.Element == UInt8 {
528+
fileprivate static func decodingEscapes<Bytes: RandomAccessCollection>(_ bytes: Bytes, escapes: Int) -> String
529+
where Bytes.Element == UInt8 {
526530
// We assume the string is previously validated, so the escapes are easily removed. See the doc comment for
527531
// `StrippingStringEscapesCollection` for more details on what we're doing here.
528532
let unescapedBytes = StrippingStringEscapesCollection(bytes, escapes: escapes)
@@ -545,7 +549,8 @@ extension String {
545549
/// Until this issue is fixed (https://bugs.swift.org/browse/SR-13111) we take a different approach: we use
546550
/// `String.init(unsafeUninitializedCapacity:initializingWith)`. This is an unsafe function, so to reduce the unsafety as much
547551
/// as possible we define this safe wrapping Collection and then use `copyBytes` to implement the initialization.
548-
private struct StrippingStringEscapesCollection<BaseCollection: RandomAccessCollection> where BaseCollection.Element == UInt8 {
552+
private struct StrippingStringEscapesCollection<BaseCollection: RandomAccessCollection>
553+
where BaseCollection.Element == UInt8 {
549554
private var base: BaseCollection
550555
private var escapes: UInt
551556

Sources/RawStructuredFieldValues/FieldSerializer.swift

Lines changed: 5 additions & 5 deletions
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)
@@ -224,7 +224,7 @@ extension String {
224224
let validKey = utf8View.dropFirst().allSatisfy {
225225
switch $0 {
226226
case asciiLowercases, asciiDigits, asciiUnderscore,
227-
asciiDash, asciiPeriod, asciiAsterisk:
227+
asciiDash, asciiPeriod, asciiAsterisk:
228228
return true
229229
default:
230230
return false

Sources/RawStructuredFieldValues/PseudoDecimal.swift

Lines changed: 6 additions & 4 deletions
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

Lines changed: 2 additions & 1 deletion
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)