-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo.sh
executable file
·203 lines (179 loc) · 3.57 KB
/
go.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
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
200
201
202
203
#!/usr/bin/env bash
if [[ -z "${PACT_FOLDER}" ]]; then
echo "PACT_FOLDER not set"
exit 1;
else
PACT_FOLDER="${PACT_FOLDER}"
fi
d_check() {
command -v python3 >/dev/null 2>&1 || { echo >&2 "python3 was not found. Aborting."; exit 1; }
command -v pip3 >/dev/null 2>&1 || { echo >&2 "pip3 was not found. Aborting."; exit 1; }
command -v yarn >/dev/null 2>&1 || { echo >&2 "yarn was not found. Aborting."; exit 1; }
command -v wget >/dev/null 2>&1 || { echo >&2 "wget was not found. Aborting."; exit 1; }
command -v java >/dev/null 2>&1 || { echo >&2 "java was not found. Aborting."; exit 1; }
command -v ruby >/dev/null 2>&1 || { echo >&2 "ruby was not found. Aborting."; exit 1; }
command -v docker >/dev/null 2>&1 || { echo >&2 "docker is not running. Aborting."; exit 1; }
command -v docker-compose >/dev/null 2>&1 || { echo >&2 "docker-compose was not found. Aborting."; exit 1; }
}
setup()
{
d_check
docker pull pactfoundation/pact-stub-server
cd ./ui_smoke
python3 -m pip install --user virtualenv
python3 -m venv env
pip3 install -r requirements.txt
playwright install
cd ../web-ui
yarn install
cd ../web-api
./gradlew clean
cd ../wallet
bundle install
cd ../certifier
bundle install
cd ..
}
test_client()
{
cd ./web-ui
yarn audit && yarn lint && yarn test
PORT=3000 yarn run dev &
local client_pid=$!
../waitfor.sh http://localhost:3000 -t 20 -- echo "client started"
../waitfor.sh http://localhost:8080/wallets/ea4ceefe-cfe6-49e8-a36d-1a889c780bb4 -t 20 -- echo "stubs started"
cd ../ui_smoke
pytest
cd ..
kill ${client_pid}
}
test_wallet()
{
cd wallet
bundle exec rake test
APP_ENV=test PACT_DO_NOT_TRACK=true bundle exec rake pact:verify
cd ..
}
test_certifier()
{
cd certifier
bundle exec rake db:migrate
bundle exec rake test
APP_ENV=test PACT_DO_NOT_TRACK=true bundle exec rake pact:verify
cd ..
}
test_api()
{
cd wallet
bundle exec rackup -p 8081 &
local wallet_pid=$!
cd ../web-api
./gradlew clean
./gradlew test
cd ..
kill ${wallet_pid}
}
generate_pacts()
{
cd web-ui
yarn run test:cdc
cd ../web-api
./gradlew clean test --tests "org.scrumfall.webapi.contract.providers.*"
cd ..
}
run_pact_stubs()
{
docker run --rm -t --name pact-stubs -p 8080:8080 -v "${PACT_FOLDER}:/app/pacts" pactfoundation/pact-stub-server -p 8080 -d pacts --cors &
}
run_ui()
{
d_check
generate_pacts
run_pact_stubs
cd ./web-ui
PORT=3000 ../waitfor.sh http://localhost:8080/wallets/ea4ceefe-cfe6-49e8-a36d-1a889c780bb4 -t 20 -- yarn run dev
}
test()
{
d_check
cat <<EOF
-----------------
generate_pacts
-----------------
EOF
generate_pacts
cat <<EOF
-----------------
start pact-stubs
-----------------
EOF
run_pact_stubs
cat <<EOF
-----------------
test_client
-----------------
EOF
test_client
cat <<EOF
-----------------
test_api
-----------------
EOF
test_api
cat <<EOF
-----------------
test_wallet
-----------------
EOF
test_wallet
cat <<EOF
-----------------
test_certifier
-----------------
EOF
test_certifier
cat <<EOF
-----------------
stop pact-stubs
-----------------
EOF
docker stop pact-stubs
}
print_usage()
{
cat <<EOF
Usage: PACT_FOLDER=<path> $0 [option]
setup setup
generate_pacts generate the contracts to PACT_FOLDER
test run all tests
run_ui run ui on pact stubs
EOF
}
payment_stub()
{
cd mockserver
docker-compose up
}
case $1 in
setup)
setup
;;
test)
test
;;
payment_stub)
payment_stub
;;
run_pact_stubs)
run_pact_stubs
;;
generate_pacts)
generate_pacts
;;
run_ui)
run_ui
;;
*)
print_usage
;;
esac