Skip to content

Commit 9a71d01

Browse files
authored
Merge pull request #1 from blocknotes/circleci-project-setup
Circleci project setup
2 parents 12a41c4 + 99ecd35 commit 9a71d01

6 files changed

Lines changed: 159 additions & 6 deletions

File tree

.circleci/config.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
version: 2.1
2+
orbs:
3+
ruby: circleci/ruby@0.1.2
4+
5+
jobs:
6+
build:
7+
docker:
8+
- image: circleci/ruby:2.6.6-node
9+
environment:
10+
RAILS_ENV: test
11+
- image: circleci/mysql:8.0.20
12+
command: [--default-authentication-plugin=mysql_native_password]
13+
environment:
14+
MYSQL_ROOT_HOST: '%'
15+
- image: circleci/postgres:9.6.15-alpine
16+
environment:
17+
POSTGRES_USER: root
18+
executor: ruby/default
19+
steps:
20+
- checkout
21+
- restore_cache:
22+
key: gem-cache-{{ checksum "active_storage_db.gemspec" }}
23+
- run:
24+
name: Setup Bundler
25+
command: gem install bundler
26+
- run:
27+
name: Bundle Install
28+
command: bundle install --path vendor/bundle
29+
- save_cache:
30+
key: gem-cache-{{ checksum "active_storage_db.gemspec" }}
31+
paths: vendor/bundle
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")
42+
- run:
43+
name: Run MySQL Specs
44+
command: |
45+
DB=mysql bin/rails db:reset
46+
DB=mysql bin/rspec \
47+
--profile 10 \
48+
--format RspecJunitFormatter \
49+
--out test_results/rspec_mysql.xml \
50+
--format progress \
51+
$(circleci tests glob "spec/**/*_spec.rb")
52+
- store_test_results:
53+
path: test_results
54+
55+
triggers:
56+
- schedule:
57+
cron: "0 8 * * 0"
58+
filters:
59+
branches:
60+
only:
61+
- master

active_storage_db.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
3636
spec.add_development_dependency 'mysql2', '~> 0.5.3'
3737
spec.add_development_dependency 'pg', '~> 1.2.3'
3838
spec.add_development_dependency 'pry', '~> 0.13.1'
39+
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
3940
spec.add_development_dependency 'rspec-rails', '~> 4.0.1'
4041
spec.add_development_dependency 'rubocop', '~> 0.89.0'
4142
spec.add_development_dependency 'selenium-webdriver', '~> 3.142.7'

bin/rake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rake' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("rake", "rake")

bin/rspec

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rspec' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("rspec-core", "rspec")

bin/rubocop

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rubocop' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "pathname"
12+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13+
Pathname.new(__FILE__).realpath)
14+
15+
bundle_binstub = File.expand_path("../bundle", __FILE__)
16+
17+
if File.file?(bundle_binstub)
18+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19+
load(bundle_binstub)
20+
else
21+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23+
end
24+
end
25+
26+
require "rubygems"
27+
require "bundler/setup"
28+
29+
load Gem.bin_path("rubocop", "rubocop")

spec/dummy/config/database.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
when 'mysql' %>
33
test:
44
adapter: mysql2
5-
database: active_storage_db_dummy_test
6-
username: root
7-
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') { '' } %>
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
13-
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') { '' } %>
1418
encoding: utf8
1519
min_messages: warning
16-
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
20+
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
1721
<% else %>
1822
<% raise "Invalid or empty env DB #{ENV['DB']}" %>
1923
<% end %>

0 commit comments

Comments
 (0)