Skip to content

Migrate to GitHub Actions #42

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

Merged
merged 2 commits into from
Oct 30, 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
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Main

on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
30 changes: 30 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PR

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftNIO"
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main

swift-6-language-mode:
name: Swift 6 Language Mode
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
if: false # Disabled for now.
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR label

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
semver-label-check:
name: Semantic Version label check
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
35 changes: 35 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.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
Snippets/*
dev/git.commit.template
.unacceptablelanguageignore
68 changes: 68 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"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,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow",
"XCTAssertThrowsError"
]
},
"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
}
}
13 changes: 0 additions & 13 deletions .swiftformat

This file was deleted.

3 changes: 0 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ let package = Package(
targets: ["RawStructuredFieldValues"]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
],
targets: [
.target(
name: "RawStructuredFieldValues",
Expand Down
6 changes: 3 additions & 3 deletions Sources/RawStructuredFieldValues/ASCII.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let asciiUnderscore = UInt8(ascii: "_")
let asciiZero = UInt8(ascii: "0")
let asciiOne = UInt8(ascii: "1")
let asciiNine = UInt8(ascii: "9")
let asciiDigits = asciiZero ... asciiNine
let asciiDigits = asciiZero...asciiNine
let asciiDquote = UInt8(ascii: "\"")
let asciiColon = UInt8(ascii: ":")
let asciiSemicolon = UInt8(ascii: ";")
Expand All @@ -48,5 +48,5 @@ let asciiCapitalA = UInt8(ascii: "A")
let asciiCapitalZ = UInt8(ascii: "Z")
let asciiLowerA = UInt8(ascii: "a")
let asciiLowerZ = UInt8(ascii: "z")
let asciiCapitals = asciiCapitalA ... asciiCapitalZ
let asciiLowercases = asciiLowerA ... asciiLowerZ
let asciiCapitals = asciiCapitalA...asciiCapitalZ
let asciiLowercases = asciiLowerA...asciiLowerZ
10 changes: 5 additions & 5 deletions Sources/RawStructuredFieldValues/ComponentTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ extension String {
// / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
// / DIGIT / ALPHA
//
// The following insane case statement covers this. Tokens suck.
// The following unfortunate case statement covers this. Tokens; not even once.
case asciiExclamationMark, asciiOctothorpe, asciiDollar, asciiPercent,
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
asciiColon, asciiSlash:
asciiAmpersand, asciiSquote, asciiAsterisk, asciiPlus, asciiDash,
asciiPeriod, asciiCaret, asciiUnderscore, asciiBacktick, asciiPipe,
asciiTilde, asciiDigits, asciiCapitals, asciiLowercases,
asciiColon, asciiSlash:
// Good
()
default:
Expand Down
25 changes: 15 additions & 10 deletions Sources/RawStructuredFieldValues/FieldParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ extension StructuredFieldValueParser {
// Unquoted dquote, this is the end of the string.
endIndex = index
break loop
case 0x00 ... 0x1F, 0x7F...:
case 0x00...0x1F, 0x7F...:
// Forbidden bytes in string: string must be VCHAR and SP.
throw StructuredHeaderError.invalidString
default:
Expand All @@ -388,7 +388,7 @@ extension StructuredFieldValueParser {
if endIndex == self.underlyingData.endIndex {
throw StructuredHeaderError.invalidString
}
let stringSlice = self.underlyingData[self.underlyingData.startIndex ..< index]
let stringSlice = self.underlyingData[self.underlyingData.startIndex..<index]
self.underlyingData.formIndex(after: &index)
self.underlyingData = self.underlyingData[index...]

Expand Down Expand Up @@ -449,7 +449,10 @@ extension StructuredFieldValueParser {
}

private mutating func _parseAToken() throws -> RFC9651BareItem {
assert(asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!) || self.underlyingData.first! == asciiAsterisk)
assert(
asciiCapitals.contains(self.underlyingData.first!) || asciiLowercases.contains(self.underlyingData.first!)
|| self.underlyingData.first! == asciiAsterisk
)

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

Expand Down
10 changes: 5 additions & 5 deletions Sources/RawStructuredFieldValues/FieldSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

private let validIntegerRange = Int64(-999_999_999_999_999) ... Int64(999_999_999_999_999)
private let validIntegerRange = Int64(-999_999_999_999_999)...Int64(999_999_999_999_999)

/// A `StructuredFieldValueSerializer` is the basic parsing object for structured header field values.
public struct StructuredFieldValueSerializer: Sendable {
Expand Down Expand Up @@ -45,7 +45,7 @@ extension StructuredFieldValueSerializer {
/// Writes a structured list header field value.
///
/// - parameters:
/// - root: The list object.
/// - list: The list object.
/// - throws: If the list could not be serialized.
/// - returns: The bytes of the serialized header field value.
public mutating func writeListFieldValue(_ list: [ItemOrInnerList]) throws -> [UInt8] {
Expand All @@ -63,7 +63,7 @@ extension StructuredFieldValueSerializer {
/// Writes a structured item header field value.
///
/// - parameters:
/// - root: The item.
/// - item: The item.
/// - throws: If the item could not be serialized.
/// - returns: The bytes of the serialized header field value.
public mutating func writeItemFieldValue(_ item: Item) throws -> [UInt8] {
Expand Down Expand Up @@ -179,7 +179,7 @@ extension StructuredFieldValueSerializer {
self.data.append(contentsOf: String(decimal).utf8)
case .string(let string):
let bytes = string.utf8
guard bytes.allSatisfy({ !(0x00 ... 0x1F).contains($0) && $0 != 0x7F && $0 < 0x80 }) else {
guard bytes.allSatisfy({ !(0x00...0x1F).contains($0) && $0 != 0x7F && $0 < 0x80 }) else {
throw StructuredHeaderError.invalidString
}
self.data.append(asciiDquote)
Expand Down Expand Up @@ -233,7 +233,7 @@ extension String {
let validKey = utf8View.dropFirst().allSatisfy {
switch $0 {
case asciiLowercases, asciiDigits, asciiUnderscore,
asciiDash, asciiPeriod, asciiAsterisk:
asciiDash, asciiPeriod, asciiAsterisk:
return true
default:
return false
Expand Down
10 changes: 6 additions & 4 deletions Sources/RawStructuredFieldValues/PseudoDecimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public struct PseudoDecimal: Hashable, Sendable {
// on the exponent.
switch exponent {
case 0 where mantissa.magnitude <= 999_999_999_999,
-1 where mantissa.magnitude <= 9_999_999_999_999,
-2 where mantissa.magnitude <= 99_999_999_999_999,
-3 where mantissa.magnitude <= 999_999_999_999_999:
-1 where mantissa.magnitude <= 9_999_999_999_999,
-2 where mantissa.magnitude <= 99_999_999_999_999,
-3 where mantissa.magnitude <= 999_999_999_999_999:
// All acceptable
()
default:
Expand All @@ -128,7 +128,9 @@ public struct PseudoDecimal: Hashable, Sendable {
do {
try Self.validate(mantissa: mantissa, exponent: exponent)
} catch {
preconditionFailure("Invalid value for structured header decimal: mantissa \(mantissa) exponent \(exponent)")
preconditionFailure(
"Invalid value for structured header decimal: mantissa \(mantissa) exponent \(exponent)"
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ extension BareInnerListDecoder: UnkeyedDecodingContainer {
}
}

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