Skip to content

Commit 87d289e

Browse files
authored
Update from hummingbird-project-template 6c7f44e2f7e58f2d298a177e73421f244f41f90e
1 parent 792db50 commit 87d289e

File tree

5 files changed

+188
-2
lines changed

5 files changed

+188
-2
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
.git
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Verify Documentation
2+
3+
on:
4+
pull_request:
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}-verifydocs
7+
cancel-in-progress: true
8+
9+
jobs:
10+
linux:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 15
13+
container:
14+
image: swift:latest
15+
steps:
16+
- name: Install rsync 📚
17+
run: |
18+
apt-get update && apt-get install -y rsync bc
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
path: "package"
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
repository: "hummingbird-project/hummingbird-docs"
28+
fetch-depth: 0
29+
path: "documentation"
30+
- name: Verify
31+
run: |
32+
cd documentation
33+
swift package edit ${GITHUB_REPOSITORY#*/} --path ../package
34+
./scripts/build-docc.sh -e
35+

.swiftformat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Minimum swiftformat version
2-
--minversion 0.51.0
2+
--minversion 0.53.10
33

44
# Swift version
55
--swiftversion 5.9
@@ -8,7 +8,7 @@
88
--exclude .build
99

1010
# rules
11-
--disable redundantReturn, extensionAccessControl, typeSugar, conditionalAssignment
11+
--disable redundantReturn, extensionAccessControl, typeSugar, conditionalAssignment, preferForLoop, redundantInternal, redundantStaticSelf
1212

1313
# format options
1414
--ifdef no-indent

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ================================
2+
# Build image
3+
# ================================
4+
FROM swift:6.0 as build
5+
6+
WORKDIR /build
7+
8+
# First just resolve dependencies.
9+
# This creates a cached layer that can be reused
10+
# as long as your Package.swift/Package.resolved
11+
# files do not change.
12+
COPY ./Package.* ./
13+
RUN swift package resolve
14+
15+
# Copy entire repo into container
16+
COPY . .
17+
18+
RUN swift test --sanitize=thread

scripts/validate.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the Hummingbird server framework project
5+
##
6+
## Copyright (c) 2021-2024 the Hummingbird authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
##===----------------------------------------------------------------------===##
16+
##
17+
## This source file is part of the SwiftNIO open source project
18+
##
19+
## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
20+
## Licensed under Apache License v2.0
21+
##
22+
## See LICENSE.txt for license information
23+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
24+
##
25+
## SPDX-License-Identifier: Apache-2.0
26+
##
27+
##===----------------------------------------------------------------------===##
28+
29+
SWIFT_FORMAT_VERSION=0.53.10
30+
31+
set -eu
32+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33+
34+
which swiftformat > /dev/null 2>&1 || (echo "swiftformat not installed. You can install it using 'brew install swiftformat'" ; exit -1)
35+
36+
function replace_acceptable_years() {
37+
# this needs to replace all acceptable forms with 'YEARS'
38+
sed -e 's/20[12][0-9]-20[12][0-9]/YEARS/' -e 's/20[12][0-9]/YEARS/' -e '/^#!/ d'
39+
}
40+
41+
printf "=> Checking format... "
42+
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
50+
SECOND_OUT="$(git status --porcelain)"
51+
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
52+
printf "\033[0;31mformatting issues!\033[0m\n"
53+
git --no-pager diff
54+
exit 1
55+
else
56+
printf "\033[0;32mokay.\033[0m\n"
57+
fi
58+
exit
59+
printf "=> Checking license headers... "
60+
tmp=$(mktemp /tmp/.soto-core-sanity_XXXXXX)
61+
62+
for language in swift-or-c; do
63+
declare -a matching_files
64+
declare -a exceptions
65+
expections=( )
66+
matching_files=( -name '*' )
67+
case "$language" in
68+
swift-or-c)
69+
exceptions=( -path '*Sources/INIParser/*' -o -path '*Sources/CSotoExpat/*' -o -path '*Benchmark/.build/*' -o -name Package.swift)
70+
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
71+
cat > "$tmp" <<"EOF"
72+
//===----------------------------------------------------------------------===//
73+
//
74+
// This source file is part of the Hummingbird open source project
75+
//
76+
// Copyright (c) YEARS the Hummingbird authors
77+
// Licensed under Apache License v2.0
78+
//
79+
// See LICENSE.txt for license information
80+
// See CONTRIBUTORS.txt for the list of Hummingbird authors
81+
//
82+
// SPDX-License-Identifier: Apache-2.0
83+
//
84+
//===----------------------------------------------------------------------===//
85+
EOF
86+
;;
87+
bash)
88+
matching_files=( -name '*.sh' )
89+
cat > "$tmp" <<"EOF"
90+
##===----------------------------------------------------------------------===##
91+
##
92+
## This source file is part of the Hummingbird open source project
93+
##
94+
## Copyright (c) YEARS the Hummingbird authors
95+
## Licensed under Apache License v2.0
96+
##
97+
## See LICENSE.txt for license information
98+
## See CONTRIBUTORS.txt for the list of Hummingbird authors
99+
##
100+
## SPDX-License-Identifier: Apache-2.0
101+
##
102+
##===----------------------------------------------------------------------===##
103+
EOF
104+
;;
105+
*)
106+
echo >&2 "ERROR: unknown language '$language'"
107+
;;
108+
esac
109+
110+
lines_to_compare=$(cat "$tmp" | wc -l | tr -d " ")
111+
# need to read one more line as we remove the '#!' line
112+
lines_to_read=$(expr "$lines_to_compare" + 1)
113+
expected_sha=$(cat "$tmp" | shasum)
114+
115+
(
116+
cd "$here/.."
117+
find . \
118+
\( \! -path './.build/*' -a \
119+
\( "${matching_files[@]}" \) -a \
120+
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
121+
if [[ "$(cat "$line" | head -n $lines_to_read | replace_acceptable_years | head -n $lines_to_compare | shasum)" != "$expected_sha" ]]; then
122+
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
123+
diff -u <(cat "$line" | head -n $lines_to_read | replace_acceptable_years | head -n $lines_to_compare) "$tmp"
124+
exit 1
125+
fi
126+
done
127+
printf "\033[0;32mokay.\033[0m\n"
128+
)
129+
done
130+
131+
rm "$tmp"

0 commit comments

Comments
 (0)