forked from mongodb/mongoid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
146 lines (118 loc) · 3.34 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# frozen_string_literal: true
# rubocop:todo all
require "bundler"
require "bundler/gem_tasks"
Bundler.setup
ROOT = File.expand_path(File.join(File.dirname(__FILE__)))
$: << File.join(ROOT, 'spec/shared/lib')
require "rake"
require "rspec/core/rake_task"
require 'mrss/spec_organizer'
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "mongoid/version"
tasks = Rake.application.instance_variable_get('@tasks')
tasks['release:do'] = tasks.delete('release')
task :gem => :build
task :build do
system "gem build mongoid.gemspec"
end
task :install => :build do
system "sudo gem install mongoid-#{Mongoid::VERSION}.gem"
end
task :release do
raise "Please use ./release.sh to release"
end
RSpec::Core::RakeTask.new("spec") do |spec|
spec.pattern = "spec/**/*_spec.rb"
end
RSpec::Core::RakeTask.new('spec:progress') do |spec|
spec.rspec_opts = %w(--format progress)
spec.pattern = "spec/**/*_spec.rb"
end
desc 'Build and validate the evergreen config'
task eg: %w[ eg:build eg:validate ]
# 'eg' == 'evergreen', but evergreen is too many letters for convenience
namespace :eg do
desc 'Builds the .evergreen/config.yml file from the templates'
task :build do
ruby '.evergreen/update-evergreen-configs'
end
desc 'Validates the .evergreen/config.yml file'
task :validate do
system 'evergreen validate --project mongoid .evergreen/config.yml'
end
desc 'Updates the evergreen executable to the latest available version'
task :update do
system 'evergreen get-update --install'
end
desc 'Runs the current branch as an evergreen patch'
task :patch do
system 'evergreen patch --uncommitted --project mongoid --browse --auto-description --yes'
end
end
namespace :generate do
desc 'Generates a mongoid.yml from the template'
task :config do
require 'mongoid'
require 'erb'
template_path = 'lib/rails/generators/mongoid/config/templates/mongoid.yml'
database_name = ENV['DATABASE_NAME'] || 'my_db'
config = ERB.new(File.read(template_path), trim_mode: '-').result(binding)
File.write('mongoid.yml', config)
end
end
CLASSIFIERS = [
[%r,^mongoid/attribute,, :attributes],
[%r,^mongoid/association/[or],, :associations_referenced],
[%r,^mongoid/association,, :associations],
[%r,^mongoid,, :unit],
[%r,^integration,, :integration],
[%r,^rails,, :rails],
]
RUN_PRIORITY = %i(
unit attributes associations_referenced associations
integration rails
)
def spec_organizer
Mrss::SpecOrganizer.new(
root: ROOT,
classifiers: CLASSIFIERS,
priority_order: RUN_PRIORITY,
)
end
task :ci do
spec_organizer.run
end
task :bucket, %i(buckets) do |task, args|
buckets = args[:buckets]
buckets = if buckets.nil? || buckets.empty?
[nil]
else
buckets.split(':').map do |bucket|
if bucket.empty?
nil
else
bucket.to_sym
end
end
end
spec_organizer.run_buckets(*buckets)
end
task :default => :spec
desc "Generate all documentation"
task :docs => 'docs:yard'
namespace :docs do
desc "Generate yard documentation"
task :yard do
out = File.join('yard-docs', Mongoid::VERSION)
FileUtils.rm_rf(out)
system "yardoc -o #{out} --title mongoid-#{Mongoid::VERSION}"
end
end
namespace :release do
task :check_private_key do
unless File.exist?('gem-private_key.pem')
raise "No private key present, cannot release"
end
end
end