Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 189 lines (160 sloc) 5.292 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
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
51 File.open(File.join("lib", "airbrake", "notifier", "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")
6b7a357 @gabebw Vendor rake 0.8.7 locally
gabebw authored
118 LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil], ['sinatra', nil], ['rake', '0.8.7']] +
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
119 RAILS_VERSIONS.collect { |version| ['rails', version] }
7df97d7 @jferris Added a test for the installation process
jferris authored
120
13bb3dd Description for vendor_test_gems rake task
Harold Giménez authored
121 desc "Vendor test gems: Run this once to prepare your test environment"
7df97d7 @jferris Added a test for the installation process
jferris authored
122 task :vendor_test_gems do
8294dcd @jferris Restore gem path after vendoring
jferris authored
123 old_gem_path = ENV['GEM_PATH']
124 old_gem_home = ENV['GEM_HOME']
125 ENV['GEM_PATH'] = LOCAL_GEM_ROOT
126 ENV['GEM_HOME'] = LOCAL_GEM_ROOT
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
127 LOCAL_GEMS.each do |gem_name, version|
128 gem_file_pattern = [gem_name, version || '*'].compact.join('-')
129 version_option = version ? "-v #{version}" : ''
130 pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
7df97d7 @jferris Added a test for the installation process
jferris authored
131 existing = Dir.glob(pattern).first
132 unless existing
2f16e06 @jferris Less noisy
jferris authored
133 command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
134 puts "Vendoring #{gem_file_pattern}..."
33eebc4 @jferris Fail loudly when a gem can't be vendored
jferris authored
135 unless system("#{command} 2>&1")
136 puts "Command failed: #{command}"
137 exit(1)
7df97d7 @jferris Added a test for the installation process
jferris authored
138 end
139 end
140 end
8294dcd @jferris Restore gem path after vendoring
jferris authored
141 ENV['GEM_PATH'] = old_gem_path
142 ENV['GEM_HOME'] = old_gem_home
7df97d7 @jferris Added a test for the installation process
jferris authored
143 end
144
145 Cucumber::Rake::Task.new(:cucumber) do |t|
146 t.fork = true
147 t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
148 end
149
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
150 task :cucumber => [:vendor_test_gems]
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
151
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
152 def run_rails_cucumbr_task(version, additional_cucumber_args)
153 puts "Testing Rails #{version}"
154 if version.empty?
155 raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
156 end
157 ENV['RAILS_VERSION'] = version
158 system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature")
159 end
160
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
161 def define_rails_cucumber_tasks(additional_cucumber_args = '')
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
162 namespace :rails do
6fbbe2b @jferris Added integration tests for rescuing
jferris authored
163 RAILS_VERSIONS.each do |version|
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
164 desc "Test integration of the gem with Rails #{version}"
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
165 task version => [:vendor_test_gems] do
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
166 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
167 end
168 end
169
170 desc "Test integration of the gem with all Rails versions"
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
171 task :all do
172 results = RAILS_VERSIONS.map do |version|
173 run_rails_cucumbr_task(version, additional_cucumber_args)
174 end
175
176 exit 1 unless results.all?
177 end
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
178 end
179 end
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
180
181 namespace :cucumber do
182 namespace :wip do
183 define_rails_cucumber_tasks('--tags @wip')
184 end
185
186 define_rails_cucumber_tasks
187 end
188
Something went wrong with that request. Please try again.