Skip to content

Commit 2f91030

Browse files
authored
feat(appium): add --releases to check out latest SDK release points (#48)
1 parent 6786121 commit 2f91030

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
# Check out the latest stable release point in each downstream SDK repo.
3+
# - rel-branch repos: newest stable rel/X.Y.Z branch (betas + non-semver excluded)
4+
# - tag-only repos (expo, ios): newest semver tag (detached HEAD)
5+
# Repo paths honor the same *_DIR overrides as run-local.sh (loaded from .env),
6+
# falling back to the config.sh defaults under $SDK_ROOT.
7+
# Repos with uncommitted changes are skipped, never clobbered.
8+
set -uo pipefail
9+
10+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
11+
APPIUM_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
12+
SDK_ROOT="$(cd "$APPIUM_DIR/../.." && pwd)"
13+
14+
# Load .env so *_DIR overrides here match run-local.sh's resolution.
15+
if [[ -f "$SCRIPT_DIR/.env" ]]; then
16+
set -a
17+
source "$SCRIPT_DIR/.env"
18+
set +a
19+
fi
20+
21+
# var|default-subpath|kind (kind: rel = latest rel/* branch, tag = latest semver tag)
22+
# Defaults mirror run-local/config.sh; override any via *_DIR in .env.
23+
REPOS=(
24+
"FLUTTER_DIR|OneSignal-Flutter-SDK|rel"
25+
"RN_DIR|react-native-onesignal|rel"
26+
"CORDOVA_DIR|OneSignal-Cordova-SDK|rel"
27+
"CAPACITOR_DIR|OneSignal-Capacitor-SDK|rel"
28+
"DOTNET_DIR|DotNet/OneSignal-DotNet-SDK|rel"
29+
"UNITY_DIR|OneSignal-Unity-SDK|rel"
30+
"ANDROID_DIR|OneSignal-Android-SDK|rel"
31+
"EXPO_DIR|onesignal-expo-plugin|tag"
32+
"IOS_DIR|OneSignal-iOS-SDK|tag"
33+
)
34+
35+
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
36+
37+
for entry in "${REPOS[@]}"; do
38+
IFS='|' read -r var subpath kind <<< "$entry"
39+
p="${!var:-$SDK_ROOT/$subpath}" # .env override wins, else default
40+
name="$(basename "$p")"
41+
42+
if [[ ! -d "$p/.git" ]]; then
43+
echo -e "${RED}SKIP${NC} $name (not a git repo: $p — set $var in .env)"; continue
44+
fi
45+
if [[ -n "$(git -C "$p" status --porcelain)" ]]; then
46+
echo -e "${YELLOW}SKIP${NC} $name (uncommitted changes — leaving on $(git -C "$p" rev-parse --abbrev-ref HEAD))"; continue
47+
fi
48+
49+
git -C "$p" fetch --prune --tags origin >/dev/null 2>&1
50+
51+
if [[ "$kind" == "rel" ]]; then
52+
target=$(git -C "$p" for-each-ref --format='%(refname:short)' 'refs/remotes/origin/rel/*' \
53+
| sed 's|^origin/||' | grep -E '^rel/[0-9]+\.[0-9]+(\.[0-9]+)?$' | sort -V | tail -1)
54+
if [[ -z "$target" ]]; then
55+
echo -e "${RED}SKIP${NC} $name (no stable rel/* branch found)"; continue
56+
fi
57+
else
58+
target=$(git -C "$p" tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+(\.[0-9]+)?$' | head -1)
59+
if [[ -z "$target" ]]; then
60+
echo -e "${RED}SKIP${NC} $name (no semver tag found)"; continue
61+
fi
62+
fi
63+
64+
if git -C "$p" checkout "$target" >/dev/null 2>&1; then
65+
[[ "$kind" == "rel" ]] && git -C "$p" pull --ff-only >/dev/null 2>&1
66+
echo -e "${GREEN}OK${NC} $name -> $target"
67+
else
68+
echo -e "${RED}FAIL${NC} $name (could not checkout $target)"
69+
fi
70+
done

appium/scripts/run-all.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ PLATFORM_FILTER=""
2222
SDKS_FILTER=""
2323
BAIL=0
2424
PODS_REQUESTED=0
25+
RELEASES=0
2526
for arg in "$@"; do
2627
case "$arg" in
2728
--skip-build|--skip-device|--skip-reset|--skip|--quiet|-q)
2829
EXTRA_ARGS+=("$arg") ;;
2930
--pods)
3031
PODS_REQUESTED=1 ;;
32+
--releases)
33+
RELEASES=1 ;;
3134
--spec=*)
3235
EXTRA_ARGS+=("$arg") ;;
3336
--platform=ios|--platform=android)
@@ -56,6 +59,9 @@ Options:
5659
Note: 'android' (native) skips --platform=ios and
5760
'ios' (native) skips --platform=android.
5861
--bail Stop after the first failing combo
62+
--releases Check out the latest release point in each SDK repo
63+
first (runs checkout-releases.sh; honors *_DIR from
64+
.env). Skips repos with uncommitted changes.
5965
6066
Options forwarded to run-local.sh:
6167
--skip-build Skip per-app build (reuse existing artifact)
@@ -111,6 +117,15 @@ if (( PODS_REQUESTED )); then
111117
fi
112118
fi
113119

120+
if (( RELEASES )); then
121+
echo -e "${BOLD}━━━ Checking out latest releases ━━━${NC}"
122+
if ! "$SCRIPT_DIR/checkout-releases.sh"; then
123+
error "checkout-releases.sh failed; aborting before running combos"
124+
exit 1
125+
fi
126+
echo ""
127+
fi
128+
114129
declare -a RESULTS
115130
FAILED=0
116131
BAILED=0

0 commit comments

Comments
 (0)