-
Notifications
You must be signed in to change notification settings - Fork 41
/
Rakefile
122 lines (99 loc) · 3.5 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
120
121
122
require 'rake'
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
require 'engine_cart/rake_task'
require 'solr_wrapper'
task :default => :ci
desc "Run specs"
RSpec::Core::RakeTask.new
# rspec hooks up spec task with spec:prepapre dependency. But we need to make sure
# it gets called *within test app* so for jsbundling-rails JS is properly built.
# So we add our custom as a dependency.
task spec: ["test:spec:prepare"]
task ci: ['engine_cart:generate'] do
SolrWrapper.wrap do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
Rake::Task["test:seed"].invoke
Rake::Task['spec'].invoke
end
end
end
desc "check npm and gem versions match before release"
task :guard_version_match do
gem_version = File.read(__dir__ + "/VERSION").chomp
npm_version = JSON.parse(File.read(__dir__ + "/package.json"))["version"]
# 9.0.0.beta1 in gem becomes 9.0.0-beta1 in npm
gem_version_parts = gem_version.split(".")
npm_version_required = [
gem_version_parts.slice(0, 3).join("."),
gem_version_parts.slice(3, gem_version_parts.length).join(".")
].join("-")
if npm_version != npm_version_required
raise <<~EOS
You should not publish without npm version in package.json matching gem version
gem version: #{gem_version}
package.json version: #{npm_version}
expected package.json version: #{npm_version_required}
EOS
end
end
# Get our guard to run before `rake release`'s, and warning afterwards
task "release:guard_clean" => :guard_version_match
Rake::Task["guard_version_match"].enhance do
puts <<~EOS
⚠️ Please remember to run `npm publish` the npm package too! ⚠️
If you don't have permission, please ask someone who does for help.
https://www.npmjs.com/package/blacklight-range-limit
EOS
end
namespace :test do
namespace :spec do
desc "call task spec:prepare within test app"
task :prepare do
within_test_app do
system "bin/rake spec:prepare"
end
end
end
desc "Put sample data into solr"
task seed: ['engine_cart:generate'] do
within_test_app do
ENV['RAILS_ENV'] ||= 'test'
system "rake blacklight:index:seed"
system "rake blacklight_range_limit:seed"
end
end
desc "run just solr, useful for local tests"
task :solr, [:rails_sever_args] do |_t, args|
unless File.exist? EngineCart.destination
Rake::Task['engine_cart:generate'].invoke
end
SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
Rake::Task['test:seed'].invoke
# sleep forever, make us cntrl-c to get out
puts "solr is running on port 8983, ctrl-c to exit..."
system "while true; do sleep 10000; done"
end
end
end
desc 'Run Solr and Blacklight for interactive development'
task :server, [:rails_server_args] do |_t, args|
if File.exist? EngineCart.destination
within_test_app do
system "bundle update"
end
else
Rake::Task['engine_cart:generate'].invoke
end
SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path(File.dirname(__FILE__)), "solr", "conf")) do
Rake::Task['test:seed'].invoke
within_test_app do
system "bundle exec rails s #{args[:rails_server_args]}"
end
end
end
end
end