Skip to content

Commit ca38b1a

Browse files
authored
Merge pull request #4308 from mapbox/NAVIOS-424-api-diff-new
NAVIOS-424: Use Xcode api breaking changes detector
2 parents f0e2b59 + 8211e90 commit ca38b1a

File tree

15 files changed

+429
-80
lines changed

15 files changed

+429
-80
lines changed

.base_api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7b8d4d56aae4d0b300f3583776bfe15040e802b6
1+
ae5c7bf237c12b90dd288a43c99e6eef8d827766

.breakage-allowlist

Whitespace-only changes.

.circleci/config.yml

Lines changed: 19 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ commands:
8484
steps:
8585
- when:
8686
condition: << parameters.is_template >>
87-
steps:
87+
steps:
8888
- save_cache:
89-
key: nav-sdk-diff-cache-v7-{{ << parameters.key >> }}
89+
key: nav-sdk-diff-cache-v8-{{ << parameters.key >> }}
9090
paths:
9191
- api_logs
9292
- store_artifacts:
@@ -96,7 +96,7 @@ commands:
9696
condition: << parameters.is_template >>
9797
steps:
9898
- save_cache:
99-
key: nav-sdk-diff-cache-v7-<< parameters.key >>
99+
key: nav-sdk-diff-cache-v8-<< parameters.key >>
100100
paths:
101101
- api_logs
102102
- store_artifacts:
@@ -112,52 +112,25 @@ commands:
112112
steps:
113113
- when:
114114
condition: << parameters.is_template >>
115-
steps:
115+
steps:
116116
- restore_cache:
117-
key: nav-sdk-diff-cache-v7-{{ << parameters.key >> }}
117+
key: nav-sdk-diff-cache-v8-{{ << parameters.key >> }}
118118
- unless:
119119
condition: << parameters.is_template >>
120120
steps:
121121
- restore_cache:
122-
key: nav-sdk-diff-cache-v7-<< parameters.key >>
122+
key: nav-sdk-diff-cache-v8-<< parameters.key >>
123123

124-
build-api-diff-cli-tool:
125-
description: "Builds CLI tool which produce diff reports"
126-
parameters:
127-
swift-api-diff-version:
128-
type: string
129-
default: "v2.0.0-rc.2"
124+
run_api_log_in_current_env:
130125
steps:
131-
- add_ssh_keys:
132-
fingerprints:
133-
- "8c:24:d5:99:22:42:45:8f:16:6f:8d:24:ee:08:97:13"
134-
- restore_cache:
135-
key: swift-api-diff-v1-<<parameters.swift-api-diff-version>>
136126
- run:
137-
name: Building API Diff Report if Needed
127+
name: "Build SDK API Logs"
138128
command: |
139-
if [ ! -f "scripts/swift-api-diff/.build/release/swift-api-diff" ]; then
140-
cd scripts && git clone [email protected]:mapbox/swift-api-diff.git --branch <<parameters.swift-api-diff-version>> --depth 1
141-
cd swift-api-diff && swift build --configuration release;
142-
fi
143-
- save_cache:
144-
key: swift-api-diff-v1-<<parameters.swift-api-diff-version>>
145-
paths:
146-
- scripts/swift-api-diff/.build/release/swift-api-diff
129+
set -e -o pipefail -u
130+
131+
mkdir $CIRCLE_WORKING_DIRECTORY/api_logs
132+
$CIRCLE_WORKING_DIRECTORY/scripts/api-compatibility-check/build-api-logs.sh "12.0" $CIRCLE_WORKING_DIRECTORY $CIRCLE_WORKING_DIRECTORY/api_logs/core_navigation_log.json $CIRCLE_WORKING_DIRECTORY/api_logs/navigation_log.json
147133
148-
run_api_log_in_current_env:
149-
parameters:
150-
iOS:
151-
type: string
152-
device:
153-
type: string
154-
steps:
155-
- run:
156-
name: Generating MapboxCoreNavigation API Log
157-
command: ./scripts/swift-api-diff/.build/release/swift-api-diff doc ./ $CIRCLE_WORKING_DIRECTORY/api_logs/core_navigation_log.json --module-name MapboxCoreNavigation -- -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=<< parameters.iOS >>,name=<< parameters.device >>' -scheme MapboxNavigation-Package build
158-
- run:
159-
name: Generating MapboxNavigation API Log
160-
command: ./scripts/swift-api-diff/.build/release/swift-api-diff doc ./ $CIRCLE_WORKING_DIRECTORY/api_logs/navigation_log.json --module-name MapboxNavigation -- -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=<< parameters.iOS >>,name=<< parameters.device >>' -scheme MapboxNavigation-Package build
161134
run_breaking_changes_detector:
162135
parameters:
163136
module_name:
@@ -171,16 +144,7 @@ commands:
171144
name: Generating << parameters.module_name >> API Diff
172145
command: |
173146
export GITHUB_TOKEN=$(mbx-ci github issues public token)
174-
LOG=$(./scripts/swift-api-diff/.build/release/swift-api-diff breaking_changes << parameters.base_api_path >> << parameters.new_api_path >> --ignore-undocumented true)
175-
if [ ! -z "$CIRCLE_PULL_REQUEST" ]; then
176-
if [ -z "$LOG" ]; then
177-
echo "No breaking changes detected in << parameters.module_name >>"
178-
else
179-
PR_COMMENT=$'# Breaking Changes in << parameters.module_name >>\n\n'
180-
PR_COMMENT+="$LOG"
181-
gh pr comment -F - \<<< "$PR_COMMENT"
182-
fi
183-
fi
147+
./scripts/api-compatibility-check/ci-analyze-api.sh << parameters.module_name >> << parameters.base_api_path >> << parameters.new_api_path >> $CIRCLE_WORKING_DIRECTORY/.breakage-allowlist.txt
184148
185149
carthage-bootstrap:
186150
steps:
@@ -216,7 +180,7 @@ step-library:
216180
key: 1-gems-{{ checksum "Gemfile.lock" }}
217181
paths:
218182
- vendor/bundle
219-
183+
220184
- &save-cache-cocoapods
221185
save_cache:
222186
key: nav-cache-pod-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Tests/CocoaPodsTest/PodInstall/Podfile.lock" }}
@@ -454,7 +418,7 @@ jobs:
454418
steps:
455419
- checkout
456420
- *trigger-metrics
457-
421+
458422
spm-test-job:
459423
parameters:
460424
xcode:
@@ -518,17 +482,11 @@ jobs:
518482
parameters:
519483
xcode:
520484
type: string
521-
default: "13.0.0"
522-
device:
523-
type: string
524-
default: "iPhone 12 Pro Max"
525-
iOS:
526-
type: string
527-
default: "14.5"
485+
default: "14.2.0"
528486
is_base_api:
529487
type: boolean
530488
default: false
531-
commit_hash:
489+
commit_hash:
532490
description: "git hash of the commit to be used for generating logs in api_logs folder"
533491
type: string
534492
macos:
@@ -574,13 +532,7 @@ jobs:
574532
- run:
575533
name: Checking out commit
576534
command: git checkout << parameters.commit_hash >>
577-
- build-api-diff-cli-tool
578-
- run:
579-
name: Move Xcode project aside
580-
command: rm -rf *.xcodeproj
581-
- run_api_log_in_current_env:
582-
iOS: << parameters.iOS >>
583-
device: << parameters.device >>
535+
- run_api_log_in_current_env
584536
- when:
585537
condition: << parameters.is_base_api >>
586538
steps:
@@ -594,26 +546,15 @@ jobs:
594546
key: << parameters.commit_hash >>
595547

596548
api-diff-job:
597-
parameters:
598-
xcode:
599-
type: string
600-
default: "13.0.0"
601-
device:
602-
type: string
603-
default: "iPhone 13 Pro Max"
604-
iOS:
605-
type: string
606-
default: "15.0"
607549
macos:
608-
xcode: << parameters.xcode >>
550+
xcode: 14.2.0
609551
environment:
610552
HOMEBREW_NO_AUTO_UPDATE: 1
611553
steps:
612554
- checkout
613555
- *add-github-to-known-hosts
614556
- *prepare-mapbox-file
615557
- *prepare-netrc-file
616-
- build-api-diff-cli-tool
617558
- install-mbx-ci
618559
- install-gh-cli
619560
- restore-api-diff-cache:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ Examples/Swift/Navigation_Example.mobileprovision
2323

2424
*-pre.podspec
2525

26-
vendor/bundle/ruby/
26+
vendor/bundle/ruby/
27+
.vscode
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# This script builds MapboxNavigation and MapboxCoreNavigation frameworks and then extracts their public API using swift-api-digester tool.
4+
5+
set -e -o pipefail -u
6+
7+
if [ $# -ne 4 ]; then
8+
echo -e "Usage: $0 <ios_version> <root_dir> <core_module_logs_path> <ui_module_logs_path>\n- <ios-version>: iOS version to build the frameworks for (e.g. 12.0)"
9+
exit 1
10+
fi
11+
12+
IOS_VERSION=$1
13+
ROOT_DIR=$2
14+
CORE_MODULE_LOGS_PATH=$3
15+
UI_MODULE_LOGS_PATH=$4
16+
17+
PROJECT_PATH=$ROOT_DIR/MapboxNavigation-SPM.xcodeproj/
18+
19+
TARGET="arm64-apple-ios${IOS_VERSION}"
20+
SDK=iphoneos
21+
CONFIGURATION=Release
22+
23+
xcodebuild -sdk $SDK -destination 'generic/platform=iOS' -project "$PROJECT_PATH" -scheme MapboxNavigation -configuration $CONFIGURATION build
24+
DERIVED_DATA_PATH=$(xcodebuild -destination 'generic/platform=iOS' -sdk $SDK -project "$PROJECT_PATH" -configuration $CONFIGURATION -showBuildSettings | grep -m 1 "CONFIGURATION_BUILD_DIR" | grep -oEi "\/.*")
25+
26+
xcrun -sdk $SDK swift-api-digester -sdk $(xcrun --sdk $SDK --show-sdk-path) -dump-sdk -module MapboxNavigation -o $UI_MODULE_LOGS_PATH -target $TARGET -I "$DERIVED_DATA_PATH"
27+
xcrun -sdk $SDK swift-api-digester -sdk $(xcrun --sdk $SDK --show-sdk-path) -dump-sdk -module MapboxCoreNavigation -o $CORE_MODULE_LOGS_PATH -target $TARGET -I "$DERIVED_DATA_PATH"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
# This scripts compares two API logs and posts a comment to the PR with the result of the comparison.
4+
5+
set -e -o pipefail -u
6+
7+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
9+
if [ $# -ne 4 ]; then
10+
echo "Usage: $0 <module_name> <base_api_path> <new_api_path> <breakage_allowlist_path"
11+
exit 1
12+
fi
13+
14+
MODULE_NAME=$1
15+
BASE_API_PATH=$2
16+
NEW_API_PATH=$3
17+
BREAKAGE_ALLOWLIST_PATH=$4
18+
19+
echo "Building API compatibility report..."
20+
REPORT=$(xcrun --sdk iphoneos swift-api-digester -diagnose-sdk -input-paths "$BASE_API_PATH" -input-paths "$NEW_API_PATH" -breakage-allowlist-path $BREAKAGE_ALLOWLIST_PATH 2>&1 >/dev/null)
21+
echo "Report is $REPORT"
22+
23+
echo "Parsing report..."
24+
pushd "$SCRIPT_DIR/swift-api-compatibility" > /dev/null
25+
COMMENT=$(swift run -c release swift-api-compatibility parse-report "$MODULE_NAME" "$REPORT")
26+
popd
27+
28+
echo "Comment is $COMMENT"
29+
30+
if [[ ! $COMMENT == *"🟢"* ]]; then
31+
gh pr comment --body "$COMMENT"
32+
else
33+
echo "No Breaking Changes"
34+
fi
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/config/registries.json
8+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
.netrc

scripts/api-compatibility-check/swift-api-compatibility/Package.resolved

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version: 5.7
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-api-compatibility",
7+
products: [
8+
.executable(
9+
name: "swift-api-compatibility",
10+
targets: ["SwiftApiCompatibility"]
11+
),
12+
],
13+
dependencies: [
14+
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"),
15+
],
16+
targets: [
17+
.executableTarget(
18+
name: "SwiftApiCompatibility",
19+
dependencies: [
20+
"SwiftApiCompatibilityKit",
21+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
22+
]
23+
),
24+
.target(name: "SwiftApiCompatibilityKit"),
25+
.testTarget(name: "SwiftApiCompatibilityKitTests", dependencies: [
26+
"SwiftApiCompatibilityKit",
27+
])
28+
]
29+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# swift-api-compatibility-check
2+
3+
Helper tool for api compatibility check.

0 commit comments

Comments
 (0)