Skip to content

Commit 99ecd35

Browse files
author
Mattia Roccoberton
committed
Run specs on both PostgreSQL and MySQL
1 parent 1632e9a commit 99ecd35

2 files changed

Lines changed: 19 additions & 25 deletions

File tree

.circleci/config.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,14 @@ jobs:
77
docker:
88
- image: circleci/ruby:2.6.6-node
99
environment:
10-
DB_HOST: 127.0.0.1
11-
PGHOST: 127.0.0.1
12-
PGUSER: root
1310
RAILS_ENV: test
1411
- image: circleci/mysql:8.0.20
1512
command: [--default-authentication-plugin=mysql_native_password]
1613
environment:
17-
MYSQL_ALLOW_EMPTY_PASSWORD: yes
1814
MYSQL_ROOT_HOST: '%'
19-
MYSQL_ROOT_PASSWORD: ''
20-
MYSQL_DATABASE: circle-test_test
21-
MYSQL_USER: user
22-
MYSQL_PASSWORD: ''
2315
- image: circleci/postgres:9.6.15-alpine
2416
environment:
2517
POSTGRES_USER: root
26-
POSTGRES_DB: circle-test_test
2718
executor: ruby/default
2819
steps:
2920
- checkout
@@ -38,24 +29,24 @@ jobs:
3829
- save_cache:
3930
key: gem-cache-{{ checksum "active_storage_db.gemspec" }}
4031
paths: vendor/bundle
41-
# - run:
42-
# name: Run PostgreSQL Specs
43-
# command: |
44-
# DB=postgresql bin/rails db:reset
45-
# DB=postgresql bin/rspec \
46-
# --profile 10 \
47-
# --format RspecJunitFormatter \
48-
# --out test_results/rspec.xml \
49-
# --format progress \
50-
# $(circleci tests glob "spec/**/*_spec.rb")
32+
- run:
33+
name: Run PostgreSQL Specs
34+
command: |
35+
DB=postgresql bin/rails db:reset
36+
DB=postgresql bin/rspec \
37+
--profile 10 \
38+
--format RspecJunitFormatter \
39+
--out test_results/rspec_postgresql.xml \
40+
--format progress \
41+
$(circleci tests glob "spec/**/*_spec.rb")
5142
- run:
5243
name: Run MySQL Specs
5344
command: |
5445
DB=mysql bin/rails db:reset
5546
DB=mysql bin/rspec \
5647
--profile 10 \
5748
--format RspecJunitFormatter \
58-
--out test_results/rspec.xml \
49+
--out test_results/rspec_mysql.xml \
5950
--format progress \
6051
$(circleci tests glob "spec/**/*_spec.rb")
6152
- store_test_results:

spec/dummy/config/database.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
when 'mysql' %>
33
test:
44
adapter: mysql2
5-
host: <%= ENV.fetch('DB_HOST') { '127.0.0.1' } %>
6-
database: <%= ENV.fetch('DB_NAME') { 'active_storage_db_dummy_test' } %>
7-
username: <%= ENV.fetch('DB_USERNAME') { 'root' } %>
8-
password: <%= ENV.fetch('DB_PASSWORD') { '' } %>
5+
host: <%= ENV.fetch('MYSQL_DB_HOST') { '127.0.0.1' } %>
6+
database: <%= ENV.fetch('MYSQL_DB_NAME') { 'active_storage_db_dummy_test' } %>
7+
username: <%= ENV.fetch('MYSQL_DB_USERNAME') { 'root' } %>
8+
password: <%= ENV.fetch('MYSQL_DB_PASSWORD') { '' } %>
99
encoding: utf8
1010
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
1111
<% when 'postgres', 'postgresql' %>
1212
test:
1313
adapter: postgresql
14-
database: active_storage_db_dummy_test
14+
host: <%= ENV.fetch('PG_DB_HOST') { '127.0.0.1' } %>
15+
database: <%= ENV.fetch('PG_DB_NAME') { 'active_storage_db_dummy_test' } %>
16+
username: <%= ENV.fetch('PG_DB_USERNAME') { 'root' } %>
17+
password: <%= ENV.fetch('PG_DB_PASSWORD') { '' } %>
1518
encoding: utf8
1619
min_messages: warning
1720
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>

0 commit comments

Comments
 (0)