Skip to content

Instantly share code, notes, and snippets.

@doitian
Last active March 3, 2019 15:02
Show Gist options
  • Save doitian/571338265428d5f6e2ad9739fe89d539 to your computer and use it in GitHub Desktop.
Save doitian/571338265428d5f6e2ad9739fe89d539 to your computer and use it in GitHub Desktop.
Gitlab CI to test Rails app
image: rails
services:
- redis
- $DB
cache:
key: bundle
paths:
- vendor/bundle
variables:
POSTGRES_DB: center_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: ""
MYSQL_DATABASE: center_test
MYSQL_ROOT_PASSWORD: root
before_script:
- cp config/database.ci-$DB.yml config/database.yml
- cp .ci.env .env
- bundle install --jobs $(nproc) --path=vendor/bundle
.test: &test_template
script:
- bundle exec rake db:create RAILS_ENV=test
- RAILS_ENV=test bundle exec rake db:reset
- bundle exec rake test
test_pg:
<<: *test_template
variables:
DB: postgres
test_mysql:
<<: *test_template
variables:
DB: mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment