Skip to content

Instantly share code, notes, and snippets.

@sakatam
Created November 8, 2013 17:16
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sakatam/7374387 to your computer and use it in GitHub Desktop.
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
#!/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