forked from RestKit/RestKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
148 lines (129 loc) · 5.16 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
require 'rubygems'
namespace :test do
desc "Run the RestKit test server"
task :server do
server_path = File.dirname(__FILE__) + '/Tests/Server/server.rb'
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 \"RestKit\" " +
"--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, min_exit_status = 0)
puts "Executing: `#{command}`"
system(command)
if $?.exitstatus > min_exit_status
puts "[!] Failed with exit code #{$?.exitstatus} while running: `#{command}`"
exit($?.exitstatus)
end
return $?.exitstatus
end
task :default => 'test:server'
desc "Build RestKit for iOS and Mac OS X"
task :build do
run("xcodebuild -workspace RestKit.xcodeproj/project.xcworkspace -scheme RestKit -sdk iphonesimulator5.0 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 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, 1)
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/"
exitstatus = run(command, 1)
if exitstatus == 0
puts "appledoc generation completed successfully!"
elsif exitstatus == 1
puts "appledoc generation produced warnings"
elsif exitstatus == 2
puts "! appledoc generation encountered an error"
exit(exitstatus)
else
puts "!! appledoc generation failed with a fatal error"
end
exit(exitstatus)
end
desc "Generate & install a docset into Xcode from the current sources"
task :install do
command = apple_doc_command << " --install-docset Code/"
run(command, 1)
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 --verbose 3 Code/"
run(command, 1)
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 $?.exitstatus == 0
command = "rsync -rvpPe ssh Docs/API/publish/ restkit.org:/var/www/public/restkit.org/public/api/"
run(command)
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 Test server listening on port 4567. Run `rake test:server` and try again."
exit(-1)
end
end
namespace :build do
desc "Build all Example projects to ensure they are building properly"
task :examples do
ios_sdks = %w{iphoneos iphonesimulator5.0}
osx_sdks = %w{macosx}
osx_projects = %w{RKMacOSX}
examples_path = File.join(File.expand_path(File.dirname(__FILE__)), 'Examples')
example_projects = `find #{examples_path} -name '*.xcodeproj'`.split("\n")
puts "Building #{example_projects.size} Example projects..."
example_projects.each do |example_project|
project_name = File.basename(example_project).gsub('.xcodeproj', '')
sdks = osx_projects.include?(project_name) ? osx_sdks : ios_sdks
sdks.each do |sdk|
puts "Building '#{example_project}' with SDK #{sdk}..."
scheme = project_name
run("xcodebuild -workspace #{example_project}/project.xcworkspace -scheme #{scheme} -sdk #{sdk} clean build")
#run("xcodebuild -project #{example_project} -alltargets -sdk #{sdk} clean build")
end
end
end
end
desc "Validate a branch is ready for merging by checking for common issues"
task :validate => [:ensure_server_is_running, :build, 'docs:check', 'uispec:all'] do
puts "Project state validated successfully. Proceed with merge."
end