Skip to content

Instantly share code, notes, and snippets.

@ArturT
Forked from sakatam/circleci-specs-in-parallel
Last active August 29, 2015 14:03
Show Gist options
  • Save ArturT/e45b41960fa30a9e5a4a to your computer and use it in GitHub Desktop.
Save ArturT/e45b41960fa30a9e5a4a to your computer and use it in GitHub Desktop.
#!/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|specify)" -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 --color --profile -- ${files[@]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment