Skip to content

chore: Adjusts format CI to use docker #125

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
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
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
name: Lint for correct formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: swift-actions/setup-swift@v1
with:
swift-version: "5.7.1"
- name: GitHub Action for SwiftFormat
uses: CassiusPacheco/action-swiftformat@v0.1.0
with:
swiftformat-version: '0.50.6'
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Pull formatting docker image
run: docker pull ghcr.io/nicklockwood/swiftformat:latest
- name: Run format linting
run: docker run --rm -v ${{ github.workspace }}:/repo ghcr.io/nicklockwood/swiftformat:latest /repo --lint

macos:
name: Build and test on macos-latest
Expand Down
4 changes: 2 additions & 2 deletions Sources/GraphQL/Execution/Execute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,8 @@ func completeValue(
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning .null if serialization is not possible.
if let returnType = returnType as? GraphQLLeafType {
return exeContext.eventLoopGroup.next()
.makeSucceededFuture(try completeLeafValue(returnType: returnType, result: r))
return try exeContext.eventLoopGroup.next()
.makeSucceededFuture(completeLeafValue(returnType: returnType, result: r))
}

// If field type is an abstract type, Interface or Union, determine the
Expand Down
106 changes: 53 additions & 53 deletions Sources/GraphQL/Language/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func parseDocument(lexer: Lexer) throws -> Document {
var definitions: [Definition] = []

repeat {
definitions.append(try parseDefinition(lexer: lexer))
try definitions.append(parseDefinition(lexer: lexer))
} while try !skip(lexer: lexer, kind: .eof)

return Document(
Expand Down Expand Up @@ -207,13 +207,13 @@ func parseOperationDefinition(lexer: Lexer) throws -> OperationDefinition {
let start = lexer.token

if peek(lexer: lexer, kind: .openingBrace) {
return OperationDefinition(
return try OperationDefinition(
loc: loc(lexer: lexer, startToken: start),
operation: .query,
name: nil,
variableDefinitions: [], // nil
directives: [],
selectionSet: try parseSelectionSet(lexer: lexer)
selectionSet: parseSelectionSet(lexer: lexer)
)
}

Expand All @@ -225,13 +225,13 @@ func parseOperationDefinition(lexer: Lexer) throws -> OperationDefinition {
name = try parseName(lexer: lexer)
}

return OperationDefinition(
return try OperationDefinition(
loc: loc(lexer: lexer, startToken: start),
operation: operation,
name: name,
variableDefinitions: try parseVariableDefinitions(lexer: lexer),
directives: try parseDirectives(lexer: lexer),
selectionSet: try parseSelectionSet(lexer: lexer)
variableDefinitions: parseVariableDefinitions(lexer: lexer),
directives: parseDirectives(lexer: lexer),
selectionSet: parseSelectionSet(lexer: lexer)
)
}

Expand Down Expand Up @@ -271,11 +271,11 @@ func parseVariableDefinitions(lexer: Lexer) throws -> [VariableDefinition] {
*/
func parseVariableDefinition(lexer: Lexer) throws -> VariableDefinition {
let start = lexer.token
return VariableDefinition(
return try VariableDefinition(
loc: loc(lexer: lexer, startToken: start),
variable: try parseVariable(lexer: lexer),
type: (try expect(lexer: lexer, kind: .colon), try parseTypeReference(lexer: lexer)).1,
defaultValue: try skip(lexer: lexer, kind: .equals) ?
variable: parseVariable(lexer: lexer),
type: (expect(lexer: lexer, kind: .colon), parseTypeReference(lexer: lexer)).1,
defaultValue: skip(lexer: lexer, kind: .equals) ?
parseValueLiteral(lexer: lexer, isConst: true) : nil
)
}
Expand All @@ -286,9 +286,9 @@ func parseVariableDefinition(lexer: Lexer) throws -> VariableDefinition {
func parseVariable(lexer: Lexer) throws -> Variable {
let start = lexer.token
try expect(lexer: lexer, kind: .dollar)
return Variable(
return try Variable(
loc: loc(lexer: lexer, startToken: start),
name: try parseName(lexer: lexer)
name: parseName(lexer: lexer)
)
}

Expand All @@ -297,9 +297,9 @@ func parseVariable(lexer: Lexer) throws -> Variable {
*/
func parseSelectionSet(lexer: Lexer) throws -> SelectionSet {
let start = lexer.token
return SelectionSet(
return try SelectionSet(
loc: loc(lexer: lexer, startToken: start),
selections: try many(
selections: many(
lexer: lexer,
openKind: .openingBrace,
closeKind: .closingBrace,
Expand Down Expand Up @@ -340,14 +340,14 @@ func parseField(lexer: Lexer) throws -> Field {
name = nameOrAlias
}

return Field(
return try Field(
loc: loc(lexer: lexer, startToken: start),
alias: alias,
name: name,
arguments: try parseArguments(lexer: lexer),
directives: try parseDirectives(lexer: lexer),
arguments: parseArguments(lexer: lexer),
directives: parseDirectives(lexer: lexer),
selectionSet: peek(lexer: lexer, kind: .openingBrace) ?
try parseSelectionSet(lexer: lexer) :
parseSelectionSet(lexer: lexer) :
nil
)
}
Expand All @@ -370,12 +370,12 @@ func parseArguments(lexer: Lexer) throws -> [Argument] {
*/
func parseArgument(lexer: Lexer) throws -> Argument {
let start = lexer.token
return Argument(
return try Argument(
loc: loc(lexer: lexer, startToken: start),
name: try parseName(lexer: lexer),
name: parseName(lexer: lexer),
value: (
try expect(lexer: lexer, kind: .colon),
try parseValueLiteral(lexer: lexer, isConst: false)
expect(lexer: lexer, kind: .colon),
parseValueLiteral(lexer: lexer, isConst: false)
).1
)
}
Expand All @@ -393,10 +393,10 @@ func parseFragment(lexer: Lexer) throws -> Fragment {
let start = lexer.token
try expect(lexer: lexer, kind: .spread)
if peek(lexer: lexer, kind: .name), lexer.token.value != "on" {
return FragmentSpread(
return try FragmentSpread(
loc: loc(lexer: lexer, startToken: start),
name: try parseFragmentName(lexer: lexer),
directives: try parseDirectives(lexer: lexer)
name: parseFragmentName(lexer: lexer),
directives: parseDirectives(lexer: lexer)
)
}

Expand All @@ -406,11 +406,11 @@ func parseFragment(lexer: Lexer) throws -> Fragment {
try lexer.advance()
typeCondition = try parseNamedType(lexer: lexer)
}
return InlineFragment(
return try InlineFragment(
loc: loc(lexer: lexer, startToken: start),
typeCondition: typeCondition,
directives: try parseDirectives(lexer: lexer),
selectionSet: try parseSelectionSet(lexer: lexer)
directives: parseDirectives(lexer: lexer),
selectionSet: parseSelectionSet(lexer: lexer)
)
}

Expand All @@ -423,15 +423,15 @@ func parseFragment(lexer: Lexer) throws -> Fragment {
func parseFragmentDefinition(lexer: Lexer) throws -> FragmentDefinition {
let start = lexer.token
try expectKeyword(lexer: lexer, value: "fragment")
return FragmentDefinition(
return try FragmentDefinition(
loc: loc(lexer: lexer, startToken: start),
name: try parseFragmentName(lexer: lexer),
name: parseFragmentName(lexer: lexer),
typeCondition: (
try expectKeyword(lexer: lexer, value: "on"),
try parseNamedType(lexer: lexer)
expectKeyword(lexer: lexer, value: "on"),
parseNamedType(lexer: lexer)
).1,
directives: try parseDirectives(lexer: lexer),
selectionSet: try parseSelectionSet(lexer: lexer)
directives: parseDirectives(lexer: lexer),
selectionSet: parseSelectionSet(lexer: lexer)
)
}

Expand Down Expand Up @@ -538,9 +538,9 @@ func parseValueValue(lexer: Lexer) throws -> Value {
func parseList(lexer: Lexer, isConst: Bool) throws -> ListValue {
let start = lexer.token
let item = isConst ? parseConstValue : parseValueValue
return ListValue(
return try ListValue(
loc: loc(lexer: lexer, startToken: start),
values: try any(
values: any(
lexer: lexer,
openKind: .openingBracket,
closeKind: .closingBracket,
Expand All @@ -560,7 +560,7 @@ func parseObject(lexer: Lexer, isConst: Bool) throws -> ObjectValue {
var fields: [ObjectField] = []

while try !skip(lexer: lexer, kind: .closingBrace) {
fields.append(try parseObjectField(lexer: lexer, isConst: isConst))
try fields.append(parseObjectField(lexer: lexer, isConst: isConst))
}

return ObjectValue(
Expand All @@ -574,12 +574,12 @@ func parseObject(lexer: Lexer, isConst: Bool) throws -> ObjectValue {
*/
func parseObjectField(lexer: Lexer, isConst: Bool) throws -> ObjectField {
let start = lexer.token
return ObjectField(
return try ObjectField(
loc: loc(lexer: lexer, startToken: start),
name: try parseName(lexer: lexer),
name: parseName(lexer: lexer),
value: (
try expect(lexer: lexer, kind: .colon),
try parseValueLiteral(lexer: lexer, isConst: isConst)
expect(lexer: lexer, kind: .colon),
parseValueLiteral(lexer: lexer, isConst: isConst)
).1
)
}
Expand Down Expand Up @@ -609,7 +609,7 @@ func parseDirectives(lexer: Lexer) throws -> [Directive] {
var directives: [Directive] = []

while peek(lexer: lexer, kind: .at) {
directives.append(try parseDirective(lexer: lexer))
try directives.append(parseDirective(lexer: lexer))
}

return directives
Expand All @@ -621,10 +621,10 @@ func parseDirectives(lexer: Lexer) throws -> [Directive] {
func parseDirective(lexer: Lexer) throws -> Directive {
let start = lexer.token
try expect(lexer: lexer, kind: .at)
return Directive(
return try Directive(
loc: loc(lexer: lexer, startToken: start),
name: try parseName(lexer: lexer),
arguments: try parseArguments(lexer: lexer)
name: parseName(lexer: lexer),
arguments: parseArguments(lexer: lexer)
)
}

Expand Down Expand Up @@ -666,9 +666,9 @@ func parseTypeReference(lexer: Lexer) throws -> Type {
*/
func parseNamedType(lexer: Lexer) throws -> NamedType {
let start = lexer.token
return NamedType(
return try NamedType(
loc: loc(lexer: lexer, startToken: start),
name: try parseName(lexer: lexer)
name: parseName(lexer: lexer)
)
}

Expand Down Expand Up @@ -909,12 +909,12 @@ func parseUnionTypeDefinition(lexer: Lexer) throws -> UnionTypeDefinition {
try expectKeyword(lexer: lexer, value: "union")
let name = try parseName(lexer: lexer)
let directives = try parseDirectives(lexer: lexer)
return UnionTypeDefinition(
return try UnionTypeDefinition(
loc: loc(lexer: lexer, startToken: start),
description: description,
name: name,
directives: directives,
types: try parseUnionMembers(lexer: lexer)
types: parseUnionMembers(lexer: lexer)
)
}

Expand Down Expand Up @@ -1290,7 +1290,7 @@ func any<T>(
var nodes: [T] = []

while try !skip(lexer: lexer, kind: closeKind) {
nodes.append(try parse(lexer))
try nodes.append(parse(lexer))
}

return nodes
Expand All @@ -1313,7 +1313,7 @@ func optionalMany<T>(
}
var nodes: [T] = []
while try !skip(lexer: lexer, kind: closeKind) {
nodes.append(try parse(lexer))
try nodes.append(parse(lexer))
}
return nodes
}
Expand All @@ -1333,7 +1333,7 @@ func many<T>(
try expect(lexer: lexer, kind: openKind)
var nodes = [try parse(lexer)]
while try !skip(lexer: lexer, kind: closeKind) {
nodes.append(try parse(lexer))
try nodes.append(parse(lexer))
}
return nodes
}
4 changes: 2 additions & 2 deletions Sources/GraphQL/Type/Definition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ func defineFieldMap(name: String, fields: GraphQLFieldMap) throws -> GraphQLFiel
for (name, config) in fields {
try assertValid(name: name)

let field = GraphQLFieldDefinition(
let field = try GraphQLFieldDefinition(
name: name,
type: config.type,
description: config.description,
deprecationReason: config.deprecationReason,
args: try defineArgumentMap(args: config.args),
args: defineArgumentMap(args: config.args),
resolve: config.resolve,
subscribe: config.subscribe
)
Expand Down
3 changes: 2 additions & 1 deletion Sources/GraphQL/Utilities/NIO+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public extension EventLoopFuture {
///
/// The key difference between this method and the regular `flatMap` is error handling.
///
/// With `tryFlatMap`, the provided callback _may_ throw Errors, causing the returned `EventLoopFuture<Value>`
/// With `tryFlatMap`, the provided callback _may_ throw Errors, causing the returned
/// `EventLoopFuture<Value>`
/// to report failure immediately after the completion of the original `EventLoopFuture`.
flatMap { [eventLoop] value in
do {
Expand Down
Loading