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
|
||||
cache: bundler
|
||||
env:
|
||||
- DB=postgresql
|
||||
bundler_args: --without development staging production
|
||||
|
@ -9,9 +10,7 @@ before_script:
|
|||
- "cp config/application-example.yml config/application.yml"
|
||||
- "cp config/secrets-example.yml config/secrets.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:all:schema:load"
|
||||
- "RAILS_ENV=test bundle exec rake db:migrate"
|
||||
- "RAILS_ENV=test bundle exec rake db:setup:all"
|
||||
script:
|
||||
- "RAILS_ENV=test bundle exec rspec"
|
||||
after_success:
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -139,8 +139,6 @@ group :development, :test do
|
|||
# debug
|
||||
gem 'pry', '0.10.1'
|
||||
|
||||
# code review
|
||||
gem 'rubycritic', '3.2.0'
|
||||
gem 'bullet', '4.14.7' # for finding database optimizations
|
||||
gem 'bundler-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)
|
||||
chronic (0.10.2)
|
||||
cliver (0.3.2)
|
||||
codeclimate-engine-rb (0.4.0)
|
||||
virtus (~> 1.0)
|
||||
codeclimate-test-reporter (1.0.8)
|
||||
simplecov (<= 0.13)
|
||||
coderay (1.1.0)
|
||||
|
@ -195,15 +193,6 @@ GEM
|
|||
ffi (1.9.18)
|
||||
figaro (1.1.1)
|
||||
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)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
|
@ -297,7 +286,7 @@ GEM
|
|||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.0.11)
|
||||
mail (2.6.4)
|
||||
mail (2.6.5)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
|
@ -333,7 +322,6 @@ GEM
|
|||
orm_adapter (0.5.0)
|
||||
parser (2.4.0.0)
|
||||
ast (~> 2.2)
|
||||
path_expander (1.0.1)
|
||||
pdfkit (0.6.2)
|
||||
pg (0.19.0)
|
||||
phantomjs (1.9.8.0)
|
||||
|
@ -405,10 +393,6 @@ GEM
|
|||
rb-inotify (0.9.8)
|
||||
ffi (>= 0.5.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)
|
||||
request_store (1.1.0)
|
||||
responders (2.3.0)
|
||||
|
@ -448,15 +432,6 @@ GEM
|
|||
ruby_dep (1.5.0)
|
||||
ruby_parser (3.8.4)
|
||||
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)
|
||||
sass (3.4.23)
|
||||
sass-rails (5.0.6)
|
||||
|
@ -620,7 +595,6 @@ DEPENDENCIES
|
|||
rest-client
|
||||
rspec-rails (~> 3.5)
|
||||
rubocop (= 0.48.1)
|
||||
rubycritic (= 3.2.0)
|
||||
sass-rails (= 5.0.6)
|
||||
sdoc (= 0.4.1)
|
||||
select2-rails (= 3.5.9.3)
|
||||
|
|
|
@ -44,7 +44,7 @@ Manual demo install and database setup:
|
|||
bundle
|
||||
cp config/application-example.yml config/application.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
|
||||
|
||||
### 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:
|
||||
|
||||
RAILS_ENV=test rake db:all:setup
|
||||
RAILS_ENV=test rake db:setup:all
|
||||
|
||||
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 :schema do
|
||||
task load: [:environment, :load_config] do
|
||||
puts 'Only rake db:structure:load is supported and invoked. ' \
|
||||
'Otherwise zonefile generation does not work nor que.'
|
||||
Rake::Task["db:structure:load"].invoke
|
||||
end
|
||||
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
|
||||
namespace :setup do
|
||||
desc 'Create all databases: api_log and whois'
|
||||
task all: [:environment, :load_config] do
|
||||
Rake::Task['db:create:all'].invoke
|
||||
Rake::Task['db:structure:load'].invoke
|
||||
Rake::Task['db:schema:load:all'].invoke
|
||||
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
||||
|
@ -60,81 +13,49 @@ namespace :db do
|
|||
Rake::Task['db:seed'].invoke
|
||||
puts "\n All done!\n\n"
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Create all databases: registry, api_log and whois'
|
||||
task create: [:environment, :load_config] do
|
||||
databases.each do |name|
|
||||
begin
|
||||
puts "\n------------------------ Create #{name} ---------------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
conf = ActiveRecord::Base.configurations
|
||||
namespace :schema do
|
||||
def other_databases
|
||||
@other_dbs ||= ["api_log_#{Rails.env}", "whois_#{Rails.env}"]
|
||||
end
|
||||
|
||||
if name == Rails.env
|
||||
ActiveRecord::Tasks::DatabaseTasks.create_current
|
||||
else
|
||||
ActiveRecord::Base.connection.create_database(conf[name]['database'].to_sym, conf[name])
|
||||
end
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
def schema_file(db)
|
||||
case db
|
||||
when "api_log_#{Rails.env}"
|
||||
'api_log_schema.rb'
|
||||
when "whois_#{Rails.env}"
|
||||
'whois_schema.rb'
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Drop all databaseses: registry, api_log and whois'
|
||||
task drop: [:environment, :load_config] do
|
||||
# just in case we allow only drop test, comment it out only for temp
|
||||
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
|
||||
|
||||
namespace :load do
|
||||
desc 'Schema load for all databases: api_log and whois'
|
||||
task all: [:environment, :load_config] do
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
puts "\n------------------------ #{name} schema loading -----------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(name.to_sym)
|
||||
if ActiveRecord::Base.connection.table_exists?('schema_migrations')
|
||||
puts 'Found tables, skip schema load!'
|
||||
else
|
||||
load("#{Rails.root}/db/#{schema_file(name)}")
|
||||
end
|
||||
load("#{Rails.root}/db/#{schema_file(name)}")
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Schema dump for all databases: registry, api_log and whois'
|
||||
task dump: [:environment, :load_config] do
|
||||
puts "\n---------------------------- #{Rails.env} structure and schema dump--------------\n"
|
||||
Rake::Task['db:schema:dump'].invoke # dumps both schema and structure
|
||||
namespace :dump do
|
||||
desc 'Schema dump for all databases: api_log and whois'
|
||||
task all: [:environment, :load_config] do
|
||||
puts "\n---------------------------- #{Rails.env} schema dump--------------\n"
|
||||
|
||||
other_databases.each do |name|
|
||||
begin
|
||||
puts "\n---------------------------- #{name} ----------------------------------------\n"
|
||||
filename = "#{Rails.root}/db/#{schema_file(name)}"
|
||||
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)
|
||||
end
|
||||
rescue => e
|
||||
|
@ -142,17 +63,6 @@ namespace :db do
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue