-
Notifications
You must be signed in to change notification settings - Fork 514
CircleCI recipe
John Bachir edited this page Feb 18, 2026
·
2 revisions
Here's some slightly redacted code for what worked for me, hopefully all the interesting parts. came out of this issue
environment:
PARALLEL_TEST_PROCESSORS: "12"
...
- run:
name: setup parallel test databases
command: |
bundle exec rake parallel:create
bundle exec rake parallel:load_schema
- restore_cache:
keys:
- parallel-runtime-v1-
- attach_workspace:
at: workspace
...
- persist_to_workspace:
root: tmp
paths:
- parallel_runtime_rspec_*.log
...
aggregate-parallel-test-logs:
docker:
- image: cimg/base:current
steps:
- attach_workspace:
at: workspace
- run:
name: Combine runtime logs
command: cat workspace/parallel_runtime_rspec_*.log > workspace/parallel_runtime_rspec.log
- save_cache:
key: parallel-runtime-v1-{{ epoch }}
paths:
- workspace/parallel_runtime_rspec.log
- store_artifacts:
path: workspace/parallel_runtime_rspec.log
destination: parallel_runtime_rspec.log
if [[ -f workspace/parallel_runtime_rspec.log ]]; then
cp workspace/parallel_runtime_rspec.log tmp/parallel_runtime_rspec.log
else
echo "No runtime log found, using filesize splitting"
fi
TEST_FILES=$(circleci tests glob "spec/controllers/**/*_spec.rb" ......
cat > .rspec_parallel <<EOF
--format RspecJunitFormatter
--out /tmp/test-results/rspec_${CIRCLE_NODE_INDEX:?}_<%= ENV["TEST_ENV_NUMBER"] %>.xml
--format ParallelTests::RSpec::RuntimeLogger
--out tmp/parallel_runtime_rspec.log
EOF
RSPEC_COMMAND="bundle exec parallel_rspec \
-n ${PARALLEL_TEST_PROCESSORS:?}\
--runtime-log tmp/parallel_runtime_rspec.log"
echo "${TEST_FILES}" | circleci tests run --verbose --split-by=timings --command="xargs -I{} bash -c '${RSPEC_COMMAND} {}'"
rspec_status=$?
cp tmp/parallel_runtime_rspec.log tmp/parallel_runtime_rspec_"${CIRCLE_NODE_INDEX}".log
cp log/test*.log /tmp/test-results/
exit "${rspec_status}"
# database.yml
url: <%= ... %><%= ENV['TEST_ENV_NUMBER'] %>