@@ -106,79 +106,116 @@ print_success() {
106106 echo ' Success!' >&2
107107}
108108
109- # Runs unit tests .
109+ # Performs install tasks .
110110#
111111# $1 - log file
112112# $2 - number of log lines
113- run_tests () {
114- echo ' Running tests ...' >&2
115- make NODE_FLAGS= ' --no-deprecation ' test | tail -n " $2 " >> " $1 " 2>&1
113+ install () {
114+ echo ' Installing ...' >&2
115+ make install | tail -n " $2 " >> " $1 " 2>&1
116116 if [[ " $? " -ne 0 ]]; then
117- echo ' Tests failed.' >&2
118- return 1
117+ echo ' Error occurred during install.' >&2
118+ echo ' Retry 1 of 2...' >&2
119+ sleep 15s
120+ echo ' Installing...' >&2
121+ make install | tail -n " $2 " >> " $1 " 2>&1
122+ if [[ " $? " -ne 0 ]]; then
123+ echo ' Error occurred during install.' >&2
124+ echo ' Retry 2 of 2...' >&2
125+ sleep 30s
126+ echo ' Installing...' >&2
127+ make install | tail -n " $2 " >> " $1 " 2>&1
128+ if [[ " $? " -ne 0 ]]; then
129+ echo ' Error occurred during install.' >&2
130+ echo ' Failed to install 3 times. Aborting install.' >&2
131+ return 1
132+ fi
133+ fi
119134 fi
120- echo ' Tests passed .' >&2
135+ echo ' Install successful .' >&2
121136 return 0
122137}
123138
124- # Runs test coverage .
139+ # Performs development environment initialization tasks .
125140#
126141# $1 - log file
127142# $2 - number of log lines
128- run_test_coverage () {
129- echo ' Running test coverage ...' >&2
130- make NODE_FLAGS= ' --no-deprecation ' test-cov | tail -n " $2 " >> " $1 " 2>&1
143+ dev_init () {
144+ echo ' Initializing development environment ...' >&2
145+ make init | tail -n " $2 " >> " $1 " 2>&1
131146 if [[ " $? " -ne 0 ]]; then
132- echo ' Tests failed .' >&2
147+ echo ' Error occurred during initialization .' >&2
133148 return 1
134149 fi
135- echo ' Tests passed .' >&2
150+ echo ' Initialization successful .' >&2
136151 return 0
137152}
138153
139- # Sends test coverage to coverage service .
154+ # Checks dependencies .
140155#
141- # $1 - report title
142- # $2 - log file
143- # $3 - number of log lines
144- send_coverage () {
145- echo ' Sending coverage report to coverage service...' >&2
146- make COVERAGE_NAME=" $1 " coverage | tail -n " $3 " >> " $2 " 2>&1
156+ # $1 - log file
157+ # $2 - number of log lines
158+ check_deps () {
159+ echo ' Checking dependencies...' >&2
160+ make check-deps | tail -n " $2 " >> " $1 " 2>&1
147161 if [[ " $? " -ne 0 ]]; then
148- echo ' Sending coverage report to coverage service failed .' >&2
162+ echo ' Dependencies are out-of-date .' >&2
149163 return 1
150164 fi
151- echo ' Coverage report sent to coverage service .' >&2
165+ echo ' Dependencies are up-to-date .' >&2
152166 return 0
153167}
154168
155- # Runs benchmarks .
169+ # Checks licenses .
156170#
157171# $1 - log file
158172# $2 - number of log lines
159- run_benchmarks () {
160- echo ' Running benchmarks ...' >&2
161- make NODE_FLAGS= ' --no-deprecation ' benchmark | tail -n " $2 " >> " $1 " 2>&1
173+ check_licenses () {
174+ echo ' Checking licenses ...' >&2
175+ make check-licenses-production | tail -n " $2 " >> " $1 " 2>&1
162176 if [[ " $? " -ne 0 ]]; then
163- echo ' Benchmarks failed .' >&2
177+ echo ' Detected dependency licensing issues .' >&2
164178 return 1
165179 fi
166- echo ' Successfully ran benchmarks .' >&2
180+ echo ' No dependency licensing issues detected .' >&2
167181 return 0
168182}
169183
170- # Runs examples .
184+ # Performs lint tasks .
171185#
172186# $1 - log file
173187# $2 - number of log lines
174- run_examples () {
175- echo ' Running examples...' >&2
176- make NODE_FLAGS=' --no-deprecation' examples | tail -n " $2 " >> " $1 " 2>&1
188+ lint () {
189+ dev_init " $1 " " $2 "
177190 if [[ " $? " -ne 0 ]]; then
178- echo ' Examples failed.' >&2
191+ echo ' Linting failed as unable to initialize development environment .' >&2
179192 return 1
180193 fi
181- echo ' Successfully ran examples.' >&2
194+ echo ' Linting filenames...' >&2
195+ make lint-filenames | tail -n " $2 " >> " $1 " 2>&1
196+ if [[ " $? " -ne 0 ]]; then
197+ echo ' Linting filenames failed.' >&2
198+ return 1
199+ fi
200+ make lint-header-filenames | tail -n " $2 " >> " $1 " 2>&1
201+ if [[ " $? " -ne 0 ]]; then
202+ echo ' Linting filenames failed.' >&2
203+ return 1
204+ fi
205+ echo ' Linting package.json files...' >&2
206+ make lint-pkg-json | tail -n " $2 " >> " $1 " 2>&1
207+ if [[ " $? " -ne 0 ]]; then
208+ echo ' Linting package.json failed.' >&2
209+ return 1
210+ fi
211+ # FIXME: linting of Markdown files takes too long; need to speed-up via distributed tasks or only linting files which changed
212+ # echo 'Linting Markdown files...' >&2
213+ # make lint-markdown | tail -n "$2" >> "$1" 2>&1
214+ # if [[ "$?" -ne 0 ]]; then
215+ # echo 'Linting Markdown failed.' >&2
216+ # return 1
217+ # fi
218+ echo ' Linting passed.' >&2
182219 return 0
183220}
184221
@@ -191,33 +228,143 @@ test_npm_install() {
191228 make test-npm-install | tail -n " $2 " >> " $1 " 2>&1
192229 if [[ " $? " -ne 0 ]]; then
193230 echo ' Installation failed.' >&2
194- return 1
231+ echo ' Retry 1 of 1...' >&2
232+ sleep 15s
233+ echo ' Testing npm install...' >&2
234+ make test-npm-install | tail -n " $2 " >> " $1 " 2>&1
235+ if [[ " $? " -ne 0 ]]; then
236+ echo ' Installation failed.' >&2
237+ return 1
238+ fi
195239 fi
196240 echo ' Successfully installed.' >&2
197241
198242 echo ' Testing npm install (via GitHub)...' >&2
199243 make test-npm-install-github | tail -n " $2 " >> " $1 " 2>&1
200244 if [[ " $? " -ne 0 ]]; then
201245 echo ' Installation (via GitHub) failed.' >&2
202- return 1
246+ echo ' Retry 1 of 1...' >&2
247+ sleep 15s
248+ echo ' Testing npm install (via GitHub)...' >&2
249+ make test-npm-install-github | tail -n " $2 " >> " $1 " 2>&1
250+ if [[ " $? " -ne 0 ]]; then
251+ echo ' Installation (via GitHub) failed.' >&2
252+ return 1
253+ fi
203254 fi
204255 echo ' Successfully installed (via GitHub).' >&2
205256
206257 return 0
207258}
208259
209- # Checks dependencies .
260+ # Runs unit tests .
210261#
211262# $1 - log file
212263# $2 - number of log lines
213- check_deps () {
214- echo ' Checking dependencies ...' >&2
215- make check-deps | tail -n " $2 " >> " $1 " 2>&1
264+ run_tests () {
265+ echo ' Running tests ...' >&2
266+ make NODE_FLAGS= ' --no-deprecation ' test | tail -n " $2 " >> " $1 " 2>&1
216267 if [[ " $? " -ne 0 ]]; then
217- echo ' Dependencies are out-of-date.' >&2
218- return 1
268+ echo ' Tests failed.' >&2
269+ echo ' Retry 1 of 1...' >&2
270+ sleep 15s
271+ echo ' Running tests...' >&2
272+ make NODE_FLAGS=' --no-deprecation' test | tail -n " $2 " >> " $1 " 2>&1
273+ if [[ " $? " -ne 0 ]]; then
274+ echo ' Tests failed.' >&2
275+ return 1
276+ fi
219277 fi
220- echo ' Dependencies are up-to-date.' >&2
278+ echo ' Tests passed.' >&2
279+ return 0
280+ }
281+
282+ # Runs test coverage.
283+ #
284+ # $1 - log file
285+ # $2 - number of log lines
286+ run_test_coverage () {
287+ echo ' Running test coverage...' >&2
288+ make NODE_FLAGS=' --no-deprecation' test-cov | tail -n " $2 " >> " $1 " 2>&1
289+ if [[ " $? " -ne 0 ]]; then
290+ echo ' Tests failed.' >&2
291+ echo ' Retry 1 of 1...' >&2
292+ sleep 15s
293+ echo ' Running test coverage...' >&2
294+ make NODE_FLAGS=' --no-deprecation' test-cov | tail -n " $2 " >> " $1 " 2>&1
295+ if [[ " $? " -ne 0 ]]; then
296+ echo ' Tests failed.' >&2
297+ return 1
298+ fi
299+ fi
300+ echo ' Tests passed.' >&2
301+ return 0
302+ }
303+
304+ # Sends test coverage to coverage service.
305+ #
306+ # $1 - report title
307+ # $2 - log file
308+ # $3 - number of log lines
309+ send_coverage () {
310+ echo ' Sending coverage report to coverage service...' >&2
311+ make COVERAGE_NAME=" $1 " coverage | tail -n " $3 " >> " $2 " 2>&1
312+ if [[ " $? " -ne 0 ]]; then
313+ echo ' Sending coverage report to coverage service failed.' >&2
314+ echo ' Retry 1 of 1...' >&2
315+ sleep 15s
316+ echo ' Sending coverage report to coverage service...' >&2
317+ make COVERAGE_NAME=" $1 " coverage | tail -n " $3 " >> " $2 " 2>&1
318+ if [[ " $? " -ne 0 ]]; then
319+ echo ' Sending coverage report to coverage service failed.' >&2
320+ return 1
321+ fi
322+ fi
323+ echo ' Coverage report sent to coverage service.' >&2
324+ return 0
325+ }
326+
327+ # Runs benchmarks.
328+ #
329+ # $1 - log file
330+ # $2 - number of log lines
331+ run_benchmarks () {
332+ echo ' Running benchmarks...' >&2
333+ make NODE_FLAGS=' --no-deprecation' benchmark | tail -n " $2 " >> " $1 " 2>&1
334+ if [[ " $? " -ne 0 ]]; then
335+ echo ' Benchmarks failed.' >&2
336+ echo ' Retry 1 of 1...' >&2
337+ sleep 15s
338+ echo ' Running benchmarks...' >&2
339+ make NODE_FLAGS=' --no-deprecation' benchmark | tail -n " $2 " >> " $1 " 2>&1
340+ if [[ " $? " -ne 0 ]]; then
341+ echo ' Benchmarks failed.' >&2
342+ return 1
343+ fi
344+ fi
345+ echo ' Successfully ran benchmarks.' >&2
346+ return 0
347+ }
348+
349+ # Runs examples.
350+ #
351+ # $1 - log file
352+ # $2 - number of log lines
353+ run_examples () {
354+ echo ' Running examples...' >&2
355+ make NODE_FLAGS=' --no-deprecation' examples | tail -n " $2 " >> " $1 " 2>&1
356+ if [[ " $? " -ne 0 ]]; then
357+ echo ' Examples failed.' >&2
358+ echo ' Retry 1 of 1...' >&2
359+ sleep 15s
360+ echo ' Running examples...' >&2
361+ make NODE_FLAGS=' --no-deprecation' examples | tail -n " $2 " >> " $1 " 2>&1
362+ if [[ " $? " -ne 0 ]]; then
363+ echo ' Examples failed.' >&2
364+ return 1
365+ fi
366+ fi
367+ echo ' Successfully ran examples.' >&2
221368 return 0
222369}
223370
@@ -227,7 +374,27 @@ main() {
227374 start_heartbeat " ${heartbeat_interval} "
228375
229376 echo " Task: ${task} ." >&2
230- if [[ " ${task} " = " test-npm-install" ]]; then
377+ if [[ " ${task} " = " install" ]]; then
378+ install " ${log_file} " " ${log_num_lines} "
379+ if [[ " $? " -ne 0 ]]; then
380+ on_error 1
381+ fi
382+ elif [[ " ${task} " = " check_deps" ]]; then
383+ check_deps " ${log_file} " " ${log_num_lines} "
384+ if [[ " $? " -ne 0 ]]; then
385+ on_error 1
386+ fi
387+ elif [[ " ${task} " = " check_licenses" ]]; then
388+ check_licenses " ${log_file} " " ${log_num_lines} "
389+ if [[ " $? " -ne 0 ]]; then
390+ on_error 1
391+ fi
392+ elif [[ " ${task} " = " lint" ]]; then
393+ lint " ${log_file} " " ${log_num_lines} "
394+ if [[ " $? " -ne 0 ]]; then
395+ on_error 1
396+ fi
397+ elif [[ " ${task} " = " test-npm-install" ]]; then
231398 test_npm_install " ${log_file} " " ${log_num_lines} "
232399 if [[ " $? " -ne 0 ]]; then
233400 on_error 1
@@ -256,11 +423,6 @@ main() {
256423 if [[ " $? " -ne 0 ]]; then
257424 on_error 1
258425 fi
259- elif [[ " ${task} " = " check-deps" ]]; then
260- check_deps " ${log_file} " " ${log_num_lines} "
261- if [[ " $? " -ne 0 ]]; then
262- on_error 1
263- fi
264426 else
265427 echo " ERROR: unknown task: ${task} ." >&2
266428 on_error 1
0 commit comments