@@ -80,6 +80,9 @@ commands:
8080 - gradle/collect_test_results :
8181 reports_path : pmd-cataloger/build/reports/
8282 test_results_path : pmd-cataloger/build/test-results/
83+ - gradle/collect_test_results :
84+ reports_path : sfge/build/reports/
85+ test_results_path : sfge/build/test-results/
8386 - store_test_results :
8487 path : test-results
8588 - store_artifacts : # upload nyc test coverage as artifact.
@@ -218,12 +221,21 @@ jobs:
218221
219222 # Purpose: Runs the unit tests in a Windows environment.
220223 windows-unit-tests :
224+ # `parallelism` indicates how many simultaneous executors should be run, allowing us to split
225+ # long-running tasks across multiple executors.
226+ parallelism : 4 # larger values didn't seem to affect performance greatly
221227 executor :
222228 name : win/default # executor type
223- size : " medium "
229+ size : " large "
224230 shell : bash.exe
225231 parameters :
226232 node-version : *node_version_param
233+ # Specify a subset of unit tests to be run, instead of the whole suite.
234+ # This allows us to work around the suboptimal performance of the Windows executor by running
235+ # multiple executors in parallel where different unit tests are ran in each.
236+ test-type :
237+ type : string
238+ default : all
227239 working_directory : C:\repo
228240 steps :
229241 - attach_workspace :
@@ -259,12 +271,90 @@ jobs:
259271 - run : mkdir test-results
260272
261273 # Unit tests
262- - run :
263- name : test
264- # Necessary to explicitly use bash, otherwise gradlew's status code won't be received and the job will hang.
265- shell : bash.exe
266- command : yarn test --reporter mocha-junit-reporter --reporter-option mochaFile=test-results/mocha/test-results.xml
267- when : always
274+ - when :
275+ condition :
276+ equal : [ all, << parameters.test-type >> ]
277+ steps :
278+ - run :
279+ name : test
280+ # Necessary to explicitly use bash, otherwise gradlew's status code won't be received and the job will hang.
281+ shell : bash.exe
282+ command : yarn test --reporter mocha-junit-reporter --reporter-option mochaFile=test-results/mocha/test-results.xml
283+ when : always
284+
285+ - when :
286+ condition :
287+ equal : [ sfge, << parameters.test-type >> ]
288+ steps :
289+ - run :
290+ name : test-sfge
291+ # Necessary to explicitly use bash, otherwise gradlew's status code won't be received and the job will hang.
292+ shell : bash.exe
293+ # Identify all the test files and allocate them between parallelized executors by timing data.
294+ # Then turn the array of tests into something that gradle can accept, and run the tests.
295+ command : |
296+ TESTGLOB=$(circleci tests glob "sfge/src/test/**/*Test.java" | circleci tests split --split-by=timings)
297+ echo $TESTGLOB
298+ TESTARRAY=($TESTGLOB)
299+ TESTARG=""
300+ for element in "${TESTARRAY[@]}"
301+ do
302+ TESTARG="$TESTARG --tests `basename $element .java`"
303+ done
304+ echo $TESTARG
305+ yarn test-sfge $TESTARG
306+ when : always
307+
308+ - when :
309+ condition :
310+ equal : [ cli-messaging, << parameters.test-type >> ]
311+ steps :
312+ - run :
313+ name : test-cli-messaging
314+ # Necessary to explicitly use bash, otherwise gradlew's status code won't be received and the job will hang.
315+ shell : bash.exe
316+ # This unit test suite is fast, so we have the first parallel executor run the tests, and all others exit early.
317+ command : |
318+ if [[ $CIRCLE_NODE_INDEX -gt 0 ]]
319+ then
320+ exit 0
321+ fi
322+ yarn test-cli-messaging
323+ when : always
324+
325+ - when :
326+ condition :
327+ equal : [ pmd-cataloger, << parameters.test-type >> ]
328+ steps :
329+ - run :
330+ name : test-pmd-cataloger
331+ # Necessary to explicitly use bash, otherwise gradlew's status code won't be received and the job will hang.
332+ shell : bash.exe
333+ # This unit test suite is fast, so we have the first parallel executor run the tests, and all others exit early.
334+ command : |
335+ if [[ $CIRCLE_NODE_INDEX -gt 0 ]]
336+ then
337+ exit 0
338+ fi
339+ yarn test-pmd-cataloger
340+ when : always
341+
342+ - when :
343+ condition :
344+ equal : [ ts, << parameters.test-type >> ]
345+ steps :
346+ - run :
347+ name : test-ts
348+ # Explicitly using bash, for simplicity of required shell script.
349+ shell : bash.exe
350+ # This unit test suite is relatively fast, so we have the first parallel executor run the tests, and all others exit early.
351+ command : |
352+ if [[ $CIRCLE_NODE_INDEX -gt 0 ]]
353+ then
354+ exit 0
355+ fi
356+ yarn test-ts --reporter mocha-junit-reporter --reporter-option mochaFile=test-results/mocha/test-results.xml
357+ when : always
268358
269359 # Linting
270360 - run :
@@ -510,6 +600,11 @@ workflows:
510600 << : *testing_filters
511601 requires :
512602 - setup
603+ matrix :
604+ parameters :
605+ # The values of the parameters will be appended to the jobs they create.
606+ # So we'll get "windows-unit-tests-pmd-cataloger", "windows-unit-tests-ts", etc.
607+ test-type : [pmd-cataloger, cli-messaging, ts, sfge]
513608 - linux-tarball-test :
514609 filters :
515610 << : *testing_filters
0 commit comments