Skip to content

Commit 33d3f71

Browse files
Update API breakage CI script (#143)
* Update API breakage CI script * restate sendable conformance to avoid warning/as-error --------- Co-authored-by: Konrad `ktoso` Malawski <[email protected]>
1 parent 7e53749 commit 33d3f71

File tree

2 files changed

+8
-76
lines changed

2 files changed

+8
-76
lines changed

Sources/CoreMetrics/Metrics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension FloatingPointCounter: CustomStringConvertible {
176176
/// A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
177177
/// Gauges are typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of active threads.
178178
/// Gauges are modeled as `Recorder` with a sample size of 1 and that does not perform any aggregation.
179-
public final class Gauge: Recorder {
179+
public final class Gauge: Recorder, @unchecked Sendable {
180180
/// Create a new `Gauge`.
181181
///
182182
/// - parameters:

scripts/check_no_api_breakages.sh

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
##
1818
## This source file is part of the SwiftNIO open source project
1919
##
20-
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
20+
## Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors
2121
## Licensed under Apache License v2.0
2222
##
2323
## See LICENSE.txt for license information
@@ -29,44 +29,15 @@
2929

3030
set -eu
3131

32-
# repodir
33-
function all_modules() {
34-
local repodir="$1"
35-
(
36-
set -eu
37-
cd "$repodir"
38-
swift package dump-package | jq '.products |
39-
map(select(.type | has("library") )) |
40-
map(.name) | .[]' | tr -d '"'
41-
)
42-
}
43-
44-
# repodir tag output
45-
function build_and_do() {
46-
local repodir=$1
47-
local tag=$2
48-
local output=$3
49-
50-
(
51-
cd "$repodir"
52-
git checkout -q "$tag"
53-
swift build
54-
while read -r module; do
55-
swift api-digester -sdk "$sdk" -dump-sdk -module "$module" \
56-
-o "$output/$module.json" -I "$repodir/.build/debug"
57-
done < <(all_modules "$repodir")
58-
)
59-
}
60-
6132
function usage() {
6233
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
6334
echo >&2
64-
echo >&2 "This script requires a Swift 5.1+ toolchain."
35+
echo >&2 "This script requires a Swift 5.2+ toolchain."
6536
echo >&2
6637
echo >&2 "Examples:"
6738
echo >&2
68-
echo >&2 "Check between master and tag 2.1.1 of swift-nio:"
69-
echo >&2 " $0 https://github.com/apple/swift-nio master 2.1.1"
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"
7041
echo >&2
7142
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
7243
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
@@ -77,12 +48,6 @@ if [[ $# -lt 3 ]]; then
7748
exit 1
7849
fi
7950

80-
sdk=/
81-
if [[ "$(uname -s)" == Darwin ]]; then
82-
sdk=$(xcrun --show-sdk-path)
83-
fi
84-
85-
hash jq 2> /dev/null || { echo >&2 "ERROR: jq must be installed"; exit 1; }
8651
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
8752
repo_url=$1
8853
new_tag=$2
@@ -91,46 +56,13 @@ shift 2
9156
repodir="$tmpdir/repo"
9257
git clone "$repo_url" "$repodir"
9358
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
94-
errors=0
59+
cd "$repodir"
60+
git checkout -q "$new_tag"
9561

9662
for old_tag in "$@"; do
97-
mkdir "$tmpdir/api-old"
98-
mkdir "$tmpdir/api-new"
99-
10063
echo "Checking public API breakages from $old_tag to $new_tag"
10164

102-
build_and_do "$repodir" "$new_tag" "$tmpdir/api-new/"
103-
build_and_do "$repodir" "$old_tag" "$tmpdir/api-old/"
104-
105-
for f in "$tmpdir/api-new"/*; do
106-
f=$(basename "$f")
107-
report="$tmpdir/$f.report"
108-
if [[ ! -f "$tmpdir/api-old/$f" ]]; then
109-
echo "NOTICE: NEW MODULE $f"
110-
continue
111-
fi
112-
113-
echo -n "Checking $f... "
114-
swift api-digester -sdk "$sdk" -diagnose-sdk \
115-
--input-paths "$tmpdir/api-old/$f" -input-paths "$tmpdir/api-new/$f" 2>&1 \
116-
> "$report" 2>&1
117-
118-
if ! shasum "$report" | grep -q cefc4ee5bb7bcdb7cb5a7747efa178dab3c794d5; then
119-
echo ERROR
120-
echo >&2 "=============================="
121-
echo >&2 "ERROR: public API change in $f"
122-
echo >&2 "=============================="
123-
cat >&2 "$report"
124-
errors=$(( errors + 1 ))
125-
else
126-
echo OK
127-
fi
128-
done
129-
rm -rf "$tmpdir/api-new" "$tmpdir/api-old"
65+
swift package diagnose-api-breaking-changes "$old_tag"
13066
done
13167

132-
if [[ "$errors" == 0 ]]; then
133-
echo "OK, all seems good"
134-
fi
13568
echo done
136-
exit "$errors"

0 commit comments

Comments
 (0)