forked from projectblacklight/spotlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
119 lines (96 loc) · 3.28 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# frozen_string_literal: true
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Spotlight'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks
require 'solr_wrapper'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
require 'engine_cart/rake_task'
require 'spotlight/version'
task ci: ['engine_cart:generate'] do
ENV['environment'] = 'test'
SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(__dir__, 'solr_conf', 'conf')) do
within_test_app do
system 'bundle install'
system 'bundle exec rake db:migrate'
end
Rake::Task['spotlight:fixtures'].invoke
# run the tests
Rake::Task['spec'].invoke
end
end
end
namespace :spotlight do
desc 'Load fixtures'
task fixtures: ['engine_cart:generate'] do
within_test_app do
system 'rake spotlight_test:solr:seed RAILS_ENV=test'
abort 'Error running fixtures' unless $?.success?
end
end
desc 'Start the test application for Spotlight'
task :server do
Rake::Task['engine_cart:generate'].invoke
SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(__dir__, 'solr_conf', 'conf')) do
within_test_app do
unless File.exist? '.initialized'
system 'bundle exec rake spotlight:initialize'
system 'bundle exec rake spotlight_test:solr:seed'
File.open('.initialized', 'w') {}
end
system 'bundle exec rails s'
end
end
end
end
namespace :template do
desc 'Start a brand new Spotlight application using the Rails template'
task :server do
require 'tmpdir'
require 'fileutils'
template_path = File.expand_path(File.join(File.dirname(__FILE__), 'template.rb'))
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
Bundler.with_clean_env do
version = "_#{Gem.loaded_specs['rails'].version}_" if Gem.loaded_specs['rails']
Bundler.with_clean_env do
IO.popen({ 'SPOTLIGHT_GEM' => File.dirname(__FILE__) },
['rails', version, 'new', 'internal', '--skip-spring', '-m', template_path] +
[err: %i[child out]]) do |io|
IO.copy_stream(io, $stderr)
_, exit_status = Process.wait2(io.pid)
raise 'Failed to generate spotlight' if exit_status.nonzero?
end
end
Bundler.with_clean_env do
Dir.chdir('internal') do
APP_ROOT = Dir.pwd
SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path('..', File.dirname(__FILE__)), 'solr', 'conf')) do
system 'bundle exec rails s'
end
end
end
end
end
end
end
end
end
end
task default: %i[rubocop ci]