Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 224 lines (188 sloc) 6.109 kB
34a3106 Added hoptoad_notifier
jyurek authored
1 require 'rake'
2 require 'rake/testtask'
8a0bd14 @mike-burns Use less deprecated gems and requires.
mike-burns authored
3 require 'rubygems/package_task'
da65e95 @gabebw Informatively fail if cucumber isn't installed
gabebw authored
4 begin
5 require 'cucumber/rake/task'
6 rescue LoadError
7 $stderr.puts "Please install cucumber: `gem install cucumber`"
8 exit 1
9 end
8b01b01 Bumping to version 3.1.1
Jonathan Siegel authored
10 require './lib/airbrake/version'
34a3106 Added hoptoad_notifier
jyurek authored
11
779c7ac @shime remove unnecessary shim
shime authored
12 FEATURES = ["sinatra","rack","metal","user_informer"]
e7b7d7a @shime add all supported frameworks to rake test task
shime authored
13
34a3106 Added hoptoad_notifier
jyurek authored
14 desc 'Default: run unit tests.'
779c7ac @shime remove unnecessary shim
shime authored
15 task :default => [:test, "cucumber:rails:all"] + FEATURES
34a3106 Added hoptoad_notifier
jyurek authored
16
02220b1 @jyurek A task to clean
jyurek authored
17 desc "Clean out the tmp directory"
18 task :clean do
19 exec "rm -rf tmp"
20 end
21
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
22 desc 'Test the airbrake gem.'
34a3106 Added hoptoad_notifier
jyurek authored
23 Rake::TestTask.new(:test) do |t|
24 t.libs << 'lib'
25 t.pattern = 'test/**/*_test.rb'
26 t.verbose = true
27 end
28
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
29 namespace :changeling do
30 desc "Bumps the version by a minor or patch version, depending on what was passed in."
31 task :bump, :part do |t, args|
32 # Thanks, Jeweler!
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
33 if Airbrake::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
34 major = $1.to_i
35 minor = $2.to_i
36 patch = $3.to_i
37 build = $4
38 else
39 abort
40 end
41
42 case args[:part]
43 when /minor/
44 minor += 1
45 patch = 0
46 when /patch/
47 patch += 1
48 else
49 abort
50 end
51
52 version = [major, minor, patch, build].compact.join('.')
53
3ff689e Bumped 3.0.5
Jonathan Siegel authored
54 File.open(File.join("lib", "airbrake", "version.rb"), "w") do |f|
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
55 f.write <<EOF
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
56 module Airbrake
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
57 VERSION = "#{version}".freeze
58 end
59 EOF
60 end
61 end
62
63 desc "Writes out the new CHANGELOG and prepares the release"
64 task :change do
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
65 load 'lib/airbrake/version.rb'
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
66 file = "CHANGELOG"
67 old = File.read(file)
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
68 version = Airbrake::VERSION
4a84f90 @shime minor fixes for Rakefile
shime authored
69 message = "Bumping to version #{version}"
0458123 @shime add a CHANGELOG entry for 3.1.0
shime authored
70 editor = ENV["EDITOR"] || "vim" # prefer vim if no env variable for editor is set
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
71
72 File.open(file, "w") do |f|
73 f.write <<EOF
3c65260 @jasonm Bumping to version 2.3.9
jasonm authored
74 Version #{version} - #{Time.now}
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
75 ===============================================================================
76
0458123 @shime add a CHANGELOG entry for 3.1.0
shime authored
77 #{`git log $(git tag | grep -v rc | tail -1)..HEAD | git shortlog`}
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
78 #{old}
79 EOF
80 end
81
0458123 @shime add a CHANGELOG entry for 3.1.0
shime authored
82 exec ["#{editor} #{file}",
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
83 "git commit -aqm '#{message}'",
84 "git tag -a -m '#{message}' v#{version}",
5948491 @qrush Adding rake changeling:push
qrush authored
85 "echo '\n\n\033[32mMarked v#{version} /' `git show-ref -s refs/heads/master` 'for release. Run: rake changeling:push\033[0m\n\n'"].join(' && ')
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
86 end
87
88 desc "Bump by a minor version (1.2.3 => 1.3.0)"
89 task :minor do |t|
90 Rake::Task['changeling:bump'].invoke(t.name)
91 Rake::Task['changeling:change'].invoke
92 end
93
94 desc "Bump by a patch version, (1.2.3 => 1.2.4)"
95 task :patch do |t|
96 Rake::Task['changeling:bump'].invoke(t.name)
97 Rake::Task['changeling:change'].invoke
98 end
5948491 @qrush Adding rake changeling:push
qrush authored
99
100 desc "Push the latest version and tags"
101 task :push do |t|
102 system("git push origin master")
4a84f90 @shime minor fixes for Rakefile
shime authored
103 system("git push origin $(git tag | grep -v rc | tail -1)")
5948491 @qrush Adding rake changeling:push
qrush authored
104 end
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
105 end
106
c4e26cb @qrush Starting YARD'ing up the plugin
qrush authored
107 begin
108 require 'yard'
109 YARD::Rake::YardocTask.new do |t|
df14a50 @qrush Removing INSTALL and making sure the testing and license file show up
qrush authored
110 t.files = ['lib/**/*.rb', 'TESTING.rdoc']
c4e26cb @qrush Starting YARD'ing up the plugin
qrush authored
111 end
112 rescue LoadError
113 end
bf486bb @jferris Addd a gemspec
jferris authored
114
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
115 GEM_ROOT = File.dirname(__FILE__).freeze
bf486bb @jferris Addd a gemspec
jferris authored
116
117 desc "Clean files generated by rake tasks"
118 task :clobber => [:clobber_rdoc, :clobber_package]
119
7df97d7 @jferris Added a test for the installation process
jferris authored
120 LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
121 RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
afcd9ca @shime support rails 3.2.x with the test suite
shime authored
122 LOCAL_GEMS =
123 [
124 ["rack","1.3.2"],
125 ] +
126 RAILS_VERSIONS.collect { |version| ['rails', version] } +
127 [
128 ['sham_rack', nil],
129 ['capistrano', nil],
130 ['sqlite3-ruby', nil],
611e8ea @shime log messages for sinatra and rack
shime authored
131 ["therubyracer",nil],
132 ["sinatra",nil]
afcd9ca @shime support rails 3.2.x with the test suite
shime authored
133 ]
134
7df97d7 @jferris Added a test for the installation process
jferris authored
135
13bb3dd Description for vendor_test_gems rake task
Harold Giménez authored
136 desc "Vendor test gems: Run this once to prepare your test environment"
7df97d7 @jferris Added a test for the installation process
jferris authored
137 task :vendor_test_gems do
8294dcd @jferris Restore gem path after vendoring
jferris authored
138 old_gem_path = ENV['GEM_PATH']
139 old_gem_home = ENV['GEM_HOME']
140 ENV['GEM_PATH'] = LOCAL_GEM_ROOT
141 ENV['GEM_HOME'] = LOCAL_GEM_ROOT
afcd9ca @shime support rails 3.2.x with the test suite
shime authored
142
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
143 LOCAL_GEMS.each do |gem_name, version|
144 gem_file_pattern = [gem_name, version || '*'].compact.join('-')
145 version_option = version ? "-v #{version}" : ''
146 pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
7df97d7 @jferris Added a test for the installation process
jferris authored
147 existing = Dir.glob(pattern).first
afcd9ca @shime support rails 3.2.x with the test suite
shime authored
148 if existing
149 puts "\nskipping #{gem_name} since it's already vendored," +
150 "remove it from the tmp directory first."
151 next
152 end
153
154 command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
155 puts "Vendoring #{gem_file_pattern}..."
156 unless system("#{command} 2>&1")
157 puts "Command failed: #{command}"
158 exit(1)
7df97d7 @jferris Added a test for the installation process
jferris authored
159 end
160 end
afcd9ca @shime support rails 3.2.x with the test suite
shime authored
161
8294dcd @jferris Restore gem path after vendoring
jferris authored
162 ENV['GEM_PATH'] = old_gem_path
163 ENV['GEM_HOME'] = old_gem_home
7df97d7 @jferris Added a test for the installation process
jferris authored
164 end
165
166 Cucumber::Rake::Task.new(:cucumber) do |t|
167 t.fork = true
168 t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
169 end
170
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
171 task :cucumber => [:vendor_test_gems]
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
172
e7b7d7a @shime add all supported frameworks to rake test task
shime authored
173
b4f1d3a @shime fix typo in Rakefile
shime authored
174 def run_rails_cucumber_task(version, additional_cucumber_args)
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
175 puts "Testing Rails #{version}"
176 if version.empty?
177 raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
178 end
179 ENV['RAILS_VERSION'] = version
8213553 @shime monkeypatch the old rails versions in tests
shime authored
180 cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature"
1a84993 @dvdplm Be explicit about what cucumber commands we run
dvdplm authored
181 puts "Running command: #{cmd}"
182 system(cmd)
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
183 end
184
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
185 def define_rails_cucumber_tasks(additional_cucumber_args = '')
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
186 namespace :rails do
6fbbe2b @jferris Added integration tests for rescuing
jferris authored
187 RAILS_VERSIONS.each do |version|
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
188 desc "Test integration of the gem with Rails #{version}"
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
189 task version => [:vendor_test_gems] do
b4f1d3a @shime fix typo in Rakefile
shime authored
190 exit 1 unless run_rails_cucumber_task(version, additional_cucumber_args)
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
191 end
192 end
193
194 desc "Test integration of the gem with all Rails versions"
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
195 task :all do
196 results = RAILS_VERSIONS.map do |version|
b4f1d3a @shime fix typo in Rakefile
shime authored
197 run_rails_cucumber_task(version, additional_cucumber_args)
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
198 end
199
200 exit 1 unless results.all?
201 end
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
202 end
203 end
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
204
205 namespace :cucumber do
206 namespace :wip do
207 define_rails_cucumber_tasks('--tags @wip')
208 end
209
210 define_rails_cucumber_tasks
211
779c7ac @shime remove unnecessary shim
shime authored
212 rule /#{"(" + FEATURES.join("|") + ")"}/ do |t|
e7b7d7a @shime add all supported frameworks to rake test task
shime authored
213 framework = t.name
214 desc "Test integration of the gem with #{framework}"
215 task framework.to_sym do
216 puts "Testing #{framework.split(":").last}..."
217 cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features/#{framework.split(":").last}.feature"
218 puts "Running command: #{cmd}"
219 system(cmd)
220 end
221 end
222
223 end
Something went wrong with that request. Please try again.