Buildkite Rails Docker Parallel Example with Knapsack Pro
This repository is an example of how to easily run a large number of parallel testing agents for a Rails application using Buildkite, Docker and Knapsack Pro. This approach works well with Docker available autoscaling environments like the Buildkite AWS Stack.
This repository doesn't actually include a Rails sample application, but has the same CI scripts,
docker-compose.yml you would use for a production application. For a non-Docker based setup, see the Rails Parallel Example with Knapsack Pro.
Files to note:
- docker-compose.yml - sets up the app to be able to run via Buildkite’s Docker Compose support
- Dockerfile - setups up the entire Ruby environment, including a waiter script to help wait for Posgtres, Redis and Memcache to become available
- .buildkite/pipeline.yml - the pipeline config showing how to have parallel steps
- scripts/ci/parallel_specs.sh - runs the specs in parallel using knapsack_pro gem with Queue Mode. Tests are dynamically distributed across parallel jobs. Please read this article to learn more about environment variables configuration for Buildkite and Knapsack Pro.
How does it work?
In the pipeline configuration file the
parallelism property for the test step is set to 20. When a build, the step will appear 20 times in the pipeline, each with different environment variables exposed so you can divvy up your test suite accordingly. You can set the parallelism as high as you need to bring down your build times.
See the parallelizing builds guide for more information to create parallelized and distributed builds with Buildkite.
See the Containerized Builds with Docker guide for information on how to use Docker Compose with Buildkite pipelines.
Consult the Knapsack Pro documentation for configuring your database and dependent services to support running parallel steps on the one machine.
You can obtain API key for Knapsack Pro here.
See Licence.md (MIT)