Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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