-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (180 loc) · 7.54 KB
/
Copy pathbuild-and-test.yaml
File metadata and controls
199 lines (180 loc) · 7.54 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
on: [pull_request, workflow_dispatch]
name: Build and Test Pipeline
jobs:
build:
name: Build and Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.22.4'
channel: 'stable'
- uses: actions/setup-node@v2
with:
node-version: '12'
- name: Pub get - Example
working-directory: ./mobilefoundation/example
run: |
flutter pub get
- name: Pub get - Test App
working-directory: ./mobilefoundation/tests_app
run: |
flutter pub get
- name: Analyze MF SDK
working-directory: ./mobilefoundation
run: |
flutter pub get
flutter analyze
- name: Build app
working-directory: ./mobilefoundation/example
run: |
flutter build apk
flutter build ios --no-codesign
- name: Check if publishable
working-directory: ./mobilefoundation
run: |
flutter pub publish --dry-run
- name : Run Tests when server not running on iOS Simulator
working-directory: ./mobilefoundation/tests_app
run: |
xcode-select -v
xcrun simctl list
open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
sleep 60
flutter pub get
flutter doctor -v
flutter drive --target=test_driver/app.dart --driver=test_driver/app_noserver.dart
killall "Simulator"
- name: Run Tests when server not running on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
target: default
arch: x86_64
profile: Nexus 6
script: cd ./mobilefoundation/tests_app && flutter pub get && flutter doctor -v && flutter drive --target=test_driver/app.dart --driver=test_driver/app_noserver.dart
- name: Setup MobileFirst Server using Docker
working-directory: ./mobilefoundation/tests_app
run: |
brew install --cask docker-toolbox
docker-machine create --driver "virtualbox" TestApp
eval "$(docker-machine env TestApp)"
docker-machine ls
docker pull ibmcom/ibm-mobilefoundation-ce:latest
CONTIANER_ID=$(docker run -d -p 9080:9080 -p 9443:9443 -e MFPF_ANALYTICS_PROTOCOL=http -e ANALYTICS_SVC_NAME=localhost -e ANALYTICS_PORT=9080 -e MFPF_SERVER_PROTOCOL=http -e ADMIN_HOST=localhost -e MFPF_SERVER_PORT=9080 -e RUNTIME_SVC_NAME=localhost -e MFPF_ANALYTICS_RECVR_HOST=localhost ibmcom/ibm-mobilefoundation-ce)
docker ps
echo "CONTIANER_ID=${CONTIANER_ID}" >> $GITHUB_ENV
echo "Container ID: ${CONTIANER_ID}"
sleep 10
poll=0
while [ "$poll" -lt 10 ]; do
poll=$(( poll + 1 ))
echo "Count --> $poll"
curl --location --request GET http://192.168.99.100:9080/mfpadmin/management-apis/2.0/diagnostic --user "admin:admin" -o output.json
line=$(head -n 1 output.json)
case $line in
*"html"*)
echo "Mobile Foundation Admin Service is not up yet"
if [ "$poll" -ge 10 ]; then
echo "Mobile Foundation Server did not start"
exit 1;
fi
sleep 20
continue
;;
esac
MFPROJECT_LENGTH=$(node -pe 'JSON.parse(process.argv[1]).runningProjectStatuses.length' "$(cat output.json)")
echo "Output status length ---> $MFPROJECT_LENGTH"
if [ "$MFPROJECT_LENGTH" == "1" ]; then
echo "Checking status"
STATUS=$(node -pe 'JSON.parse(process.argv[1]).runningProjectStatuses[0].running' "$(cat output.json)")
if [ "$STATUS" == "true" ]; then
echo "Mobile Foundation Server is UP : $STATUS"
break;
else
echo "Mobile Foundation Server is not running"
if [ "$poll" -ge 10 ]; then
echo "Mobile Foundation Server did not start"
exit 1;
fi
sleep 20
continue
fi
else
echo "No data available. Retry"
if [ "$poll" -ge 10 ]; then
echo "Mobile Foundation Server did not start"
exit 1;
fi
sleep 20
continue
fi
done
echo "Getting the logs"
docker logs ${CONTIANER_ID}
curl http://192.168.99.100:9080/mfp/api/az/v1/token
curl --location --request POST 'http://192.168.99.100:9080/mfpadmin/management-apis/2.0/runtimes/mfp/adapters' \
--user "admin:admin" \
--form 'adapterPath=@./adapters/UserLogin.adapter'
curl --location --request POST 'http://192.168.99.100:9080/mfpadmin/management-apis/2.0/runtimes/mfp/adapters' \
--user "admin:admin" \
--form 'adapterPath=@./adapters/ResourceAdapter.adapter'
curl --location --request POST 'http://192.168.99.100:9080/mfpadmin/management-apis/2.0/runtimes/mfp/adapters' \
--user "admin:admin" \
--form 'adapterPath=@./adapters/PinCodeAttempts.adapter'
cat <<EOF > ./registeriosconfig.json
{
"applicationKey":{
"version":"1.0.0",
"clientPlatform":"ios",
"bundleId":"com.example.testsApp"
},
"displayName":"RunnerTest",
"scopeElementMapping":{
"accessRestricted":"UserLogin",
"checkScope":""
}
}
EOF
curl -X POST "http://192.168.99.100:9080/mfpadmin/management-apis/2.0/runtimes/mfp/applications?async=false&locale=en_US" -H "Content-Type: application/json" --user "admin:admin" -H "cache-control: no-cache" -d @./registeriosconfig.json -o output.json
cat ./output.json
cat <<EOF > ./registerandroidconfig.json
{
"applicationKey":{
"version":"1.0.0",
"clientPlatform":"android",
"packageName":"com.example.tests_app"
},
"displayName":"tests_app",
"scopeElementMapping":{
"accessRestricted":"UserLogin",
"checkScope":""
}
}
EOF
curl -X POST "http://192.168.99.100:9080/mfpadmin/management-apis/2.0/runtimes/mfp/applications?async=false&locale=en_US" -H "Content-Type: application/json" --user "admin:admin" -H "cache-control: no-cache" -d @./registerandroidconfig.json -o output.json
cat ./output.json
- name : Run Tests on iOS Simulator
working-directory: ./mobilefoundation/tests_app
run: |
open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
sleep 60
flutter drive --target=test_driver/app.dart --driver=test_driver/app_test.dart
killall "Simulator"
- name: Run Tests on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
target: default
arch: x86_64
profile: Nexus 6
script: cd ./mobilefoundation/tests_app && flutter pub get && flutter doctor -v && flutter drive --target=test_driver/app.dart --driver=test_driver/app_test.dart
- name: Check any issues with doc generation
working-directory: ./mobilefoundation
run: |
flutter pub global activate dartdoc
flutter pub global run dartdoc:dartdoc