-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
153 lines (132 loc) · 4.98 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
require 'rubygems'
begin
gem 'uispecrunner'
require 'uispecrunner'
require 'uispecrunner/options'
rescue LoadError => error
puts "Unable to load UISpecRunner: #{error}"
end
namespace :uispec do
desc "Run all specs"
task :all do
options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
uispec_runner = UISpecRunner.new(options)
uispec_runner.run_all!
end
desc "Run all unit specs (those that implement UISpecUnit)"
task :units do
options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
uispec_runner = UISpecRunner.new(options)
uispec_runner.run_protocol!('UISpecUnit')
end
desc "Run all integration specs (those that implement UISpecIntegration)"
task :integration do
options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
uispec_runner = UISpecRunner.new(options)
uispec_runner.run_protocol!('UISpecIntegration')
end
desc "Run the Spec server via Shotgun"
task :server do
server_path = File.dirname(__FILE__) + '/Specs/Server/server.rb'
#system("shotgun --port 4567 #{server_path}")
system("ruby #{server_path}")
end
end
def restkit_version
@restkit_version ||= ENV['VERSION'] || File.read("VERSION").chomp
end
def apple_doc_command
"Vendor/appledoc/appledoc -t Vendor/appledoc/Templates -o Docs/API -p RestKit -v #{restkit_version} -c \"Two Toasters\" " +
"--company-id org.restkit --warn-undocumented-object --warn-undocumented-member --warn-empty-description --warn-unknown-directive " +
"--warn-invalid-crossref --warn-missing-arg --no-repeat-first-par "
end
def run(command)
puts "Executing: `#{command}`"
system(command)
if $?.exitstatus != 0
puts "[!] Failed with exit code #{$?.exitstatus} while running: `#{command}`"
exit($?.exitstatus)
end
end
desc "Run all specs"
task :default => 'uispec:all'
desc "Build RestKit for iOS and Mac OS X"
task :build do
run("xcodebuild -workspace RestKit.xcodeproj/project.xcworkspace -scheme RestKit -sdk iphonesimulator3.2 clean build")
run("xcodebuild -workspace RestKit.xcodeproj/project.xcworkspace -scheme RestKit -sdk iphoneos clean build")
run("xcodebuild -workspace RestKit.xcodeproj/project.xcworkspace -scheme RestKit -sdk macosx10.6 clean build")
run("xcodebuild -workspace RestKit.xcodeproj/project.xcworkspace -scheme RestKitThree20 -sdk iphoneos clean build")
run("xcodebuild -workspace Examples/RKCatalog/RKCatalog.xcodeproj/project.xcworkspace -scheme RKCatalog -sdk iphoneos clean build")
end
desc "Generate documentation via appledoc"
task :docs => 'docs:generate'
namespace :docs do
task :generate do
command = apple_doc_command << " --no-create-docset --keep-intermediate-files --create-html Code/"
run(command)
puts "Generated HTML documentationa at Docs/API/html"
end
desc "Check that documentation can be built from the source code via appledoc successfully."
task :check do
command = apple_doc_command << " --no-create-html --verbose 5 Code/"
run(command)
if $? != 0
puts "Documentation failed to generate with exit code #{$?}"
exit($?)
else
puts "Documentation processing with appledoc was successful."
end
end
desc "Generate & install a docset into Xcode from the current sources"
task :install do
command = apple_doc_command << " --install-docset Code/"
run(command)
end
desc "Build and upload the documentation set to the remote server"
task :upload do
version = ENV['VERSION'] || File.read("VERSION").chomp
puts "Generating RestKit docset for version #{version}..."
command = apple_doc_command <<
" --keep-intermediate-files" <<
" --docset-feed-name \"RestKit #{version} Documentation\"" <<
" --docset-feed-url http://restkit.org/api/%DOCSETATOMFILENAME" <<
" --docset-package-url http://restkit.org/api/%DOCSETPACKAGEFILENAME --publish-docset Code/"
run(command)
if $? == 0
puts "Uploading docset to restkit.org..."
command = "rsync -rvpPe ssh --delete Docs/API/html/ restkit.org:/var/www/public/restkit.org/public/api/#{version}"
run(command)
if $? == 0
command = "rsync -rvpPe ssh Docs/API/publish/ restkit.org:/var/www/public/restkit.org/public/api/"
run(command)
end
end
end
end
def is_port_open?(ip, port)
require 'socket'
require 'timeout'
begin
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
s.close
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
end
rescue Timeout::Error
end
return false
end
task :ensure_server_is_running do
unless is_port_open?('127.0.0.1', 4567)
puts "Unable to find RestKit Specs server listening on port 4567. Run `rake uispec:server` and try again."
exit(-1)
end
end
desc "Validate a branch is ready for merging by checking for common issues"
task :validate => [:build, 'docs:check', :ensure_server_is_running, 'uispec:all'] do
puts "All tests passed OK. Proceed with merge."
end