Skip to content

Instantly share code, notes, and snippets.

@gorzell
Last active May 4, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gorzell/36eda085ebf3e5d72e475fd98c018ebd to your computer and use it in GitHub Desktop.
Save gorzell/36eda085ebf3e5d72e475fd98c018ebd to your computer and use it in GitHub Desktop.
Circle 2.0 Integration Tests With Docker Compose
docker:
- image: keen/build-scala:master
# Setup docker now that we need it.
- setup_remote_docker
- run:
name: Dockerhub login
command: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
# Setup and run integration tests.
- run:
name: Start integration envrionment.
command: make compose-it
- run:
name: Integration tests
command: make it-ci
- store_test_results:
path: target/it/test-reports/
compose-it: #: Compose dependencies for integration tests.
docker-compose -f docker-compose.yaml up -d
# Give the services a chance to start up.
sleep 45
it: #: Run integration tests
sbt ci:test
it-ci: #: Setup up and run integration tests in ci.
docker create --name it \
# Run on the compose network.
--network dependencies_default \
# Link to the containers you depend on.
--link api1 \
--link api2 \
# Pass required environment variables.
-e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
# Change working directory
-w /build \
# Use the same build image we are using for the parent.
keen/build-scala:master \
# Run the integration tests.
make it
# Copy the entire build context into the container.
docker cp . it:/build
# Copy the caches from the parent since we already did a compile and unit tests.
docker cp ~/.sbt it:/root
docker cp ~/.ivy2 it:/root
# Now that everything is configured and copied, execute the container.
docker start -a it
# Copy out the test results.
docker cp it:/build/target/test-reports target/it/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment