mirror of
https://github.com/internetee/registry.git
synced 2025-05-29 17:10:08 +02:00
Merge branch 'master' into remove-robot-bin
# Conflicts: # bin/robot
This commit is contained in:
commit
8bcd0614ee
8 changed files with 47 additions and 1302 deletions
|
@ -1,4 +1,5 @@
|
||||||
language: ruby
|
language: ruby
|
||||||
|
cache: bundler
|
||||||
env:
|
env:
|
||||||
- DB=postgresql
|
- DB=postgresql
|
||||||
bundler_args: --without development staging production
|
bundler_args: --without development staging production
|
||||||
|
@ -9,9 +10,7 @@ before_script:
|
||||||
- "cp config/application-example.yml config/application.yml"
|
- "cp config/application-example.yml config/application.yml"
|
||||||
- "cp config/secrets-example.yml config/secrets.yml"
|
- "cp config/secrets-example.yml config/secrets.yml"
|
||||||
- "cp config/database-travis.yml config/database.yml"
|
- "cp config/database-travis.yml config/database.yml"
|
||||||
- "RAILS_ENV=test bundle exec rake db:all:create"
|
- "RAILS_ENV=test bundle exec rake db:setup:all"
|
||||||
- "RAILS_ENV=test bundle exec rake db:all:schema:load"
|
|
||||||
- "RAILS_ENV=test bundle exec rake db:migrate"
|
|
||||||
script:
|
script:
|
||||||
- "RAILS_ENV=test bundle exec rspec"
|
- "RAILS_ENV=test bundle exec rspec"
|
||||||
after_success:
|
after_success:
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -139,8 +139,6 @@ group :development, :test do
|
||||||
# debug
|
# debug
|
||||||
gem 'pry', '0.10.1'
|
gem 'pry', '0.10.1'
|
||||||
|
|
||||||
# code review
|
|
||||||
gem 'rubycritic', '3.2.0'
|
|
||||||
gem 'bullet', '4.14.7' # for finding database optimizations
|
gem 'bullet', '4.14.7' # for finding database optimizations
|
||||||
gem 'bundler-audit'
|
gem 'bundler-audit'
|
||||||
gem 'brakeman', '3.6.1', require: false # for security audit'
|
gem 'brakeman', '3.6.1', require: false # for security audit'
|
||||||
|
|
28
Gemfile.lock
28
Gemfile.lock
|
@ -141,8 +141,6 @@ GEM
|
||||||
xpath (~> 2.0)
|
xpath (~> 2.0)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
cliver (0.3.2)
|
cliver (0.3.2)
|
||||||
codeclimate-engine-rb (0.4.0)
|
|
||||||
virtus (~> 1.0)
|
|
||||||
codeclimate-test-reporter (1.0.8)
|
codeclimate-test-reporter (1.0.8)
|
||||||
simplecov (<= 0.13)
|
simplecov (<= 0.13)
|
||||||
coderay (1.1.0)
|
coderay (1.1.0)
|
||||||
|
@ -195,15 +193,6 @@ GEM
|
||||||
ffi (1.9.18)
|
ffi (1.9.18)
|
||||||
figaro (1.1.1)
|
figaro (1.1.1)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
flay (2.8.1)
|
|
||||||
erubis (~> 2.7.0)
|
|
||||||
path_expander (~> 1.0)
|
|
||||||
ruby_parser (~> 3.0)
|
|
||||||
sexp_processor (~> 4.0)
|
|
||||||
flog (4.6.1)
|
|
||||||
path_expander (~> 1.0)
|
|
||||||
ruby_parser (~> 3.1, > 3.1.0)
|
|
||||||
sexp_processor (~> 4.8)
|
|
||||||
formatador (0.2.5)
|
formatador (0.2.5)
|
||||||
globalid (0.3.7)
|
globalid (0.3.7)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
|
@ -297,7 +286,7 @@ GEM
|
||||||
loofah (2.0.3)
|
loofah (2.0.3)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
lumberjack (1.0.11)
|
lumberjack (1.0.11)
|
||||||
mail (2.6.4)
|
mail (2.6.5)
|
||||||
mime-types (>= 1.16, < 4)
|
mime-types (>= 1.16, < 4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (3.1)
|
mime-types (3.1)
|
||||||
|
@ -333,7 +322,6 @@ GEM
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
parser (2.4.0.0)
|
parser (2.4.0.0)
|
||||||
ast (~> 2.2)
|
ast (~> 2.2)
|
||||||
path_expander (1.0.1)
|
|
||||||
pdfkit (0.6.2)
|
pdfkit (0.6.2)
|
||||||
pg (0.19.0)
|
pg (0.19.0)
|
||||||
phantomjs (1.9.8.0)
|
phantomjs (1.9.8.0)
|
||||||
|
@ -405,10 +393,6 @@ GEM
|
||||||
rb-inotify (0.9.8)
|
rb-inotify (0.9.8)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
rdoc (4.3.0)
|
rdoc (4.3.0)
|
||||||
reek (4.6.1)
|
|
||||||
codeclimate-engine-rb (~> 0.4.0)
|
|
||||||
parser (>= 2.3.1.2, < 2.5)
|
|
||||||
rainbow (~> 2.0)
|
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
request_store (1.1.0)
|
request_store (1.1.0)
|
||||||
responders (2.3.0)
|
responders (2.3.0)
|
||||||
|
@ -448,15 +432,6 @@ GEM
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
ruby_parser (3.8.4)
|
ruby_parser (3.8.4)
|
||||||
sexp_processor (~> 4.1)
|
sexp_processor (~> 4.1)
|
||||||
rubycritic (3.2.0)
|
|
||||||
flay (~> 2.8)
|
|
||||||
flog (~> 4.4)
|
|
||||||
launchy (= 2.4.3)
|
|
||||||
parser (= 2.4.0)
|
|
||||||
rainbow (~> 2.1)
|
|
||||||
reek (~> 4.4)
|
|
||||||
ruby_parser (~> 3.8)
|
|
||||||
virtus (~> 1.0)
|
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sass (3.4.23)
|
sass (3.4.23)
|
||||||
sass-rails (5.0.6)
|
sass-rails (5.0.6)
|
||||||
|
@ -620,7 +595,6 @@ DEPENDENCIES
|
||||||
rest-client
|
rest-client
|
||||||
rspec-rails (~> 3.5)
|
rspec-rails (~> 3.5)
|
||||||
rubocop (= 0.48.1)
|
rubocop (= 0.48.1)
|
||||||
rubycritic (= 3.2.0)
|
|
||||||
sass-rails (= 5.0.6)
|
sass-rails (= 5.0.6)
|
||||||
sdoc (= 0.4.1)
|
sdoc (= 0.4.1)
|
||||||
select2-rails (= 3.5.9.3)
|
select2-rails (= 3.5.9.3)
|
||||||
|
|
|
@ -44,7 +44,7 @@ Manual demo install and database setup:
|
||||||
bundle
|
bundle
|
||||||
cp config/application-example.yml config/application.yml # and edit it
|
cp config/application-example.yml config/application.yml # and edit it
|
||||||
cp config/database-example.yml config/database.yml # and edit it
|
cp config/database-example.yml config/database.yml # and edit it
|
||||||
bundle exec rake db:all:setup # for production, please follow deployment howto
|
bundle exec rake db:setup:all # for production, please follow deployment howto
|
||||||
bundle exec rake assets:precompile
|
bundle exec rake assets:precompile
|
||||||
|
|
||||||
### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS)
|
### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS)
|
||||||
|
|
14
config/puma.rb
Normal file
14
config/puma.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
preload_app!
|
||||||
|
|
||||||
|
threads 1, 4
|
||||||
|
workers 2
|
||||||
|
|
||||||
|
on_worker_boot do
|
||||||
|
ActiveSupport.on_load(:active_record) do
|
||||||
|
ActiveRecord::Base.establish_connection
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before_fork do
|
||||||
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
end
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ Testing
|
||||||
|
|
||||||
Setup test databases:
|
Setup test databases:
|
||||||
|
|
||||||
RAILS_ENV=test rake db:all:setup
|
RAILS_ENV=test rake db:setup:all
|
||||||
|
|
||||||
Run basic test (no EPP tests):
|
Run basic test (no EPP tests):
|
||||||
|
|
||||||
|
|
|
@ -1,57 +1,10 @@
|
||||||
Rake::Task["db:schema:load"].clear
|
|
||||||
|
|
||||||
Rake::Task["db:migrate"].enhance do
|
|
||||||
if ActiveRecord::Base.schema_format == :sql
|
|
||||||
Rake::Task["db:schema:dump"].invoke
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake::Task["db:rollback"].enhance do
|
|
||||||
if ActiveRecord::Base.schema_format == :sql
|
|
||||||
Rake::Task["db:schema:dump"].invoke
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Rake::Task["db:schema:dump"].enhance do
|
|
||||||
if ActiveRecord::Base.schema_format == :sql
|
|
||||||
File.rename('db/schema.rb', 'db/schema-read-only.rb')
|
|
||||||
Rake::Task["db:structure:dump"].invoke # for users who do manually db:schema:dump
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :db do
|
namespace :db do
|
||||||
namespace :schema do
|
namespace :setup do
|
||||||
task load: [:environment, :load_config] do
|
desc 'Create all databases: api_log and whois'
|
||||||
puts 'Only rake db:structure:load is supported and invoked. ' \
|
task all: [:environment, :load_config] do
|
||||||
'Otherwise zonefile generation does not work nor que.'
|
Rake::Task['db:create:all'].invoke
|
||||||
Rake::Task["db:structure:load"].invoke
|
Rake::Task['db:structure:load'].invoke
|
||||||
end
|
Rake::Task['db:schema:load:all'].invoke
|
||||||
end
|
|
||||||
|
|
||||||
def databases
|
|
||||||
@db ||= [Rails.env, "api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def other_databases
|
|
||||||
@other_dbs ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def schema_file(db)
|
|
||||||
case db
|
|
||||||
when Rails.env
|
|
||||||
'structure.sql' # just in case
|
|
||||||
when "api_log_#{Rails.env}"
|
|
||||||
'api_log_schema.rb'
|
|
||||||
when "whois_#{Rails.env}"
|
|
||||||
'whois_schema.rb'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :all do
|
|
||||||
desc 'Create all databases: registry, api_log and whois'
|
|
||||||
task setup: [:environment, :load_config] do
|
|
||||||
Rake::Task['db:all:create'].invoke
|
|
||||||
Rake::Task['db:all:schema:load'].invoke
|
|
||||||
|
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
||||||
|
@ -60,81 +13,49 @@ namespace :db do
|
||||||
Rake::Task['db:seed'].invoke
|
Rake::Task['db:seed'].invoke
|
||||||
puts "\n All done!\n\n"
|
puts "\n All done!\n\n"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Create all databases: registry, api_log and whois'
|
namespace :schema do
|
||||||
task create: [:environment, :load_config] do
|
def other_databases
|
||||||
databases.each do |name|
|
@other_dbs ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||||
begin
|
end
|
||||||
puts "\n------------------------ Create #{name} ---------------------------------------\n"
|
|
||||||
ActiveRecord::Base.clear_all_connections!
|
def schema_file(db)
|
||||||
conf = ActiveRecord::Base.configurations
|
case db
|
||||||
|
when "api_log_#{Rails.env}"
|
||||||
if name == Rails.env
|
'api_log_schema.rb'
|
||||||
ActiveRecord::Tasks::DatabaseTasks.create_current
|
when "whois_#{Rails.env}"
|
||||||
else
|
'whois_schema.rb'
|
||||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
puts "\n#{e}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Drop all databaseses: registry, api_log and whois'
|
namespace :load do
|
||||||
task drop: [:environment, :load_config] do
|
desc 'Schema load for all databases: api_log and whois'
|
||||||
# just in case we allow only drop test, comment it out only for temp
|
task all: [:environment, :load_config] do
|
||||||
return unless Rails.env.test?
|
|
||||||
|
|
||||||
databases.each do |name|
|
|
||||||
begin
|
|
||||||
ActiveRecord::Base.clear_all_connections!
|
|
||||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
|
||||||
|
|
||||||
conf = ActiveRecord::Base.configurations
|
|
||||||
if ActiveRecord::Tasks::DatabaseTasks.drop(conf[name])
|
|
||||||
puts "#{conf[name]['database']} dropped"
|
|
||||||
else
|
|
||||||
puts "Didn't find database #{name}, no drop"
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
puts "\n#{e}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :schema do
|
|
||||||
desc 'Schema load for all databases: registry, api_log and whois'
|
|
||||||
task load: [:environment, :load_config] do
|
|
||||||
puts "\n------------------------ #{Rails.env} structure loading -----------------------------\n"
|
|
||||||
Rake::Task['db:structure:load'].invoke
|
|
||||||
|
|
||||||
other_databases.each do |name|
|
other_databases.each do |name|
|
||||||
begin
|
begin
|
||||||
puts "\n------------------------ #{name} schema loading -----------------------------\n"
|
puts "\n------------------------ #{name} schema loading -----------------------------\n"
|
||||||
ActiveRecord::Base.clear_all_connections!
|
ActiveRecord::Base.clear_all_connections!
|
||||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||||
if ActiveRecord::Base.connection.table_exists?('schema_migrations')
|
load("#{Rails.root}/db/#{schema_file(name)}")
|
||||||
puts 'Found tables, skip schema load!'
|
|
||||||
else
|
|
||||||
load("#{Rails.root}/db/#{schema_file(name)}")
|
|
||||||
end
|
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "\n#{e}"
|
puts "\n#{e}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Schema dump for all databases: registry, api_log and whois'
|
namespace :dump do
|
||||||
task dump: [:environment, :load_config] do
|
desc 'Schema dump for all databases: api_log and whois'
|
||||||
puts "\n---------------------------- #{Rails.env} structure and schema dump--------------\n"
|
task all: [:environment, :load_config] do
|
||||||
Rake::Task['db:schema:dump'].invoke # dumps both schema and structure
|
puts "\n---------------------------- #{Rails.env} schema dump--------------\n"
|
||||||
|
|
||||||
other_databases.each do |name|
|
other_databases.each do |name|
|
||||||
begin
|
begin
|
||||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||||
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
||||||
File.open(filename, 'w:utf-8') do |file|
|
File.open(filename, 'w:utf-8') do |file|
|
||||||
ActiveRecord::Base.establish_connection(name)
|
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||||
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -142,17 +63,6 @@ namespace :db do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# alias names
|
|
||||||
namespace :structure do
|
|
||||||
desc '(alias) Schema dump for all databases: registry, api_log and whois'
|
|
||||||
task :dump do
|
|
||||||
Rake::Task['db:all:schema:dump'].invoke
|
|
||||||
end
|
|
||||||
desc '(alias) Schema load for all databases: registry, api_log and whois'
|
|
||||||
task :load do
|
|
||||||
Rake::Task['db:all:schema:load'].invoke
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue