Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test env teardown #216

Merged
merged 4 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/potassium/assets/bin/cibuild.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build(){
# Wait services to be ready
wait_services(){
function test_service {
docker-compose $DOCKER_COMPOSE_ARGS run test sh -c "nc -z $1 $2"
docker-compose $DOCKER_COMPOSE_ARGS run --rm test sh -c "nc -z $1 $2"
}

count=0
Expand All @@ -41,16 +41,16 @@ wait_services(){

# Prepare dependencies
dependencies(){
docker-compose $DOCKER_COMPOSE_ARGS run test bundle install
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle install
}

assets() {
docker-compose $DOCKER_COMPOSE_ARGS run test /bin/bash -c "bin/setup && bundle exec rake assets:precompile"
docker-compose $DOCKER_COMPOSE_ARGS run --rm test /bin/bash -c "bin/setup && bundle exec rake assets:precompile"
}

# Prepare database
database(){
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rake db:create db:schema:load
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle exec rake db:create db:schema:load
}

# Run the specs
Expand All @@ -59,7 +59,7 @@ tests(){
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter --format RspecJunitFormatter -o $HOME/.rspec_reports/junit.xml"
RSPEC_FORMAT_ARGS="--format progress --no-color"
}
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
}

# Run the complete ci build
Expand Down
4 changes: 0 additions & 4 deletions spec/features/database_container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
create_dummy_project("database" => database)
end

after do
`docker-compose -f #{project_path}/docker-compose.yml down`
end

[:postgresql, :mysql].each do |db_type|
context "when database is #{db_type}" do
let!(:database) { db_type }
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
create_tmp_directory
end

config.after(:each) do
docker_cleanup
end

config.before(:each) do
FakeGithub.clear!
FakeHeroku.clear!
Expand Down
4 changes: 4 additions & 0 deletions spec/support/potassium_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def on_project(&block)
end
end

def docker_cleanup
run_command(`docker-compose -f #{project_path}/docker-compose.yml down --volumes`)
end

private

def tmp_path
Expand Down