Skip to content

Commit fe736f4

Browse files
authored
Breakage api check (#979)
* script to check api breakage * check api breakage part of sanity check
1 parent bc592b1 commit fe736f4

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.circleci/config.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ orbs:
88

99
commands:
1010

11+
check-api-breakage:
12+
steps:
13+
- run:
14+
name: Add pub-cache to PATH
15+
command: echo 'export PATH="$HOME/.pub-cache/bin:$PATH"' >> $BASH_ENV
16+
- run:
17+
name: Install dart_apitool
18+
command: dart pub global activate dart_apitool 0.21.1
19+
- run:
20+
name: Check API breakage
21+
command: bash scripts/check_api_breakage.sh
22+
1123
inject-netrc-credentials:
1224
steps:
1325
- run:
@@ -224,7 +236,7 @@ jobs:
224236
steps:
225237
- checkout
226238
- flutter/install_sdk_and_pub:
227-
version: 3.24.3
239+
version: 3.27.0
228240
- run:
229241
name: Check license
230242
command: bash scripts/license.sh --mode validate
@@ -235,6 +247,7 @@ jobs:
235247
name: Check all tests are in the test suite
236248
command: dart ../scripts/check_test_suite.dart
237249
working_directory: example
250+
- check-api-breakage
238251

239252
workflows:
240253
build:

scripts/check_api_breakage.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Check if dart_apitool is activated globally
5+
if ! dart pub global list | grep -q 'dart_apitool'; then
6+
echo "dart_apitool is not activated globally. Please run: dart pub global activate dart_apitool"
7+
exit 1
8+
fi
9+
10+
# Get the current stable version of mapbox_maps_flutter on pub.dev
11+
PACKAGE_NAME="mapbox_maps_flutter"
12+
PACKAGE_VERSION=$(curl -s "https://pub.dev/api/packages/$PACKAGE_NAME" | grep -o '"latest":{"version":"[^"]*' | grep -o '[0-9]\+\(\.[0-9]\+\)*')
13+
echo "Current stable version of mapbox_maps_flutter: $PACKAGE_VERSION"
14+
15+
# Get the path of local mapbox-maps-flutter
16+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17+
LOCAL_PACKAGE_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
18+
19+
# Run dart_apitool to check for API breakage
20+
dart-apitool diff \
21+
--old pub://$PACKAGE_NAME/$PACKAGE_VERSION \
22+
--new $LOCAL_PACKAGE_ROOT \
23+
--version-check-mode=onlyBreakingChanges

0 commit comments

Comments
 (0)