forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-ci.sh
executable file
·225 lines (180 loc) · 6.52 KB
/
docker-ci.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash -e
# Run inside https://hub.docker.com/r/devexpress/devextreme-build/
trap "echo 'Interrupted!' && kill -9 0" TERM INT
export DEVEXTREME_DOCKER_CI=true
export NUGET_PACKAGES=$PWD/dotnet_packages
function run_lint {
npm i
npm run lint
}
function run_ts {
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list
apt-get update
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 apt-get install -y dotnet-sdk-3.1
target=./ts/dx.all.d.ts
cp $target $target.current
npm i
npm update devextreme-internal-tools
npm ls devextreme-internal-tools || :
npm run validate-declarations
npm run update-ts
if ! diff $target.current $target -U 5 > $target.diff; then
echo "FAIL: $target is outdated:"
cat $target.diff | sed "1,2d"
exit 1
else
echo "TS is up-to-date"
fi
npm run validate-ts
}
function run_test {
if [ "$GITHUBACTION" != "true" ]; then
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list
apt-get update
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 apt-get install -y dotnet-sdk-3.1
fi
export DEVEXTREME_TEST_CI=true
local port=`node -e "console.log(require('./ports.json').qunit)"`
local url="http://localhost:$port/run?notimers=true"
local runner_pid
local runner_result=0
[ "$LOCAL" == "true" ] && url="http://host.docker.internal:$port/run?notimers=true"
[ -n "$CONSTEL" ] && url="$url&constellation=$CONSTEL"
[ -n "$MOBILE_UA" ] && url="$url&deviceMode=true"
[ -z "$JQUERY" ] && url="$url&nojquery=true"
[ -n "$PERF" ] && url="$url&include=DevExpress.performance&workerInWindow=true"
[ "$NORENOVATION" == "true" ] && url="$url&norenovation=true"
if [ -n "$TZ" ]; then
ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
fi
if [ "$NO_HEADLESS" == "true" ]; then
Xvfb :99 -ac -screen 0 1200x600x24 &
x11vnc -display :99 2>/dev/null &
fi
if [ "$LOCAL" != "true" ]; then
if [ "$GITHUBACTION" != "true" ]; then
npm i
npm run build
fi
dotnet ./testing/runner/bin/runner.dll --single-run & runner_pid=$!
for i in {15..0}; do
if [ -n "$runner_pid" ] && [ ! -e "/proc/$runner_pid" ]; then
echo "Runner exited unexpectedly"
exit 1
fi
httping -qsc1 "$url" && break
if [ $i -eq 0 ]; then
echo "Runner not reached"
exit 1
fi
sleep 1
echo "Waiting for runner..."
done
fi
echo "URL: $url"
case "$BROWSER" in
"firefox")
local firefox_args="-profile /firefox-profile $url"
[ "$NO_HEADLESS" != "true" ] && firefox_args="-headless $firefox_args"
firefox --version
firefox $firefox_args &
;;
*)
local chrome_command=google-chrome-stable
local chrome_args=(
--no-sandbox
--disable-dev-shm-usage
--disable-gpu
--disable-extensions
--user-data-dir=/tmp/chrome
)
if [ "$NO_HEADLESS" != "true" ]; then
echo "Headless mode"
chrome_args+=(
--headless
--remote-debugging-address=0.0.0.0
--remote-debugging-port=9222
)
else
chrome_command="dbus-launch --exit-with-session $chrome_command"
chrome_args+=(
--no-first-run
--no-default-browser-check
--disable-translate
)
fi
if [ "$PERF" == "true" ]; then
echo "Performance tests"
chrome_args+=(
--disable-popup-blocking
--remote-debugging-port=9223
--enable-impl-side-painting
--enable-skia-benchmarking
--disable-web-security
)
fi
if [ -n "$MOBILE_UA" ]; then
local user_agent
if [ "$MOBILE_UA" == "ios9" ]; then
user_agent="Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1"
elif [ "$MOBILE_UA" == "android6" ]; then
user_agent="Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Mobile Safari/537.36"
else
exit 1
fi
echo "Mobile user agent: $MOBILE_UA"
chrome_args+=(
--user-agent="'$user_agent'"
--enable-viewport
--touch-events
--enable-overlay-scrollbar
--enable-features=OverlayScrollbar
)
fi
if [ "$GITHUBACTION" == "true" ]; then
echo "$chrome_command"
printf ' %s\n' "${chrome_args[@]}"
else
tput setaf 6
echo "$chrome_command"
printf ' %s\n' "${chrome_args[@]}"
tput setaf 9
fi
google-chrome-stable --version
eval "$chrome_command ${chrome_args[@]} '$url'" &>chrome.log &
;;
esac
start_runner_watchdog $runner_pid
wait $runner_pid || runner_result=1
exit $runner_result
}
function run_test_jest {
npm i
npx gulp localization
npm run test-jest
}
function run_test_styles {
npm i
npm run test-jest -- --config=./testing/styles/jest.config.json --coverage=false
}
function start_runner_watchdog {
local last_suite_time_file="$PWD/testing/LastSuiteTime.txt"
local last_suite_time=unknown
while true; do
sleep 300
if [ ! -f $last_suite_time_file ] || [ $(cat $last_suite_time_file) == $last_suite_time ]; then
echo "Runner stalled"
kill -9 $1
else
last_suite_time=$(cat $last_suite_time_file)
fi
done &
}
echo "node $(node -v), npm $(npm -v), dotnet $(dotnet --version)"
TARGET_FUNC="run_$TARGET"
if [ $(type -t $TARGET_FUNC) != "function" ]; then
echo "Unknown target"
exit 1
fi
$TARGET_FUNC