Skip to content

Commit 1632e9a

Browse files
author
Mattia Roccoberton
committed
Add MySQL test config
1 parent e667186 commit 1632e9a

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

.circleci/config.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ jobs:
77
docker:
88
- image: circleci/ruby:2.6.6-node
99
environment:
10-
RAILS_ENV: test
10+
DB_HOST: 127.0.0.1
1111
PGHOST: 127.0.0.1
1212
PGUSER: root
13+
RAILS_ENV: test
14+
- image: circleci/mysql:8.0.20
15+
command: [--default-authentication-plugin=mysql_native_password]
16+
environment:
17+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
18+
MYSQL_ROOT_HOST: '%'
19+
MYSQL_ROOT_PASSWORD: ''
20+
MYSQL_DATABASE: circle-test_test
21+
MYSQL_USER: user
22+
MYSQL_PASSWORD: ''
1323
- image: circleci/postgres:9.6.15-alpine
1424
environment:
1525
POSTGRES_USER: root
@@ -28,14 +38,21 @@ jobs:
2838
- save_cache:
2939
key: gem-cache-{{ checksum "active_storage_db.gemspec" }}
3040
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")
3151
- run:
32-
name: PostgreSQL DB Setup
33-
command: |
34-
DB=postgresql bin/rails db:reset
35-
- run:
36-
name: Run PostgreSQL Specs
52+
name: Run MySQL Specs
3753
command: |
38-
DB=postgresql bin/rspec \
54+
DB=mysql bin/rails db:reset
55+
DB=mysql bin/rspec \
3956
--profile 10 \
4057
--format RspecJunitFormatter \
4158
--out test_results/rspec.xml \

spec/dummy/config/database.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
when 'mysql' %>
33
test:
44
adapter: mysql2
5-
database: active_storage_db_dummy_test
6-
username: root
7-
password:
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') { '' } %>
89
encoding: utf8
9-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10+
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
1011
<% when 'postgres', 'postgresql' %>
1112
test:
1213
adapter: postgresql
1314
database: active_storage_db_dummy_test
1415
encoding: utf8
1516
min_messages: warning
16-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
17+
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
1718
<% else %>
1819
<% raise "Invalid or empty env DB #{ENV['DB']}" %>
1920
<% end %>

0 commit comments

Comments
 (0)