Skip to content

Commit f6c7c5a

Browse files
fabianfetttomerd
andauthored
Add script to check for API breaks (#258)
Co-authored-by: tomer doron <[email protected]>
1 parent e5b4496 commit f6c7c5a

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

scripts/check_no_api_breakages.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftAWSLambdaRuntime open source project
5+
##
6+
## Copyright (c) 2022 Apple Inc. and the SwiftAWSLambdaRuntime 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 SwiftAWSLambdaRuntime project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
##===----------------------------------------------------------------------===##
17+
##
18+
## This source file is part of the SwiftNIO open source project
19+
##
20+
## Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors
21+
## Licensed under Apache License v2.0
22+
##
23+
## See LICENSE.txt for license information
24+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
25+
##
26+
## SPDX-License-Identifier: Apache-2.0
27+
##
28+
##===----------------------------------------------------------------------===##
29+
30+
set -eu
31+
32+
function usage() {
33+
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
34+
echo >&2
35+
echo >&2 "This script requires a Swift 5.6+ toolchain."
36+
echo >&2
37+
echo >&2 "Examples:"
38+
echo >&2
39+
echo >&2 "Check between main and tag 2.1.1 of swift-nio:"
40+
echo >&2 " $0 https://github.com/apple/swift-nio main 2.1.1"
41+
echo >&2
42+
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
43+
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
44+
}
45+
46+
if [[ $# -lt 3 ]]; then
47+
usage
48+
exit 1
49+
fi
50+
51+
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
52+
repo_url=$1
53+
new_tag=$2
54+
shift 2
55+
56+
repodir="$tmpdir/repo"
57+
git clone "$repo_url" "$repodir"
58+
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
59+
cd "$repodir"
60+
git checkout -q "$new_tag"
61+
62+
for old_tag in "$@"; do
63+
echo "Checking public API breakages from $old_tag to $new_tag"
64+
65+
swift package diagnose-api-breaking-changes "$old_tag"
66+
done
67+
68+
echo done

0 commit comments

Comments
 (0)