Skip to content

Commit 89ef2cf

Browse files
committed
Add supporting files.
1 parent 141f102 commit 89ef2cf

File tree

5 files changed

+413
-0
lines changed

5 files changed

+413
-0
lines changed

dev/git.commit.template

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
One line description of your change
2+
3+
Motivation:
4+
5+
Explain here the context, and why you're making that change.
6+
What is the problem you're trying to solve.
7+
8+
Modifications:
9+
10+
Describe the modifications you've done.
11+
12+
Result:
13+
14+
After your change, what will change.

scripts/check_no_api_breakages.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftNIO open source project
5+
##
6+
## Copyright (c) 2020 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.md for the list of SwiftNIO project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -eu
17+
18+
# repodir
19+
function all_modules() {
20+
local repodir="$1"
21+
(
22+
set -eu
23+
cd "$repodir"
24+
swift package dump-package | jq '.products |
25+
map(select(.type | has("library") )) |
26+
map(.name) | .[]' | tr -d '"'
27+
)
28+
}
29+
30+
# repodir tag output
31+
function build_and_do() {
32+
local repodir=$1
33+
local tag=$2
34+
local output=$3
35+
36+
(
37+
cd "$repodir"
38+
git checkout -q "$tag"
39+
swift build
40+
while read -r module; do
41+
swift api-digester -sdk "$sdk" -dump-sdk -module "$module" \
42+
-o "$output/$module.json" -I "$repodir/.build/debug"
43+
done < <(all_modules "$repodir")
44+
)
45+
}
46+
47+
function usage() {
48+
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
49+
echo >&2
50+
echo >&2 "This script requires a Swift 5.1+ toolchain."
51+
echo >&2
52+
echo >&2 "Examples:"
53+
echo >&2
54+
echo >&2 "Check between master and tag 2.1.1 of swift-nio:"
55+
echo >&2 " $0 https://github.com/apple/swift-nio master 2.1.1"
56+
echo >&2
57+
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
58+
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
59+
}
60+
61+
if [[ $# -lt 3 ]]; then
62+
usage
63+
exit 1
64+
fi
65+
66+
sdk=/
67+
if [[ "$(uname -s)" == Darwin ]]; then
68+
sdk=$(xcrun --show-sdk-path)
69+
fi
70+
71+
hash jq 2> /dev/null || { echo >&2 "ERROR: jq must be installed"; exit 1; }
72+
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
73+
repo_url=$1
74+
new_tag=$2
75+
shift 2
76+
77+
repodir="$tmpdir/repo"
78+
git clone "$repo_url" "$repodir"
79+
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
80+
errors=0
81+
82+
for old_tag in "$@"; do
83+
mkdir "$tmpdir/api-old"
84+
mkdir "$tmpdir/api-new"
85+
86+
echo "Checking public API breakages from $old_tag to $new_tag"
87+
88+
build_and_do "$repodir" "$new_tag" "$tmpdir/api-new/"
89+
build_and_do "$repodir" "$old_tag" "$tmpdir/api-old/"
90+
91+
for f in "$tmpdir/api-new"/*; do
92+
f=$(basename "$f")
93+
report="$tmpdir/$f.report"
94+
if [[ ! -f "$tmpdir/api-old/$f" ]]; then
95+
echo "NOTICE: NEW MODULE $f"
96+
continue
97+
fi
98+
99+
echo -n "Checking $f... "
100+
swift api-digester -sdk "$sdk" -diagnose-sdk \
101+
--input-paths "$tmpdir/api-old/$f" -input-paths "$tmpdir/api-new/$f" 2>&1 \
102+
> "$report" 2>&1
103+
104+
if ! shasum "$report" | grep -q cefc4ee5bb7bcdb7cb5a7747efa178dab3c794d5; then
105+
echo ERROR
106+
echo >&2 "=============================="
107+
echo >&2 "ERROR: public API change in $f"
108+
echo >&2 "=============================="
109+
cat >&2 "$report"
110+
errors=$(( errors + 1 ))
111+
else
112+
echo OK
113+
fi
114+
done
115+
rm -rf "$tmpdir/api-new" "$tmpdir/api-old"
116+
done
117+
118+
if [[ "$errors" == 0 ]]; then
119+
echo "OK, all seems good"
120+
fi
121+
echo done
122+
exit "$errors"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftNIO open source project
5+
##
6+
## Copyright (c) 2020 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.md for the list of SwiftNIO project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -eu
17+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18+
contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' )
19+
20+
cat > "$here/../CONTRIBUTORS.md" <<- EOF
21+
For the purpose of tracking copyright, this is the list of individuals and
22+
organizations who have contributed source code to SwiftNIO.
23+
24+
For employees of an organization/company where the copyright of work done
25+
by employees of that company is held by the company itself, only the company
26+
needs to be listed here.
27+
28+
## COPYRIGHT HOLDERS
29+
30+
- Apple Inc. (all contributors with '@apple.com')
31+
32+
### Contributors
33+
34+
$contributors
35+
36+
## Updating this list
37+
38+
Please do not edit this file manually. It is generated using \`./scripts/generate_contributors_list.sh\`.
39+
If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\` (see [docs](https://git-scm.com/docs/git-shortlog#_mapping_authors))
40+
EOF

scripts/generate_docs.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftNIO open source project
5+
##
6+
## Copyright (c) 2020 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.md for the list of SwiftNIO project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -e
17+
18+
my_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19+
root_path="$my_path/.."
20+
version=$(git describe --abbrev=0 --tags || echo "0.0.0")
21+
modules=(Crypto)
22+
23+
if [[ "$(uname -s)" == "Linux" ]]; then
24+
# build code if required
25+
if [[ ! -d "$root_path/.build/x86_64-unknown-linux" ]]; then
26+
swift build
27+
fi
28+
# setup source-kitten if required
29+
mkdir -p "$root_path/.build/sourcekitten"
30+
source_kitten_source_path="$root_path/.build/sourcekitten/source"
31+
if [[ ! -d "$source_kitten_source_path" ]]; then
32+
git clone https://github.com/jpsim/SourceKitten.git "$source_kitten_source_path"
33+
fi
34+
source_kitten_path="$source_kitten_source_path/.build/x86_64-unknown-linux/debug"
35+
if [[ ! -d "$source_kitten_path" ]]; then
36+
rm -rf "$source_kitten_source_path/.swift-version"
37+
cd "$source_kitten_source_path" && swift build && cd "$root_path"
38+
fi
39+
# generate
40+
for module in "${modules[@]}"; do
41+
if [[ ! -f "$root_path/.build/sourcekitten/$module.json" ]]; then
42+
"$source_kitten_path/sourcekitten" doc --spm-module $module > "$root_path/.build/sourcekitten/$module.json"
43+
fi
44+
done
45+
fi
46+
47+
jazzy_dir="$root_path/.build/jazzy"
48+
rm -rf "$jazzy_dir"
49+
mkdir -p "$jazzy_dir"
50+
51+
# prep index
52+
module_switcher="$jazzy_dir/README.md"
53+
cat > "$module_switcher" <<"EOF"
54+
# swift-http-structured-headers Docs
55+
56+
swift-http-structured-headers is a Swift package.
57+
58+
To get started with swift-http-structured-headers, [`import CodableStructuredHeaders`](../CodableStructuredHeaders/index.html).
59+
EOF
60+
61+
# run jazzy
62+
if ! command -v jazzy > /dev/null; then
63+
gem install jazzy --no-ri --no-rdoc
64+
fi
65+
66+
jazzy_args=(--clean
67+
--author 'SwiftNIO team'
68+
--readme "$module_switcher"
69+
--author_url https://github.com/apple/swift-http-structured-headers
70+
--github_url https://github.com/apple/swift-http-structured-headers
71+
--github-file-prefix https://github.com/apple/swift-http-structured-headers/tree/$version
72+
--theme fullwidth
73+
--swift-build-tool spm)
74+
75+
for module in "${modules[@]}"; do
76+
args=("${jazzy_args[@]}" --output "$jazzy_dir/docs/$version/$module" --docset-path "$jazzy_dir/docset/$version/$module"
77+
--module "$module" --module-version $version
78+
--root-url "https://apple.github.io/swift-http-structured-headers/docs/$version/$module/")
79+
if [[ "$(uname -s)" == "Linux" ]]; then
80+
args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json")
81+
fi
82+
jazzy "${args[@]}"
83+
done
84+
85+
# push to github pages
86+
if [[ $PUSH == true ]]; then
87+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
88+
GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD)
89+
git fetch origin +gh-pages:gh-pages
90+
git checkout gh-pages
91+
rm -rf "docs/$version"
92+
rm -rf "docs/current"
93+
cp -r "$jazzy_dir/docs/$version" docs/
94+
cp -r "docs/$version" docs/current
95+
git add --all docs
96+
echo '<html><head><meta http-equiv="refresh" content="0; url=docs/current/CodableStructuredHeaders/index.html" /></head></html>' > index.html
97+
git add index.html
98+
touch .nojekyll
99+
git add .nojekyll
100+
changes=$(git diff-index --name-only HEAD)
101+
if [[ -n "$changes" ]]; then
102+
echo -e "changes detected\n$changes"
103+
git commit --author="$GIT_AUTHOR" -m "publish $version docs"
104+
git push origin gh-pages
105+
else
106+
echo "no changes detected"
107+
fi
108+
git checkout -f $BRANCH_NAME
109+
fi

0 commit comments

Comments
 (0)