Created
November 8, 2013 17:16
-
-
Save sakatam/7374387 to your computer and use it in GitHub Desktop.
a circleci parallelism script optimized for rspec.this script is based on https://circleci.com/docs/parallel-manual-setup#balancing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
i=0 | |
files=() | |
# sort spec files by number of examples for better balancing | |
for file in $(find ./spec -name "*_spec.rb" -print0 | xargs -0 grep -e "^ *it" -c | sort -t: -k2,2rn | awk -F":" '{ print $1 }') | |
do | |
if [ $(($i % $CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ] | |
then | |
files+=" $file" | |
fi | |
((i++)) | |
done | |
echo "specs to be tested: ${files[@]}" | |
bundle exec rspec ${files[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment