@@ -92,32 +92,24 @@ print_success() {
9292 echo ' Success!' >&2
9393}
9494
95- # Performs install tasks .
95+ # Runs benchmarks .
9696#
9797# $1 - log file
98- install () {
99- echo ' Installing ...' >&2
100- make install >> " $1 " 2>&1
98+ benchmark () {
99+ echo ' Running benchmarks ...' >&2
100+ make NODE_FLAGS= ' --no-deprecation ' benchmark >> " $1 " 2>&1
101101 if [[ " $? " -ne 0 ]]; then
102- echo ' Error occurred during install .' >&2
103- echo ' Retry 1 of 2 ...' >&2
102+ echo ' Benchmarks failed .' >&2
103+ echo ' Retry 1 of 1 ...' >&2
104104 sleep 15s
105- echo ' Installing ...' >&2
106- make install >> " $1 " 2>&1
105+ echo ' Running benchmarks ...' >&2
106+ make NODE_FLAGS= ' --no-deprecation ' benchmark >> " $1 " 2>&1
107107 if [[ " $? " -ne 0 ]]; then
108- echo ' Error occurred during install.' >&2
109- echo ' Retry 2 of 2...' >&2
110- sleep 30s
111- echo ' Installing...' >&2
112- make install >> " $1 " 2>&1
113- if [[ " $? " -ne 0 ]]; then
114- echo ' Error occurred during install.' >&2
115- echo ' Failed to install 3 times. Aborting install.' >&2
116- return 1
117- fi
108+ echo ' Benchmarks failed.' >&2
109+ return 1
118110 fi
119111 fi
120- echo ' Install successful .' >&2
112+ echo ' Successfully ran benchmarks .' >&2
121113 return 0
122114}
123115
@@ -149,12 +141,62 @@ check_licenses() {
149141 return 0
150142}
151143
144+ # Runs examples.
145+ #
146+ # $1 - log file
147+ examples () {
148+ echo ' Running examples...' >&2
149+ make NODE_FLAGS=' --no-deprecation' examples >> " $1 " 2>&1
150+ if [[ " $? " -ne 0 ]]; then
151+ echo ' Examples failed.' >&2
152+ echo ' Retry 1 of 1...' >&2
153+ sleep 15s
154+ echo ' Running examples...' >&2
155+ make NODE_FLAGS=' --no-deprecation' examples >> " $1 " 2>&1
156+ if [[ " $? " -ne 0 ]]; then
157+ echo ' Examples failed.' >&2
158+ return 1
159+ fi
160+ fi
161+ echo ' Successfully ran examples.' >&2
162+ return 0
163+ }
164+
165+ # Performs install tasks.
166+ #
167+ # $1 - log file
168+ install () {
169+ echo ' Installing...' >&2
170+ make install >> " $1 " 2>&1
171+ if [[ " $? " -ne 0 ]]; then
172+ echo ' Error occurred during install.' >&2
173+ echo ' Retry 1 of 2...' >&2
174+ sleep 15s
175+ echo ' Installing...' >&2
176+ make install >> " $1 " 2>&1
177+ if [[ " $? " -ne 0 ]]; then
178+ echo ' Error occurred during install.' >&2
179+ echo ' Retry 2 of 2...' >&2
180+ sleep 30s
181+ echo ' Installing...' >&2
182+ make install >> " $1 " 2>&1
183+ if [[ " $? " -ne 0 ]]; then
184+ echo ' Error occurred during install.' >&2
185+ echo ' Failed to install 3 times. Aborting install.' >&2
186+ return 1
187+ fi
188+ fi
189+ fi
190+ echo ' Install successful.' >&2
191+ return 0
192+ }
193+
152194# Performs lint tasks.
153195#
154196# $1 - log file
155197lint () {
156198 echo ' Initializing development environment...' >&2
157- make init
199+ make init >> " $1 " 2>&1
158200 if [[ " $? " -ne 0 ]]; then
159201 echo ' Linting failed as unable to initialize development environment.' >&2
160202 return 1
@@ -189,47 +231,10 @@ lint() {
189231 return 0
190232}
191233
192- # Tests whether the project successfully installs via `npm`.
193- #
194- # $1 - log file
195- test_npm_install () {
196- echo ' Testing npm install...' >&2
197- make test-npm-install >> " $1 " 2>&1
198- if [[ " $? " -ne 0 ]]; then
199- echo ' Installation failed.' >&2
200- echo ' Retry 1 of 1...' >&2
201- sleep 15s
202- echo ' Testing npm install...' >&2
203- make test-npm-install >> " $1 " 2>&1
204- if [[ " $? " -ne 0 ]]; then
205- echo ' Installation failed.' >&2
206- return 1
207- fi
208- fi
209- echo ' Successfully installed.' >&2
210-
211- echo ' Testing npm install (via GitHub)...' >&2
212- make test-npm-install-github >> " $1 " 2>&1
213- if [[ " $? " -ne 0 ]]; then
214- echo ' Installation (via GitHub) failed.' >&2
215- echo ' Retry 1 of 1...' >&2
216- sleep 15s
217- echo ' Testing npm install (via GitHub)...' >&2
218- make test-npm-install-github >> " $1 " 2>&1
219- if [[ " $? " -ne 0 ]]; then
220- echo ' Installation (via GitHub) failed.' >&2
221- return 1
222- fi
223- fi
224- echo ' Successfully installed (via GitHub).' >&2
225-
226- return 0
227- }
228-
229234# Runs unit tests.
230235#
231236# $1 - log file
232- run_tests () {
237+ tests () {
233238 echo ' Running tests...' >&2
234239 make NODE_FLAGS=' --no-deprecation' test >> " $1 " 2>&1
235240 if [[ " $? " -ne 0 ]]; then
@@ -250,7 +255,7 @@ run_tests() {
250255# Runs test coverage.
251256#
252257# $1 - log file
253- run_test_coverage () {
258+ test_coverage () {
254259 echo ' Running test coverage...' >&2
255260 make NODE_FLAGS=' --no-deprecation' test-cov >> " $1 " 2>&1
256261 if [[ " $? " -ne 0 ]]; then
@@ -268,11 +273,11 @@ run_test_coverage() {
268273 return 0
269274}
270275
271- # Sends test coverage to coverage service.
276+ # Sends test coverage report to coverage service.
272277#
273278# $1 - report title
274279# $2 - log file
275- send_coverage () {
280+ test_coverage_report () {
276281 echo ' Sending coverage report to coverage service...' >&2
277282 make COVERAGE_NAME=" $1 " coverage >> " $2 " 2>&1
278283 if [[ " $? " -ne 0 ]]; then
@@ -290,45 +295,40 @@ send_coverage() {
290295 return 0
291296}
292297
293- # Runs benchmarks .
298+ # Tests whether the project successfully installs via `npm` .
294299#
295300# $1 - log file
296- run_benchmarks () {
297- echo ' Running benchmarks ...' >&2
298- make NODE_FLAGS= ' --no-deprecation ' benchmark >> " $1 " 2>&1
301+ test_npm_install () {
302+ echo ' Testing npm install ...' >&2
303+ make test-npm-install >> " $1 " 2>&1
299304 if [[ " $? " -ne 0 ]]; then
300- echo ' Benchmarks failed.' >&2
305+ echo ' Installation failed.' >&2
301306 echo ' Retry 1 of 1...' >&2
302307 sleep 15s
303- echo ' Running benchmarks ...' >&2
304- make NODE_FLAGS= ' --no-deprecation ' benchmark >> " $1 " 2>&1
308+ echo ' Testing npm install ...' >&2
309+ make test-npm-install >> " $1 " 2>&1
305310 if [[ " $? " -ne 0 ]]; then
306- echo ' Benchmarks failed.' >&2
311+ echo ' Installation failed.' >&2
307312 return 1
308313 fi
309314 fi
310- echo ' Successfully ran benchmarks.' >&2
311- return 0
312- }
315+ echo ' Successfully installed.' >&2
313316
314- # Runs examples.
315- #
316- # $1 - log file
317- run_examples () {
318- echo ' Running examples...' >&2
319- make NODE_FLAGS=' --no-deprecation' examples >> " $1 " 2>&1
317+ echo ' Testing npm install (via GitHub)...' >&2
318+ make test-npm-install-github >> " $1 " 2>&1
320319 if [[ " $? " -ne 0 ]]; then
321- echo ' Examples failed.' >&2
320+ echo ' Installation (via GitHub) failed.' >&2
322321 echo ' Retry 1 of 1...' >&2
323322 sleep 15s
324- echo ' Running examples ...' >&2
325- make NODE_FLAGS= ' --no-deprecation ' examples >> " $1 " 2>&1
323+ echo ' Testing npm install (via GitHub) ...' >&2
324+ make test-npm-install-github >> " $1 " 2>&1
326325 if [[ " $? " -ne 0 ]]; then
327- echo ' Examples failed.' >&2
326+ echo ' Installation (via GitHub) failed.' >&2
328327 return 1
329328 fi
330329 fi
331- echo ' Successfully ran examples.' >&2
330+ echo ' Successfully installed (via GitHub).' >&2
331+
332332 return 0
333333}
334334
@@ -337,8 +337,10 @@ main() {
337337 start_heartbeat " ${heartbeat_interval} "
338338
339339 echo " Task: ${task} ." >&2
340- if [[ " ${task} " = " install" ]]; then
341- install " ${log_file} "
340+
341+ # Note: please keep tasks in alphabetical order...
342+ if [[ " ${task} " = " benchmark" ]]; then
343+ benchmark " ${log_file} "
342344 if [[ " $? " -ne 0 ]]; then
343345 on_error 1
344346 fi
@@ -352,37 +354,37 @@ main() {
352354 if [[ " $? " -ne 0 ]]; then
353355 on_error 1
354356 fi
355- elif [[ " ${task} " = " lint " ]]; then
356- lint " ${log_file} "
357+ elif [[ " ${task} " = " examples " ]]; then
358+ examples " ${log_file} "
357359 if [[ " $? " -ne 0 ]]; then
358360 on_error 1
359361 fi
360- elif [[ " ${task} " = " test-npm- install" ]]; then
361- test_npm_install " ${log_file} "
362+ elif [[ " ${task} " = " install" ]]; then
363+ install " ${log_file} "
362364 if [[ " $? " -ne 0 ]]; then
363365 on_error 1
364366 fi
365- elif [[ " ${task} " = " test " ]]; then
366- run_tests " ${log_file} "
367+ elif [[ " ${task} " = " lint " ]]; then
368+ lint " ${log_file} "
367369 if [[ " $? " -ne 0 ]]; then
368370 on_error 1
369371 fi
370- elif [[ " ${task} " = " benchmark " ]]; then
371- run_benchmarks " ${log_file} "
372+ elif [[ " ${task} " = " test " ]]; then
373+ tests " ${log_file} "
372374 if [[ " $? " -ne 0 ]]; then
373375 on_error 1
374376 fi
375- elif [[ " ${task} " = " examples " ]]; then
376- run_examples " ${log_file} "
377+ elif [[ " ${task} " = " test-coverage " ]]; then
378+ test_coverage " ${log_file} "
377379 if [[ " $? " -ne 0 ]]; then
378380 on_error 1
379381 fi
380- elif [[ " ${task} " = " test-coverage" ]]; then
381- run_test_coverage " ${log_file} "
382+ test_coverage_report " unit_test" " ${log_file} "
382383 if [[ " $? " -ne 0 ]]; then
383384 on_error 1
384385 fi
385- send_coverage " unit_test" " ${log_file} "
386+ elif [[ " ${task} " = " test-npm-install" ]]; then
387+ test_npm_install " ${log_file} "
386388 if [[ " $? " -ne 0 ]]; then
387389 on_error 1
388390 fi
0 commit comments