forked from fly1tkg/wercker-step-testfairy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
90 lines (76 loc) · 2.42 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
validate_params() {
# Required parameters
if [ ! -n "$WERCKER_TESTFAIRY_APK_FILE" ]
then
fail "missing apk_file, please check your wercker.yml"
fi
if [ ! -e "$WERCKER_TESTFAIRY_APK_FILE" ]
then
fail "apk file is not found, please check the apk file path"
fi
if [ ! -n "$WERCKER_TESTFAIRY_API_KEY" ]
then
fail "missing api_key, please check your wercker.yml"
fi
}
set_default_params_if_needed() {
#Optional parameters
if [ ! -n "$WERCKER_TESTFAIRY_METRICS" ]
then
WERCKER_TESTFAIRY_METRICS="cpu,memory,network,logcat,phone-signal,gps,battery"
fi
if [ ! -n "$WERCKER_TESTFAIRY_MAX_DURATION" ]
then
WERCKER_TESTFAIRY_MAX_DURATION="10m"
fi
if [ ! -n "$WERCKER_TESTFAIRY_VIDEO" ]
then
WERCKER_TESTFAIRY_VIDEO="on"
fi
if [ ! -n "$WERCKER_TESTFAIRY_VIDEO_QUALITY" ]
then
WERCKER_TESTFAIRY_VIDEO_QUALITY="high"
fi
if [ ! -n "$WERCKER_TESTFAIRY_VIDEO_RATE" ]
then
WERCKER_TESTFAIRY_VIDEO_RATE="1.0"
fi
if [ ! -n "$WERCKER_TESTFAIRY_ICON_WAETERMARK" ]
then
WERCKER_TESTFAIRY_ICON_WAETERMARK="off"
fi
if [ ! -n "$WERCKER_TESTFAIRY_COMMENT" ]
then
WERCKER_TESTFAIRY_COMMENT="Deploy of commit: $WERCKER_GIT_COMMIT from branch: $WERCKER_GIT_BRANCH"
fi
}
deploy_to_testfairy() {
if [ -n "$WERCKER_TESTFAIRY_PROGUARD_FILE" ]
then
PROGUARD_FILE_OPTION="-F proguard_file=@$WERCKER_TESTFAIRY_PROGUARD_FILE"
fi
curl --tlsv1 https://app.testfairy.com/api/upload/ \
-F api_key="$WERCKER_TESTFAIRY_API_KEY" \
-F apk_file=@"$WERCKER_TESTFAIRY_APK_FILE" \
-F testers_groups="$WERCKER_TESTFAIRY_TESTERS_GROUPS" \
-F metrics="$WERCKER_TESTFAIRY_METRICS" \
-F max-duration="$WERCKER_TESTFAIRY_MAX_DURATION" \
-F video="$WERCKER_TESTFAIRY_VIDEO" \
-F video-quality="$WERCKER_TESTFAIRY_VIDEO_QUALITY" \
-F video-rate="$WERCKER_TESTFAIRY_VIDEO_RATE" \
-F icon-watermark="$WERCKER_TESTFAIRY_ICON_WAETERMARK" \
-F comment="$WERCKER_TESTFAIRY_COMMENT" \
$PROGUARD_FILE_OPTION
}
check_response() {
if [ ! `echo $1 | grep '"status":"ok"'` ]
then
fail "deploying to TestFairy is failed, please check your wercker.yml"
fi
}
validate_params
set_default_params_if_needed
RES=`deploy_to_testfairy`
info "TestFairy response: $RES"
check_response $RES