Last active
March 3, 2019 15:02
-
-
Save doitian/571338265428d5f6e2ad9739fe89d539 to your computer and use it in GitHub Desktop.
Gitlab CI to test Rails app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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