Skip to content

Commit fdb9783

Browse files
authored
Update from hummingbird-project-template 46c21b6342b1f58f4843c1c992e0e557fe8279a0
1 parent 53aa062 commit fdb9783

File tree

4 files changed

+73
-21
lines changed

4 files changed

+73
-21
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ concurrency:
88

99
jobs:
1010
validate:
11-
runs-on: macOS-latest
11+
runs-on: ubuntu-latest
1212
timeout-minutes: 15
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 1
18-
- name: Install Dependencies
19-
run: |
20-
brew install mint
21-
mint install NickLockwood/SwiftFormat@0.53.10 --no-link
2218
- name: run script
2319
run: ./scripts/validate.sh

.swift-format

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

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ The main development branch of the repository is `main`.
2828

2929
### Formatting
3030

31-
We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.53.10.
31+
We use Apple's swift-format for formatting code. PRs will not be accepted if they haven't be formatted.

scripts/validate.sh

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,16 @@ SWIFT_FORMAT_VERSION=0.53.10
3131
set -eu
3232
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3333

34-
which swiftformat > /dev/null 2>&1 || (echo "swiftformat not installed. You can install it using 'brew install swiftformat'" ; exit -1)
35-
3634
function replace_acceptable_years() {
3735
# this needs to replace all acceptable forms with 'YEARS'
3836
sed -e 's/20[12][0-9]-20[12][0-9]/YEARS/' -e 's/20[12][0-9]/YEARS/' -e '/^#!/ d'
3937
}
4038

4139
printf "=> Checking format... "
4240
FIRST_OUT="$(git status --porcelain)"
43-
if [[ -n "${CI-""}" ]]; then
44-
printf "(using v$(mint run NickLockwood/SwiftFormat@"$SWIFT_FORMAT_VERSION" --version)) "
45-
mint run NickLockwood/SwiftFormat@"$SWIFT_FORMAT_VERSION" . > /dev/null 2>&1
46-
else
47-
printf "(using v$(swiftformat --version)) "
48-
swiftformat . > /dev/null 2>&1
49-
fi
41+
git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place
42+
git diff --exit-code '*.swift'
43+
5044
SECOND_OUT="$(git status --porcelain)"
5145
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
5246
printf "\033[0;31mformatting issues!\033[0m\n"
@@ -55,7 +49,6 @@ if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
5549
else
5650
printf "\033[0;32mokay.\033[0m\n"
5751
fi
58-
exit
5952
printf "=> Checking license headers... "
6053
tmp=$(mktemp /tmp/.soto-core-sanity_XXXXXX)
6154

@@ -66,18 +59,18 @@ for language in swift-or-c; do
6659
matching_files=( -name '*' )
6760
case "$language" in
6861
swift-or-c)
69-
exceptions=( -path '*Sources/INIParser/*' -o -path '*Sources/CSotoExpat/*' -o -path '*Benchmark/.build/*' -o -name Package.swift)
62+
exceptions=( -path '*/Benchmarks/.build/*' -o -name Package.swift)
7063
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
7164
cat > "$tmp" <<"EOF"
7265
//===----------------------------------------------------------------------===//
7366
//
74-
// This source file is part of the Hummingbird open source project
67+
// This source file is part of the Hummingbird server framework project
7568
//
7669
// Copyright (c) YEARS the Hummingbird authors
7770
// Licensed under Apache License v2.0
7871
//
7972
// See LICENSE.txt for license information
80-
// See CONTRIBUTORS.txt for the list of Hummingbird authors
73+
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
8174
//
8275
// SPDX-License-Identifier: Apache-2.0
8376
//
@@ -89,13 +82,13 @@ EOF
8982
cat > "$tmp" <<"EOF"
9083
##===----------------------------------------------------------------------===##
9184
##
92-
## This source file is part of the Hummingbird open source project
85+
## This source file is part of the Hummingbird server framework project
9386
##
9487
## Copyright (c) YEARS the Hummingbird authors
9588
## Licensed under Apache License v2.0
9689
##
9790
## See LICENSE.txt for license information
98-
## See CONTRIBUTORS.txt for the list of Hummingbird authors
91+
## See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
9992
##
10093
## SPDX-License-Identifier: Apache-2.0
10194
##

0 commit comments

Comments
 (0)