require 'p4util/tasks' require 'rake/clean' begin require 'hsm' Hsm::Tasks.new rescue LoadError puts ('Could not load local hsm task library') end namespace :db do desc 'Create local databases (p4_project_services)' task :create do sh 'createdb -U postgres -h 192.168.99.100 p4_project_services' or fail 'createdb failed for p4_project_services' sh 'createdb -U postgres -h 192.168.99.100 notification_services' or fail 'createdb failed for notification_services' sh 'createdb -U postgres -h 192.168.99.100 p4_phoenix_services' or fail 'createdb failed for p4_phoenix_services' end desc 'Run migrations' task :migrate do |t, args| require 'sequel' Sequel.extension :migration puts 'Migrating p4_project_services to latest' url = 'postgres://postgres:rein4ce@192.168.99.100:5432/p4_project_services' db = Sequel.connect(url) Sequel::Migrator.run(db, 'p4_project_services/p4_project_services/migrations') puts 'Migrating notification_services to latest' url = 'postgres://postgres:rein4ce@192.168.99.100:5432/notification_services' db = Sequel.connect(url) Sequel::Migrator.run(db, 'notification_services/notification_services/migrations') puts 'Migrating p4_phoenix_services to latest' url = 'postgres://postgres:rein4ce@192.168.99.100:5432/p4_phoenix_services' db = Sequel.connect(url) Sequel::Migrator.run(db, 'p4_phoenix_services/p4_phoenix_services/migrations') end end namespace :test do # p4util, while handy, may need to be redesigned a bit with docker-compose # in mind. We very likely need to only perform steps that do not require # restart - so something like a "run unicode mode" will not work. desc 'Initialize Perforce server with test data' task :initp4 do sh 'bundle exec p4util init -p "`docker-machine ip`:1666" p4_project_services/clients/ruby/p4_project_services_client/spec/init/' or fail 'p4util init failed' end begin require 'rspec/core/rake_task' ENV['P4WS_HOST'] = `docker-machine ip` RSpec::Core::RakeTask.new(:api) do |t| t.pattern = 'p4_web_api/clients/ruby/p4_web_api_client/spec/*.rb' end end end # begin # require 'ci/reporter/rake/rspec' # require 'rspec/core/rake_task' # # ENV['CI_REPORTS'] = 'spec-output' # CLEAN.include('spec-output', 'coverage') # # RSpec::Core::RakeTask.new(:api_spec) do |t| # t.pattern = 'p4_web_api/clients/ruby/p4_web_api_client/spec/*.rb' # t.ruby_opts = ["-I#{File.absolute_path('p4_web_api/clients/ruby/p4_web_api_client/spec/lib')}"] # end # task api_spec: 'ci:setup:rspec' # # RSpec::Core::RakeTask.new(:proj_spec) do |t| # t.pattern = 'p4_project_services/clients/ruby/p4_project_services_client/spec/*.rb' # t.ruby_opts = ["-I#{File.absolute_path('p4_project_services/clients/ruby/p4_project_services_client/spec/lib')}"] # end # task proj_spec: 'ci:setup:rspec' # # RSpec::Core::RakeTask.new(:proj_svc_spec) do |t| # t.pattern = 'p4_project_services/p4_project_services/spec/*.rb' # end # task proj_svc_spec: 'ci:setup:rspec' # # rescue LoadError # # no rspec available # end desc 'Rebuild native tools in qt/work directory (please set CMAKE_PREFIX_PATH in environment)' task :qt_build do FileUtils.rmtree('qt/work') if Dir.exist?('qt/work') FileUtils.mkdir('qt/work') system('cd qt/work && cmake .. && make') or fail('qt build failed') end CLEAN.include('qt/work') desc 'Run all qt tests' task :qt_test do system('cd qt/work/p4_phoenix_services_client && ./PhoenixIntegrationTests') or fail('PhoenixIntegrationTests failed') end desc 'Create doc directory from docbook files (requires ant)' directory 'build/doc' => 'docbook' do FileUtils.rmtree('build/doc') if Dir.exist?('build/doc') sh 'cd docbook && ant publicsite -Ddoc.build.path=../tools/p4-doc/manuals/_build && cd ..' end CLEAN.include('build/doc') # # require 'sequel' # # This use of Rake by Resque, I do not care for. # DB = Sequel.connect('postgres://localhost:4567/notification_services') # # require 'notification_services/workers/webhook_notifier' # require 'resque/tasks' # # namespace :redis do # desc 'Start a local redis-server in work/redis' # task :start do # FileUtils.mkdir_p('work/redis') unless Dir.exist?('work/redis') # pid = Process.spawn('redis-server') # Process.detach(pid) # IO.write('work/redis.pid', pid.to_s) # end # # desc 'Stop the local redis-server' # task :stop do # if File.exist?('work/redis.pid') # pid = IO.read('work/redis.pid').to_i # Process.kill('TERM', pid) # end # end # # desc 'Remove the redis working directory' # task :clean => :stop do # FileUtils.rmtree('work/redis') if Dir.exist?('work/redis') # File.delete('work/redis.pid') if File.exist?('work/redis.pid') # end # end