forked from infinitered/ignite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestRelease.sh
executable file
·168 lines (150 loc) · 4.59 KB
/
testRelease.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#! /bin/bash
#################### Running this Script #######################
# Verify Git status is clean
# Verify current git is what you're testing
# Run this with `./testRelease.sh <release version>`
#
# If you'd like to test Ignite against FB Master branch
# Run with 2nd param latest `./testRelease.sh fb_check latest`
################################################################
if [[ -z $1 ]]; then
echo 'Must pass release version as parameter'
exit 1
fi
SOMETHING_FAILED=0
echo "#########################################################"
echo '# Test a release of Ignite before actually releasing it #'
echo '# ._______. #'
echo '# | \ / | #'
echo '# .--|.O.|.O.|______. #'
echo '# __).-| = | = |/ \ | #'
echo "# >__) (.'---\`.)Q.|.Q.|--. #"
echo '# \\___// = | = |-.(__ #'
echo "# \`---'( .---. ) (__< #"
echo "# \\\\.-.// #"
echo "# \`---' #"
echo '#########################################################'
# Runs command and on failure turns on the SOMETHING_FAILED flag
function test_command {
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "👎 👎 👎 👎 👎 👎 👎 👎 - $1 Failed" >&2
SOMETHING_FAILED=1
fi
return $status
}
fire_drill()
{
echo '~~~🌟 Running Fire Drill'
test_command ./fireDrill.sh
}
setup()
{
echo '~~~🌟 Linking local for Testing'
cd ignite-generator
test_command npm link
cd ../ignite-cli
test_command npm link
cd ../
mkdir testgrounds
cd testgrounds
# Check flag to see if we're testing RN latest against FB latest
if [[ $2 = "latest" ]]; then
echo '~~~🌟 Testing Master vs Facebook Latest'
test_command npm install -g react-native-cli
test_command ignite n TestProj --branch master --latest
else
echo '~~~🌟 Setting up branch'
git branch -d test_$1
git checkout -b test_$1
git push origin test_$1
echo '~~~🌟 Creating project from branch'
test_command ignite n TestProj --branch test_$1
fi
cd TestProj
}
verify_code()
{
echo '~~~🌟 Checking Code'
test_command standard App/
test_command npm test
}
check_builds()
{
echo '~~~🌟 Checking Builds'
if [ ! -d "android" ]; then
echo 'Android folder did not generate'
SOMETHING_FAILED=1
fi
if [ ! -d "ios" ]; then
echo 'ios folder did not generate'
SOMETHING_FAILED=1
fi
echo '~ Build ios'
test_command react-native bundle --entry-file index.ios.js --bundle-output test.ios.js
echo '~ Build android'
# A failed android build will not exit with a non-zero return!
# This makes it a bit trickier to test for - look for the fail message instead
cd android
./gradlew assembleRelease | grep -q 'BUILD FAILED'
if [[ $? -eq 0 ]]; then
echo 'Android build failed'
SOMETHING_FAILED=1
fi
cd -
}
clean_up()
{
echo '~~~🌟 Cleanup'
cd ../../
rm -rf testgrounds
if [[ -z $2 ]]; then
git checkout -
git branch -d test_$1
git push origin --delete test_$1
fi
}
check_generators()
{
echo '~~~🌟 Running Generator Tests'
# Note to future self: You can add more generator:locations to this list!
declare -a params=('component:components' 'container:containers' 'screen:containers')
# Loop through the generators array and create the files
for i in "${params[@]}"
do
#This will work in BASH, not sure about other shells, though.
IFS=':' read -a split <<< "${i}"
test_command ignite g ${split[0]} tester${split[0]}
done
# Then make sure they've arrived.
for i in "${params[@]}"
do
IFS=':' read -a split <<< "${i}"
if [ ! -f 'App/'${split[1]}/'tester'${split[0]}'.js' ]; then
echo ${split[0]} 'testing failed:' ${split[0]} 'js file was not generated.'
SOMETHING_FAILED=1
fi
if [ ! -f 'App/'${split[1]}'/Styles/tester'${split[0]}'Style.js' ]; then
echo ${split[0]} ' testing failed:' ${split[0]} 'style file not generated.'
SOMETHING_FAILED=1
fi
done
}
# This is where the magic happens
fire_drill
setup $1 $2
verify_code
check_generators
check_builds
clean_up $1 $2
# Done
if [ "$SOMETHING_FAILED" != "0" ]; then
echo "~~~👎 Done with errors" 1>&2
exit 1
else
echo "~~~👍 Everything looks good!"
# depends on $SECONDS being part of sh
printf '%dh:%dm:%ds\n' $(($SECONDS/3600)) $(($SECONDS%3600/60)) $(($SECONDS%60))
exit 0
fi