-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
186 lines (126 loc) · 4.65 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require './ruby_version'
desc "Defaiult task for 'rake', runs 'rspec spec' on latest active_record version."
task :default do
Rake::Task["test_latest"].invoke
end
desc "Runs 'rspec spec' on latest active_record version."
task :test_latest do
puts "\n\n"
puts "=====================================\n"
puts " Testing Latest ActiveRecord Version"
puts "=====================================\n"
latest = `BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ exec appraisal list`.split("\n").first
system "WITH_COVERAGE=true BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ exec appraisal #{latest} rspec spec"
end
desc "Runs 'rspec spec' on latest active_record version."
task :latest do
Rake::Task["test_latest"].invoke
end
desc "Runs 'rspec spec' on every version of active_record."
task :test_all do
# hide deprecation warnings
parts = ["HIDE_DEPRECATIONS=true"]
# set the gemfile for the current vertsion of ruby
parts << "BUNDLE_GEMFILE=#{RubyVersion.gemfile}"
# run appraisals
parts << "bundle _2.3.26_ exec appraisal rspec spec"
# runb the command
system parts.join(' ')
end
desc "Runs 'rspec spec' on every version of active_record."
task :all do
puts "\n\n"
puts "===================================\n"
puts " Testing All ActiveRecord Versions"
puts "===================================\n"
Rake::Task["test_all"].invoke
end
desc "Runs 'rspec spec --tag test' on latest active_record version."
task :test_tagged do
latest = `bundle _2.3.26_ exec appraisal list`.split("\n").first
system "BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle exec appraisal #{latest} rspec spec --tag test"
end
desc "Runs 'rspec spec --tag test' on latest active_record version."
task :tagged do
Rake::Task["test_tagged"].invoke
end
desc "Installs the gems and gemfiles for each version of active_record within 'appraisals'."
task :install do
puts "\n\n"
puts "==================\n"
puts " Updating Bundler"
puts "==================\n"
# system "gem update bundler"
system "gem install bundler:2.3.26"
puts "\n\n"
puts "=================\n"
puts " Installing Gems"
puts "=================\n"
puts "Using '#{RubyVersion.gemfile}'\n\n"
system "BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ install"
system "BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ lock --add-platform x86_64-linux"
puts "\n\n"
puts "======================\n"
puts " Installing Appraisal"
puts "======================\n"
system "BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ exec appraisal install"
puts "\n\n"
end
desc "Runs bundle outdated for the current version of ruby."
task :outdated do
puts "Checking outdated for '#{RubyVersion.gemfile}'"
system("BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle outdated")
end
desc "Runs bundle update for the current version of ruby."
task :update do
puts "Updating for '#{RubyVersion.gemfile}'"
system("BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle outdated")
system("BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle update")
end
desc "Outputs the terminal command to run 'rspec spec' on the latest version of active_record."
task :spec_command do
latest = `bundle _2.3.26_ exec appraisal list`.split("\n").first
puts "\nbundle _2.3.26_ exec appraisal #{latest} rspec spec/\n\n"
end
desc "Generates the Yard documentation & opens it in the default browser."
task :doc do
unless RubyVersion.latest?
fail "\nDocs only available in Ruby #{RubyVersion.latest_version}\n\n"
end
`yardoc`
`open doc/index.html`
end
desc "Generates the Yard documentation & opens it in the default browser. (alias for :doc)"
task :docs do
Rake::Task["doc"].invoke
end
desc "Opens the coverage results in the default brwoser."
task :coverage do
Rake::Task["test_latest"].invoke
unless ENV['GITHUB_ACTION']
`open coverage/index.html`
end
end
desc "Runs 'rubocop' on the 'lib' directory, auto-correcting appropved cops."
task :rubo do
corrections = [
'Layout/TrailingWhitespace',
'Layout/EmptyLinesAroundClassBody',
'Layout/EmptyLinesAroundModuleBody',
'Layout/EmptyLineBetweenDefs'
]
system "bundle _2.3.26_ exec rubocop --auto-correct --only #{corrections.join(',')} lib/"
end
desc "Validate the .codecov.yml file"
task :validate_codecov do
system "cat .codecov.yml | curl --data-binary @- https://codecov.io/validate"
end
desc "Return the commnad needed to run bundler for the current gemfile"
task :bundler do
puts "\n\n"
puts "=================\n"
puts " Bundler Command"
puts "=================\n\n"
puts "BUNDLE_GEMFILE=#{RubyVersion.gemfile} bundle _2.3.26_ "
puts "\n\n"
end