Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 197 lines (171 sloc) 6.076 kB
2fb6ae6 @alloy Hmm, chicken and egg problem on Travis, copy travis:setup task from X…
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
15 sh "sudo apt-get install subversion libicu-dev"
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
24 base_url = "https://github.com/downloads/CocoaPods/OpenCFLite"
25 %w{ opencflite1_248-1_i386.deb opencflite-dev_248-1_i386.deb }.each do |deb|
26 sh "wget #{File.join(base_url, deb)}" unless File.exist?(deb)
27 end
28 sh "sudo dpkg -i *.deb"
29 end
30 end
31
32 task :fix_rvm_include_dir do
33 unless File.exist?(File.join(rvm_ruby_dir, 'include'))
34 # Make Ruby headers available, RVM seems to do not create a include dir on 1.8.7, but it does on 1.9.3.
35 sh "mkdir '#{rvm_ruby_dir}/include'"
36 sh "ln -s '#{rvm_ruby_dir}/lib/ruby/1.8/i686-linux' '#{rvm_ruby_dir}/include/ruby'"
37 end
38 end
39
40 task :setup => [:install_opencflite_debs, :fix_rvm_include_dir]
41 end
42
ad82764 @alloy Add gem:release task.
alloy authored
43 namespace :gem do
44 def gem_version
579c1a7 @lukeredpath Allow specifications to have a local source that exists outside the P…
lukeredpath authored
45 require File.join(File.dirname(__FILE__), *%w[lib cocoapods])
ad82764 @alloy Add gem:release task.
alloy authored
46 Pod::VERSION
47 end
48
49 def gem_filename
2fe42a1 @alloy Fix Rakefile gem tasks
alloy authored
50 "cocoapods-#{gem_version}.gem"
ad82764 @alloy Add gem:release task.
alloy authored
51 end
52
53 desc "Build a gem for the current version"
54 task :build do
55 sh "gem build cocoapods.gemspec"
56 end
57
58 desc "Install a gem version of the current code"
59 task :install => :build do
579c1a7 @lukeredpath Allow specifications to have a local source that exists outside the P…
lukeredpath authored
60 sh "sudo gem install #{gem_filename}"
ad82764 @alloy Add gem:release task.
alloy authored
61 end
62
b4cf71f @alloy Probably a good idea to run at least the specs as well before releasing.
alloy authored
63 desc "Run all specs, build and install gem, commit version change, tag version change, and push everything"
ad82764 @alloy Add gem:release task.
alloy authored
64 task :release do
65 puts "You are about to release `#{gem_version}', is that correct? [y/n]"
66 exit if STDIN.gets.strip.downcase != 'y'
67 lines = `git diff --numstat`.strip.split("\n")
68 if lines.size == 0
69 puts "Change the version number yourself in lib/cocoapods.rb"
70 elsif lines.size == 1 && lines.first.include?('lib/cocoapods.rb')
b4cf71f @alloy Probably a good idea to run at least the specs as well before releasing.
alloy authored
71 # First see if the specs pass and gem builds and installs
72 Rake::Task['spec:all'].invoke
ad82764 @alloy Add gem:release task.
alloy authored
73 Rake::Task['gem:install'].invoke
74 # Then release
9428428 @alloy Print the commands that are executed during gem:release.
alloy authored
75 sh "git commit lib/cocoapods.rb -m 'Release #{gem_version}'"
76 sh "git tag -a #{gem_version} -m 'Release #{gem_version}'"
77 sh "git push origin master"
78 sh "git push --tags"
79 sh "gem push #{gem_filename}"
ad82764 @alloy Add gem:release task.
alloy authored
80 else
81 puts "Only change the version number in a release commit!"
82 end
83 end
60caa66 @alloy Fix bug that would copy Pods.xcodeproj dir into existing one.
alloy authored
84 end
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
85
86 namespace :spec do
e5ea947 @alloy Shuffle spec files on each run and make them green on Travis.
alloy authored
87 def specs(dir)
88 FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
89 end
90
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
91 desc "Run the unit specs"
14f4afb @lukeredpath Make sure we unpack the fixture tarballs before running specs, as thi…
lukeredpath authored
92 task :unit => :unpack_fixture_tarballs do
e5ea947 @alloy Shuffle spec files on each run and make them green on Travis.
alloy authored
93 sh "bacon #{specs('unit/**')} -q"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
94 end
95
96 desc "Run the functional specs"
d3bd298 @alloy The VCR fixture differs between Ruby versions, so clean it.
alloy authored
97 task :functional => :clean_env do
e5ea947 @alloy Shuffle spec files on each run and make them green on Travis.
alloy authored
98 sh "bacon #{specs('functional/**')}"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
99 end
100
101 desc "Run the integration spec"
d3bd298 @alloy The VCR fixture differs between Ruby versions, so clean it.
alloy authored
102 task :integration => :clean_env do
c821caa @alloy Make the specs run on MRI 1.9.3
alloy authored
103 sh "bacon spec/integration_spec.rb"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
104 end
105
d3bd298 @alloy The VCR fixture differs between Ruby versions, so clean it.
alloy authored
106 task :all => :clean_env do
e5ea947 @alloy Shuffle spec files on each run and make them green on Travis.
alloy authored
107 sh "bacon #{specs('**')}"
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
108 end
0c8d53a @alloy Add Specification#platform.
alloy authored
109
eafb301 @alloy Try to get Travis to run the specs.
alloy authored
110 desc "Run all specs and build all examples"
111 task :ci => :all do
112 sh "./bin/pod setup" # ensure the spec repo is up-to-date
113 Rake::Task['examples:build'].invoke
114 end
115
0c8d53a @alloy Add Specification#platform.
alloy authored
116 desc "Rebuild all the fixture tarballs"
117 task :rebuild_fixture_tarballs do
118 tarballs = FileList['spec/fixtures/**/*.tar.gz']
119 tarballs.each do |tarball|
120 basename = File.basename(tarball)
121 sh "cd #{File.dirname(tarball)} && rm #{basename} && tar -zcf #{basename} #{basename[0..-8]}"
122 end
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers t…
alloy authored
123 end
1ca552a @lukeredpath Unpack the fixture tarballs on Travis as they are being used.
lukeredpath authored
124
125 desc "Unpacks all the fixture tarballs"
126 task :unpack_fixture_tarballs do
127 tarballs = FileList['spec/fixtures/**/*.tar.gz']
128 tarballs.each do |tarball|
129 basename = File.basename(tarball)
130 Dir.chdir(File.dirname(tarball)) do
131 sh "rm -rf #{basename[0..-8]} && tar zxf #{basename}"
132 end
133 end
134 end
d3bd298 @alloy The VCR fixture differs between Ruby versions, so clean it.
alloy authored
135
136 desc "Removes the stored VCR fixture"
137 task :clean_vcr do
138 sh "rm -f spec/fixtures/vcr/tarballs.yml"
139 end
140
c8ce61f @alloy Replace Xcodeproj git submodule by adding it to the Gemfile. Closes #…
alloy authored
141 task :clean_env => [:clean_vcr, :unpack_fixture_tarballs]
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers t…
alloy authored
142 end
143
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some rea…
alloy authored
144 namespace :examples do
145 def examples
146 require 'pathname'
147 result = []
148 examples = Pathname.new(File.expand_path('../examples', __FILE__))
7d9479c @alloy Allow the use of the Rake FileList class for source_files, clean_path…
alloy authored
149 return [examples + ENV['example']] if ENV['example']
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some rea…
alloy authored
150 examples.entries.each do |example|
151 next if %w{ . .. }.include?(example.basename.to_s)
152 example = examples + example
153 next unless example.directory?
154 result << example
155 end
156 result
157 end
158
159 desc "Open all example workspaced in Xcode, which recreates the schemes."
160 task :recreate_workspace_schemes do
161 examples.each do |example|
162 Dir.chdir(example.to_s) do
163 # TODO we need to open the workspace in Xcode at least once, otherwise it might not contain schemes.
164 # The schemes do not seem to survive a SCM round-trip.
165 sh "open '#{example.basename}.xcworkspace'"
166 sleep 5
167 end
168 end
169 end
170
171 desc "Build all examples"
172 task :build do
173 examples.entries.each do |example|
174 puts "Building example: #{example}"
175 puts
176 Dir.chdir(example.to_s) do
177 sh "rm -rf Pods DerivedData"
178 sh "#{'../../bin/' unless ENV['FROM_GEM']}pod install --verbose"
179 command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
180 if (example + 'Podfile').read.include?('platform :ios')
181 # 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
182 command << " -sdk "
183 command << "/Applications/Xcode.app/Contents" if File.exist?("/Applications/Xcode.app")
184 command << "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk"
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some rea…
alloy authored
185 end
186 sh command
30c8a1e @alloy Make the rake build_examples task work and use newer xcodeproj versio…
alloy authored
187 end
aba658e @alloy Add a rake task to open all example workspaces in Xcode. For some rea…
alloy authored
188 puts
159dd1f @alloy Make the AFNetworking Mac Example work. Fix bug that caused headers t…
alloy authored
189 end
0c8d53a @alloy Add Specification#platform.
alloy authored
190 end
5d87894 @alloy Add a few rake tasks to run the specs.
alloy authored
191 end
192
193 desc "Run all specs"
194 task :spec => 'spec:all'
ef25e3f @lukeredpath Make spec the default task
lukeredpath authored
195
196 task :default => :spec
Something went wrong with that request. Please try again.