Skip to content

Instantly share code, notes, and snippets.

@adamrneary
Created April 5, 2016 03:18
Show Gist options
  • Save adamrneary/5d11a49be3416f1450c082f20b416978 to your computer and use it in GitHub Desktop.
Save adamrneary/5d11a49be3416f1450c082f20b416978 to your computer and use it in GitHub Desktop.
#!/bin/bash -x
if [ $CIRCLE_NODE_TOTAL -gt 1 ]
then
echo $CIRCLE_NODE_TOTAL 'Circle CI nodes. Running tests in parallel.'
echo 'This is Circle CI node' $CIRCLE_NODE_INDEX'.'
# First worker should just run unit tests
if [ $CIRCLE_NODE_INDEX -eq 0 ]
then
# ESLint
./node_modules/eslint/bin/eslint.js src/
if [ $? -gt 0 ] ; then exit 1; fi
# Mocha (TODO)
# mocha
# if [ $? -gt 0 ] ; then exit 1; fi
fi
# Other workers should divy up the integration tests
if [ $CIRCLE_NODE_INDEX -gt 0 ]
then
./script/wait-for-dependencies.sh
i=0
for testfile in $(find ./integrationTests/tests -name "*.js" | sort); do
if [ $(expr $i % $(expr $CIRCLE_NODE_TOTAL - 1)) -eq $(expr $CIRCLE_NODE_INDEX - 1) ]
then
echo ${testfile}
nightwatch --env localChrome --test ${testfile}
if [ $? -gt 0 ] ; then exit 1; fi
fi
((i=i+1))
done
fi
fi
if [ $CIRCLE_NODE_TOTAL -eq 1 ]
then
echo $CIRCLE_NODE_TOTAL 'Circle CI nodes. Running tests in series.'
./node_modules/eslint/bin/eslint.js src/
if [ $? -gt 0 ] ; then exit 1; fi
./script/wait-for-dependencies.sh
nightwatch --env localChrome
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment