Skip to content

Commit caf872e

Browse files
authored
Update from hummingbird-project-template 90cc92742619f256866975dec51c6899fbb537bc
1 parent 792db50 commit caf872e

File tree

5 files changed

+175
-2
lines changed

5 files changed

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

0 commit comments

Comments
 (0)