Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 299 lines (250 sloc) 9.39 kb
2fb6ae6 @alloy Hmm, chicken and egg problem on Travis, copy travis:setup task from Xcod...
alloy authored
1 # Travis support
2 def on_rvm?
3 `which ruby`.strip.include?('.rvm')
4 end
5
6 def rvm_ruby_dir
7 @rvm_ruby_dir ||= File.expand_path('../..', `which ruby`.strip)
8 end
9
10 namespace :travis do
11 # Used to create the deb package.
12 #
13 # Known to work with opencflite rev 248.
14 task :prepare_deb do
46d14e0 @fabiopelosin [Rakefile] Fix Travis.
fabiopelosin authored
15 sh "sudo apt-get install subversion libicu-dev"
2fb6ae6 @alloy Hmm, chicken and egg problem on Travis, copy travis:setup task from Xcod...
alloy authored
16 sh "svn co https://opencflite.svn.sourceforge.net/svnroot/opencflite/trunk opencflite"
17 sh "cd opencflite && ./configure --target=linux --with-uuid=/usr --with-tz-includes=./include --prefix=/usr/local && make && sudo make install"
18 sh "sudo /sbin/ldconfig"
19 end
20
21 task :install_opencflite_debs do
22 sh "mkdir -p debs"
23 Dir.chdir("debs") do
46d14e0 @fabiopelosin [Rakefile] Fix Travis.
fabiopelosin authored
24 sh "wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu44_4.4.2-2ubuntu0.11.04.1_i386.deb" unless File.exist?("libicu44_4.4.2-2ubuntu0.11.04.1_i386.deb")
2fb6ae6 @alloy Hmm, chicken and egg problem on Travis, copy travis:setup task from Xcod...
alloy authored
25 base_url = "https://github.com/downloads/CocoaPods/OpenCFLite"
26 %w{ opencflite1_248-1_i386.deb opencflite-dev_248-1_i386.deb }.each do |deb|
27 sh "wget #{File.join(base_url, deb)}" unless File.exist?(deb)
28 end
29 sh "sudo dpkg -i *.deb"
30 end
31 end
32
714ce91 @alloy Move travis install commands to Rakefile and setup CFLAGS env for Travis...
alloy authored
33 task :install do
34 sh "git submodule update --init"
35 sh "sudo apt-get install subversion"
36 sh "env CFLAGS='-I#{rvm_ruby_dir}/include' bundle install"
37 end
38
c3accb7 @alloy Build on Travis should work without this hack now.
alloy authored
39 task :setup => [:install_opencflite_debs, :install]
2fb6ae6 @alloy Hmm, chicken and egg problem on Travis, copy travis:setup task from Xcod...
alloy authored
40 end
41
ad82764 @alloy Add gem:release task.
alloy authored
42 namespace :gem do
43 def gem_version
476ed93 @alloy Clean Rakefile a bit.
alloy authored
44 require File.expand_path('../lib/cocoapods', __FILE__)
ad82764 @alloy Add gem:release task.
alloy authored
45 Pod::VERSION
46 end
47
48 def gem_filename
2fe42a1 @alloy Fix Rakefile gem tasks
alloy authored
49 "cocoapods-#{gem_version}.gem"
ad82764 @alloy Add gem:release task.
alloy authored
50 end
51
52 desc "Build a gem for the current version"
53 task :build do
54 sh "gem build cocoapods.gemspec"
55 end
56
57 desc "Install a gem version of the current code"
58 task :install => :build do
fd5c704 @alloy Improve gem:release tas task.
alloy authored
59 sh "gem install #{gem_filename}"
ad82764 @alloy Add gem:release task.
alloy authored
60 end
61
fd5c704 @alloy Improve gem:release tas task.
alloy authored
62 def silent_sh(command)
63 output = `#{command} 2>&1`
64 unless $?.success?
65 puts output
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
66 exit 1
67 end
fd5c704 @alloy Improve gem:release tas task.
alloy authored
68 output
69 end
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
70
fd5c704 @alloy Improve gem:release tas task.
alloy authored
71 desc "Run all specs, build and install gem, commit version change, tag version change, and push everything"
0f5481d @fabiopelosin [Rakefile] Improvements to release.
fabiopelosin authored
72 task :release do
743207e @fabiopelosin [Rake] Update CocoaPods-version.yml on release.
fabiopelosin authored
73
fd5c704 @alloy Improve gem:release tas task.
alloy authored
74 unless ENV['SKIP_CHECKS']
3f36305 @alloy [Rakefile] Update release task now that `develop` is gone.
alloy authored
75 if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master'
76 $stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release."
fd5c704 @alloy Improve gem:release tas task.
alloy authored
77 exit 1
78 end
79
80 if `git tag`.strip.split("\n").include?(gem_version)
81 $stderr.puts "[!] A tag for version `#{gem_version}' already exists. Change the version in lib/cocoapods.rb"
82 exit 1
83 end
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
84
fd5c704 @alloy Improve gem:release tas task.
alloy authored
85 puts "You are about to release `#{gem_version}', is that correct? [y/n]"
86 exit if $stdin.gets.strip.downcase != 'y'
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
87
0f5481d @fabiopelosin [Rakefile] Improvements to release.
fabiopelosin authored
88 diff_lines = `git diff --name-only`.strip.split("\n")
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
89
0f5481d @fabiopelosin [Rakefile] Improvements to release.
fabiopelosin authored
90 if diff_lines.size == 0
fd5c704 @alloy Improve gem:release tas task.
alloy authored
91 $stderr.puts "[!] Change the version number yourself in lib/cocoapods.rb"
92 exit 1
93 end
94
f9886a1 @fabiopelosin [Rakefile] fine tuned release task.
fabiopelosin authored
95 diff_lines.delete('Gemfile.lock')
e6438c3 @fabiopelosin [Rakefile] Allow to update the changelog during a release.
fabiopelosin authored
96 diff_lines.delete('CHANGELOG.md')
5a0a496 @fabiopelosin [Rakefile] Improvements to gem:release.
fabiopelosin authored
97 if diff_lines != ['lib/cocoapods.rb']
fd5c704 @alloy Improve gem:release tas task.
alloy authored
98 $stderr.puts "[!] Only change the version number in a release commit!"
99 exit 1
100 end
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
101 end
102
19448ec @alloy Ensure the gemspec can be loaded.
alloy authored
103 require 'date'
104
fd5c704 @alloy Improve gem:release tas task.
alloy authored
105 # First check if the required Xcodeproj gem has ben pushed
106 gem_spec = eval(File.read(File.expand_path('../cocoapods.gemspec', __FILE__)))
107 xcodeproj = gem_spec.dependencies.find { |d| d.name == 'xcodeproj' }
23268a2 @alloy Make Xcodeproj version check actually work.
alloy authored
108 required_xcodeproj_version = xcodeproj.requirement.requirements.first.last.to_s
fd5c704 @alloy Improve gem:release tas task.
alloy authored
109
23268a2 @alloy Make Xcodeproj version check actually work.
alloy authored
110 puts "* Checking if xcodeproj #{required_xcodeproj_version} exists on the gem host"
111 search_result = silent_sh("gem search --remote xcodeproj")
112 remote_xcodeproj_version = search_result.match(/xcodeproj \(([\d\.]+)\)/m)[1]
113 unless Gem::Version.new(required_xcodeproj_version) <= Gem::Version.new(remote_xcodeproj_version)
114 $stderr.puts "[!] The Xcodeproj version `#{required_xcodeproj_version}' required by " \
fd5c704 @alloy Improve gem:release tas task.
alloy authored
115 "this version of CocoaPods does not exist on the gem host. " \
116 "Either push that first, or fix the version requirement."
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
117 exit 1
ad82764 @alloy Add gem:release task.
alloy authored
118 end
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
119
3f36305 @alloy [Rakefile] Update release task now that `develop` is gone.
alloy authored
120 # Ensure that the branches are up to date with the remote
121 sh "git pull"
122
fd5c704 @alloy Improve gem:release tas task.
alloy authored
123 puts "* Running specs"
124 silent_sh('rake spec:all')
125
126 tmp = File.expand_path('../tmp', __FILE__)
127 tmp_gems = File.join(tmp, 'gems')
128
0f5481d @fabiopelosin [Rakefile] Improvements to release.
fabiopelosin authored
129 Rake::Task['gem:build'].invoke
130
fd5c704 @alloy Improve gem:release tas task.
alloy authored
131 puts "* Testing gem installation (tmp/gems)"
132 silent_sh "rm -rf '#{tmp}'"
133 silent_sh "gem install --install-dir='#{tmp_gems}' #{gem_filename}"
134
1ffb827 @fabiopelosin [Rakefile] Temporarily disable examples check from gem:release.
fabiopelosin authored
135 # puts "* Building examples from gem (tmp/gems)"
136 # ENV['GEM_HOME'] = ENV['GEM_PATH'] = tmp_gems
137 # ENV['PATH'] = "#{tmp_gems}/bin:#{ENV['PATH']}"
138 # ENV['FROM_GEM'] = '1'
139 # silent_sh "rake examples:build"
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
140
141 # Then release
e6438c3 @fabiopelosin [Rakefile] Allow to update the changelog during a release.
fabiopelosin authored
142 sh "git commit lib/cocoapods.rb Gemfile.lock CHANGELOG.md -m 'Release #{gem_version}'"
f4d3673 @alloy Add a few more checks to gem:release task.
alloy authored
143 sh "git tag -a #{gem_version} -m 'Release #{gem_version}'"
144 sh "git push origin master"
145 sh "git push origin --tags"
146 sh "gem push #{gem_filename}"
743207e @fabiopelosin [Rake] Update CocoaPods-version.yml on release.
fabiopelosin authored
147
148 # Update the last version in CocoaPods-version.yml
9203daf @fabiopelosin [Rakefile] Cosmetics.
fabiopelosin authored
149 puts "* Updating last known version in Specs repo"
eede812 @fabiopelosin [Repo] Use master branch of specs repo.
fabiopelosin authored
150 specs_branch = 'master'
4036b66 @fabiopelosin [LocalPod] Specs and fix all_specs_public_header_files.
fabiopelosin authored
151 Dir.chdir('../Specs') do
743207e @fabiopelosin [Rake] Update CocoaPods-version.yml on release.
fabiopelosin authored
152 puts Dir.pwd
153 sh "git checkout #{specs_branch}"
154 sh "git pull"
155
156 yaml_file = 'CocoaPods-version.yml'
157 unless File.exist?(yaml_file)
158 $stderr.puts "[!] Unable to find #{yaml_file}!"
159 exit 1
160 end
94155a8 @alloy Another gem:release fix.
alloy authored
161 require 'yaml'
743207e @fabiopelosin [Rake] Update CocoaPods-version.yml on release.
fabiopelosin authored
162 cocoapods_version = YAML.load_file(yaml_file)
163 cocoapods_version['last'] = gem_version
164 File.open(yaml_file, "w") do |f|
165 f.write(cocoapods_version.to_yaml)
166 end
167
168 sh "git commit #{yaml_file} -m 'CocoaPods release #{gem_version}'"
169 sh "git push"
170 end
ad82764 @alloy Add gem:release task.
alloy authored
171 end
60caa66 @alloy Fix bug that would copy Pods.xcodeproj dir into existing one.
alloy authored
172 end
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
173
174 namespace :spec do
e5ea947 @alloy Shuffle spec files on each run and make them green on Travis.
alloy authored
175 def specs(dir)
176 FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
177 end
178
97840d4 @alloy Remove Guard dependencies. Use `rake spec:kick` for auto-test-running.
alloy authored
179 desc "Automatically run specs for updated files"
180 task :kick do
181 exec "bundle exec kicker -c"
182 end
183
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
184 desc "Run the unit specs"
14f4afb @lukeredpath Make sure we unpack the fixture tarballs before running specs, as this c...
lukeredpath authored
185 task :unit => :unpack_fixture_tarballs do
d66e82a @alloy Make sure to use bundler for rake tasks that run bacon.
alloy authored
186 sh "bundle exec bacon #{specs('unit/**')} -q"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
187 end
188
189 desc "Run the functional specs"
23692ea @alloy Instead of removing the VCR cache, namespace the cache by Ruby version.
alloy authored
190 task :functional => :unpack_fixture_tarballs do
d66e82a @alloy Make sure to use bundler for rake tasks that run bacon.
alloy authored
191 sh "bundle exec bacon #{specs('functional/**')}"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
192 end
193
194 desc "Run the integration spec"
23692ea @alloy Instead of removing the VCR cache, namespace the cache by Ruby version.
alloy authored
195 task :integration => :unpack_fixture_tarballs do
d66e82a @alloy Make sure to use bundler for rake tasks that run bacon.
alloy authored
196 sh "bundle exec bacon spec/integration_spec.rb"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
197 end
198
23692ea @alloy Instead of removing the VCR cache, namespace the cache by Ruby version.
alloy authored
199 task :all => :unpack_fixture_tarballs do
d66e82a @alloy Make sure to use bundler for rake tasks that run bacon.
alloy authored
200 sh "bundle exec bacon #{specs('**')}"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
201 end
0c8d53a @alloy Add Specification#platform.
alloy authored
202
eafb301 @alloy Try to get Travis to run the specs.
alloy authored
203 desc "Run all specs and build all examples"
204 task :ci => :all do
205 sh "./bin/pod setup" # ensure the spec repo is up-to-date
206 Rake::Task['examples:build'].invoke
207 end
208
0c8d53a @alloy Add Specification#platform.
alloy authored
209 desc "Rebuild all the fixture tarballs"
210 task :rebuild_fixture_tarballs do
211 tarballs = FileList['spec/fixtures/**/*.tar.gz']
212 tarballs.each do |tarball|
213 basename = File.basename(tarball)
214 sh "cd #{File.dirname(tarball)} && rm #{basename} && tar -zcf #{basename} #{basename[0..-8]}"
215 end
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers to i...
alloy authored
216 end
743207e @fabiopelosin [Rake] Update CocoaPods-version.yml on release.
fabiopelosin authored
217
1ca552a @lukeredpath Unpack the fixture tarballs on Travis as they are being used.
lukeredpath authored
218 desc "Unpacks all the fixture tarballs"
219 task :unpack_fixture_tarballs do
220 tarballs = FileList['spec/fixtures/**/*.tar.gz']
221 tarballs.each do |tarball|
222 basename = File.basename(tarball)
223 Dir.chdir(File.dirname(tarball)) do
224 sh "rm -rf #{basename[0..-8]} && tar zxf #{basename}"
225 end
226 end
227 end
4e4fc7f @alloy Update for latest Xcodeproj.
alloy authored
228
229 desc "Removes the stored VCR fixture"
230 task :clean_vcr do
231 sh "rm -f spec/fixtures/vcr/tarballs.yml"
232 end
233
234 task :clean_env => [:clean_vcr, :unpack_fixture_tarballs, "ext:cleanbuild"]
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers to i...
alloy authored
235 end
236
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
237 namespace :examples do
238 def examples
239 require 'pathname'
240 result = []
241 examples = Pathname.new(File.expand_path('../examples', __FILE__))
7d9479c @alloy Allow the use of the Rake FileList class for source_files, clean_paths, ...
alloy authored
242 return [examples + ENV['example']] if ENV['example']
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
243 examples.entries.each do |example|
244 next if %w{ . .. }.include?(example.basename.to_s)
245 example = examples + example
246 next unless example.directory?
247 result << example
248 end
249 result
250 end
251
252 desc "Open all example workspaced in Xcode, which recreates the schemes."
253 task :recreate_workspace_schemes do
254 examples.each do |example|
255 Dir.chdir(example.to_s) do
256 # TODO we need to open the workspace in Xcode at least once, otherwise it might not contain schemes.
257 # The schemes do not seem to survive a SCM round-trip.
258 sh "open '#{example.basename}.xcworkspace'"
259 sleep 5
260 end
261 end
262 end
263
264 desc "Build all examples"
265 task :build do
a63aa89 @alloy Delete generated docs before running `rake examples:build`.
alloy authored
266 sh "rm -rf ~/Library/Developer/Shared/Documentation/DocSets/org.cocoapods.*"
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
267 examples.entries.each do |example|
268 puts "Building example: #{example}"
269 puts
270 Dir.chdir(example.to_s) do
271 sh "rm -rf Pods DerivedData"
613dbc4 @fabiopelosin [Rakefile] Don't update repos in order to speed up examples.
fabiopelosin authored
272 sh "#{'../../bin/' unless ENV['FROM_GEM']}pod install --verbose --no-update"
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
273 command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
274 if (example + 'Podfile').read.include?('platform :ios')
275 # Specifically build against the simulator SDK so we don't have to deal with code signing.
14a9efa @alloy Make the examples build with older Xcode 4 versions.
alloy authored
276 command << " -sdk "
224c72e @fabiopelosin [Rakefile] Robustness against different version of xcode.
fabiopelosin authored
277 command << Dir.glob("#{`xcode-select -print-path`.chomp}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk").last
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
278 end
279 sh command
30c8a1e @alloy Make the rake build_examples task work and use newer xcodeproj version w...
alloy authored
280 end
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some reason...
alloy authored
281 puts
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers to i...
alloy authored
282 end
0c8d53a @alloy Add Specification#platform.
alloy authored
283 end
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
284 end
285
664d0c2 @subdigital Run rake bootstrap to set up your working copy.
subdigital authored
286 desc "Initializes your working copy to run the specs"
287 task :bootstrap do
e256b49 @subdigital rake bootstrap now bundle installs
subdigital authored
288 puts "Updating submodules..."
664d0c2 @subdigital Run rake bootstrap to set up your working copy.
subdigital authored
289 `git submodule update --init --recursive`
e256b49 @subdigital rake bootstrap now bundle installs
subdigital authored
290
291 puts "Installing gems"
292 `bundle install`
664d0c2 @subdigital Run rake bootstrap to set up your working copy.
subdigital authored
293 end
294
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
295 desc "Run all specs"
296 task :spec => 'spec:all'
ef25e3f @lukeredpath Make spec the default task
lukeredpath authored
297
298 task :default => :spec
Something went wrong with that request. Please try again.