xcjobs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,422 @@
1
+ require 'spec_helper'
2
+
3
+ describe XCJobs::Xcodebuild do
4
+ before(:each) do
5
+ @commands = []
6
+
7
+ allow_any_instance_of(FileUtils).to receive(:sh) do |object, command|
8
+ @commands << command
9
+ end
10
+
11
+ allow_any_instance_of(XCJobs::Xcodebuild).to receive(:run) do |object, command|
12
+ @commands << command.join(' ')
13
+ end
14
+
15
+ Rake.application = rake
16
+ end
17
+
18
+ let(:rake) { Rake::Application.new }
19
+
20
+ let(:destinations) do
21
+ ['name=iPhone 6,OS=8.1', 'name=iPhone 6 Plus,OS=8.1', 'name=iPad 2,OS=7.1', 'name=iPad Air,OS=8.1']
22
+ end
23
+
24
+ describe XCJobs::Test do
25
+ context 'when a scheme is not specified' do
26
+ subject do
27
+ XCJobs::Test.new do |t|
28
+ t.project = 'Example.xcodeproj'
29
+ end
30
+ end
31
+
32
+ it 'fails' do
33
+ expect { subject }.to raise_error(RuntimeError, 'test action requires specifying a scheme')
34
+ end
35
+ end
36
+
37
+ context 'when both scheme and targets specified' do
38
+ subject do
39
+ XCJobs::Test.new do |t|
40
+ t.project = 'Example.xcodeproj'
41
+ t.scheme = 'Example'
42
+ t.target = 'Example'
43
+ end
44
+ end
45
+
46
+ it 'fails' do
47
+ expect { subject.invoke }.to raise_error(RuntimeError, 'cannot specify both a scheme and targets')
48
+ end
49
+ end
50
+
51
+ describe 'test project with simulator' do
52
+ let!(:task) do
53
+ XCJobs::Test.new do |t|
54
+ t.project = 'Example.xcodeproj'
55
+ t.scheme = 'Example'
56
+ t.configuration = 'Debug'
57
+ destinations.each do |destination|
58
+ t.add_destination(destination)
59
+ end
60
+ end
61
+ end
62
+
63
+ it 'configures the project' do
64
+ expect(task.project).to eq 'Example.xcodeproj'
65
+ end
66
+
67
+ it 'configures the scheme' do
68
+ expect(task.scheme).to eq 'Example'
69
+ end
70
+
71
+ it 'configures the build configuration' do
72
+ expect(task.configuration).to eq 'Debug'
73
+ end
74
+
75
+ describe 'tasks' do
76
+ describe 'test' do
77
+ subject { Rake.application['test'] }
78
+
79
+ it 'executes the appropriate commands' do
80
+ subject.invoke
81
+ expect(@commands).to eq ['xcodebuild test -project Example.xcodeproj -scheme Example -sdk iphonesimulator -configuration Debug -destination name=iPhone 6,OS=8.1 -destination name=iPhone 6 Plus,OS=8.1 -destination name=iPad 2,OS=7.1 -destination name=iPad Air,OS=8.1 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO GCC_SYMBOLS_PRIVATE_EXTERN=NO']
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ describe 'test workspace with simulator' do
88
+ let!(:task) do
89
+ XCJobs::Test.new do |t|
90
+ t.workspace = 'Example.xcworkspace'
91
+ t.scheme = 'Example'
92
+ t.configuration = 'Debug'
93
+ destinations.each do |destination|
94
+ t.add_destination(destination)
95
+ end
96
+ end
97
+ end
98
+
99
+ it 'configures the workspace' do
100
+ expect(task.workspace).to eq 'Example.xcworkspace'
101
+ end
102
+
103
+ it 'configures the scheme' do
104
+ expect(task.scheme).to eq 'Example'
105
+ end
106
+
107
+ it 'configures the build configuration' do
108
+ expect(task.configuration).to eq 'Debug'
109
+ end
110
+
111
+ it 'configures destinations' do
112
+ expect(task.destinations).to eq destinations
113
+ end
114
+
115
+ describe 'tasks' do
116
+ describe 'test' do
117
+ subject { Rake.application['test'] }
118
+
119
+ it 'executes the appropriate commands' do
120
+ subject.invoke
121
+ expect(@commands).to eq ['xcodebuild test -workspace Example.xcworkspace -scheme Example -sdk iphonesimulator -configuration Debug -destination name=iPhone 6,OS=8.1 -destination name=iPhone 6 Plus,OS=8.1 -destination name=iPad 2,OS=7.1 -destination name=iPad Air,OS=8.1 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO GCC_SYMBOLS_PRIVATE_EXTERN=NO']
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ describe 'test project with device' do
128
+ let(:destination) { 'platform=iOS,id=8d18c8c4d1a6988ac4a70d370bfcbe99fef3f7b5' }
129
+
130
+ let!(:task) do
131
+ XCJobs::Test.new do |t|
132
+ t.project = 'Example.xcodeproj'
133
+ t.scheme = 'Example'
134
+ t.configuration = 'Debug'
135
+ t.sdk = 'iphoneos'
136
+ t.add_destination(destination)
137
+ end
138
+ end
139
+
140
+ it 'configures the project' do
141
+ expect(task.project).to eq 'Example.xcodeproj'
142
+ end
143
+
144
+ it 'configures the scheme' do
145
+ expect(task.scheme).to eq 'Example'
146
+ end
147
+
148
+ it 'configures the build configuration' do
149
+ expect(task.configuration).to eq 'Debug'
150
+ end
151
+
152
+ it 'configures the sdk' do
153
+ expect(task.sdk).to eq 'iphoneos'
154
+ end
155
+
156
+ it 'configures destinations' do
157
+ expect(task.destinations).to eq [destination]
158
+ end
159
+
160
+ describe 'tasks' do
161
+ describe 'test' do
162
+ subject { Rake.application['test'] }
163
+
164
+ it 'executes the appropriate commands' do
165
+ subject.invoke
166
+ expect(@commands).to eq ['xcodebuild test -project Example.xcodeproj -scheme Example -sdk iphoneos -configuration Debug -destination platform=iOS,id=8d18c8c4d1a6988ac4a70d370bfcbe99fef3f7b5']
167
+ end
168
+ end
169
+ end
170
+ end
171
+ end
172
+
173
+ describe XCJobs::Build do
174
+ context 'when specifying build_dir' do
175
+ subject do
176
+ XCJobs::Build.new do |t|
177
+ t.project = 'Example.xcodeproj'
178
+ t.build_dir = 'build'
179
+ end
180
+ end
181
+
182
+ it 'fails' do
183
+ expect { subject }.to raise_error(RuntimeError, 'the scheme is required when specifying build_dir')
184
+ end
185
+ end
186
+
187
+ context 'when both scheme and targets specified' do
188
+ subject do
189
+ XCJobs::Build.new do |t|
190
+ t.project = 'Example.xcodeproj'
191
+ t.scheme = 'Example'
192
+ t.target = 'Example'
193
+ end
194
+ end
195
+
196
+ it 'fails' do
197
+ expect { subject.invoke }.to raise_error(RuntimeError, 'cannot specify both a scheme and targets')
198
+ end
199
+ end
200
+
201
+ describe 'simple task with a project' do
202
+ let!(:task) do
203
+ XCJobs::Build.new do |t|
204
+ t.project = 'Example.xcodeproj'
205
+ t.target = 'Example'
206
+ t.configuration = 'Release'
207
+ end
208
+ end
209
+
210
+ it 'configures the project' do
211
+ expect(task.project).to eq 'Example.xcodeproj'
212
+ end
213
+
214
+ it 'configures the target' do
215
+ expect(task.target).to eq 'Example'
216
+ end
217
+
218
+ it 'configures the build configuration' do
219
+ expect(task.configuration).to eq 'Release'
220
+ end
221
+
222
+ describe 'tasks' do
223
+ describe 'build' do
224
+ subject { Rake.application['build'] }
225
+
226
+ it 'executes the appropriate commands' do
227
+ subject.invoke
228
+ expect(@commands).to eq ['xcodebuild build -project Example.xcodeproj -target Example -configuration Release']
229
+ end
230
+ end
231
+ end
232
+ end
233
+
234
+ describe 'simple task with a workspace' do
235
+ let(:signing_identity) { 'iPhone Developer: Katsumi Kishikawa (9NXEJ2L8Q6)' }
236
+
237
+ let!(:task) do
238
+ XCJobs::Build.new do |t|
239
+ t.workspace = 'Example.xcworkspace'
240
+ t.scheme = 'Example'
241
+ t.configuration = 'Debug'
242
+ t.signing_identity = signing_identity
243
+ unless ENV['CI']
244
+ t.provisioning_profile = './spec/profiles/development.mobileprovision'
245
+ end
246
+ t.build_dir = 'build'
247
+ end
248
+ end
249
+
250
+ it 'configures the workspace' do
251
+ expect(task.workspace).to eq 'Example.xcworkspace'
252
+ end
253
+
254
+ it 'configures the scheme' do
255
+ expect(task.scheme).to eq 'Example'
256
+ end
257
+
258
+ it 'configures the build configuration' do
259
+ expect(task.configuration).to eq 'Debug'
260
+ end
261
+
262
+ it 'configures the code signing identity' do
263
+ expect(task.signing_identity).to eq signing_identity
264
+ end
265
+
266
+ it 'configures the build directory' do
267
+ expect(task.build_dir).to eq('build')
268
+ end
269
+
270
+ describe 'tasks' do
271
+ describe 'build' do
272
+ subject { Rake.application['build'] }
273
+
274
+ it 'executes the appropriate commands' do
275
+ subject.invoke
276
+ if ENV['CI']
277
+ expect(@commands).to eq ['xcodebuild build -workspace Example.xcworkspace -scheme Example -configuration Debug -derivedDataPath build CONFIGURATION_TEMP_DIR=build/temp CODE_SIGN_IDENTITY=iPhone Developer: Katsumi Kishikawa (9NXEJ2L8Q6)']
278
+ else
279
+ expect(@commands).to eq ['xcodebuild build -workspace Example.xcworkspace -scheme Example -configuration Debug -derivedDataPath build CONFIGURATION_TEMP_DIR=build/temp CODE_SIGN_IDENTITY=iPhone Developer: Katsumi Kishikawa (9NXEJ2L8Q6) PROVISIONING_PROFILE=a55e7d27-6196-4994-ab9d-871d5d56b3fd']
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ describe XCJobs::Archive do
288
+ context 'when a scheme is not specified' do
289
+ subject do
290
+ XCJobs::Archive.new do |t|
291
+ t.project = 'Example.xcodeproj'
292
+ end
293
+ end
294
+
295
+ it 'fails' do
296
+ expect { subject }.to raise_error(RuntimeError, 'archive action requires specifying a scheme')
297
+ end
298
+ end
299
+
300
+ context 'when both scheme and targets specified' do
301
+ subject do
302
+ XCJobs::Archive.new do |t|
303
+ t.project = 'Example.xcodeproj'
304
+ t.scheme = 'Example'
305
+ t.target = 'Example'
306
+ end
307
+ end
308
+
309
+ it 'fails' do
310
+ expect { subject.invoke }.to raise_error(RuntimeError, 'cannot specify both a scheme and targets')
311
+ end
312
+ end
313
+
314
+ describe 'simple task with a project' do
315
+ let!(:task) do
316
+ XCJobs::Archive.new do |t|
317
+ t.project = 'Example.xcodeproj'
318
+ t.scheme = 'Example'
319
+ t.configuration = 'Release'
320
+ t.build_dir = 'build'
321
+ end
322
+ end
323
+
324
+ it 'configures the project' do
325
+ expect(task.project).to eq 'Example.xcodeproj'
326
+ end
327
+
328
+ it 'configures the target' do
329
+ expect(task.scheme).to eq 'Example'
330
+ end
331
+
332
+ it 'configures the build configuration' do
333
+ expect(task.configuration).to eq 'Release'
334
+ end
335
+
336
+ describe 'tasks' do
337
+ describe 'build:archive' do
338
+ subject { Rake.application['build:archive'] }
339
+
340
+ it 'executes the appropriate commands' do
341
+ subject.invoke
342
+ expect(@commands).to eq [ 'xcodebuild archive -project Example.xcodeproj -scheme Example -configuration Release -derivedDataPath build CONFIGURATION_TEMP_DIR=build/temp -archivePath build/Example',
343
+ '(cd "build"; zip -ryq "dSYMs.zip" Example.xcarchive/dSYMs)',
344
+ '(cd "build"; zip -ryq Example.xcarchive.zip Example.xcarchive)',
345
+ ]
346
+ end
347
+ end
348
+ end
349
+ end
350
+
351
+ describe 'archive task with a workspace' do
352
+ let!(:task) do
353
+ XCJobs::Archive.new do |t|
354
+ t.workspace = 'Example.xcworkspace'
355
+ t.scheme = 'Example'
356
+ t.configuration = 'Release'
357
+ t.signing_identity = 'iPhone Distribution: kishikawa katsumi'
358
+ unless ENV['CI']
359
+ t.provisioning_profile = 'spec/profiles/distribution.mobileprovision'
360
+ end
361
+ t.build_dir = 'build'
362
+ end
363
+ end
364
+
365
+ it 'configures the workspace' do
366
+ expect(task.workspace).to eq('Example.xcworkspace')
367
+ end
368
+
369
+ it 'configures the scheme' do
370
+ expect(task.scheme).to eq('Example')
371
+ end
372
+
373
+ it 'configures the build configuration' do
374
+ expect(task.configuration).to eq('Release')
375
+ end
376
+
377
+ it 'configures the code signing identity' do
378
+ expect(task.signing_identity).to eq('iPhone Distribution: kishikawa katsumi')
379
+ end
380
+
381
+ unless ENV['CI']
382
+ it 'configures the provisioning profile' do
383
+ expect(task.provisioning_profile).to eq('spec/profiles/distribution.mobileprovision')
384
+ end
385
+
386
+ it 'configures the provisioning profile name' do
387
+ expect(task.provisioning_profile_name).to eq('Distribution Provisioning Profile')
388
+ end
389
+
390
+ it 'configures the provisioning profile UUID' do
391
+ expect(task.provisioning_profile_uuid).to eq('5d09b88d-ff09-43aa-a6fd-3907f98fe467')
392
+ end
393
+ end
394
+
395
+ it 'configures the build directory' do
396
+ expect(task.build_dir).to eq('build')
397
+ end
398
+
399
+ describe 'tasks' do
400
+ describe 'build:archive' do
401
+ subject { Rake.application['build:archive'] }
402
+
403
+ it 'executes the appropriate commands' do
404
+ subject.invoke
405
+
406
+ if ENV['CI']
407
+ expect(@commands).to eq [ 'xcodebuild archive -workspace Example.xcworkspace -scheme Example -configuration Release -derivedDataPath build CONFIGURATION_TEMP_DIR=build/temp CODE_SIGN_IDENTITY=iPhone Distribution: kishikawa katsumi -archivePath build/Example',
408
+ '(cd "build"; zip -ryq "dSYMs.zip" Example.xcarchive/dSYMs)',
409
+ '(cd "build"; zip -ryq Example.xcarchive.zip Example.xcarchive)',
410
+ ]
411
+ else
412
+ expect(@commands).to eq [ 'xcodebuild archive -workspace Example.xcworkspace -scheme Example -configuration Release -derivedDataPath build CONFIGURATION_TEMP_DIR=build/temp CODE_SIGN_IDENTITY=iPhone Distribution: kishikawa katsumi PROVISIONING_PROFILE=5d09b88d-ff09-43aa-a6fd-3907f98fe467 -archivePath build/Example',
413
+ '(cd "build"; zip -ryq "dSYMs.zip" Example.xcarchive/dSYMs)',
414
+ '(cd "build"; zip -ryq Example.xcarchive.zip Example.xcarchive)',
415
+ ]
416
+ end
417
+ end
418
+ end
419
+ end
420
+ end
421
+ end
422
+ end
data/xcjobs.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xcjobs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xcjobs"
8
+ spec.version = XCJobs::VERSION
9
+ spec.authors = ["kishikawa katsumi"]
10
+ spec.email = ["kishikawakatsumi@mac.com"]
11
+ spec.summary = %q{Support the automation of release process of iOS/OSX apps with CI}
12
+ spec.description = %q{Provides rake tasks for Xcode build}
13
+ spec.homepage = "http://github.com/kishikawakatsumi/xcjobs"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcjobs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kishikawa katsumi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides rake tasks for Xcode build
70
+ email:
71
+ - kishikawakatsumi@mac.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - lib/xcjobs.rb
84
+ - lib/xcjobs/certificate.rb
85
+ - lib/xcjobs/distribute.rb
86
+ - lib/xcjobs/infoplist.rb
87
+ - lib/xcjobs/version.rb
88
+ - lib/xcjobs/xcodebuild.rb
89
+ - spec/certificate_spec.rb
90
+ - spec/distribute_spec.rb
91
+ - spec/profiles/adhoc.mobileprovision
92
+ - spec/profiles/development.mobileprovision
93
+ - spec/profiles/distribution.mobileprovision
94
+ - spec/spec_helper.rb
95
+ - spec/xcjobs_spec.rb
96
+ - spec/xcodebuild_spec.rb
97
+ - xcjobs.gemspec
98
+ homepage: http://github.com/kishikawakatsumi/xcjobs
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Support the automation of release process of iOS/OSX apps with CI
122
+ test_files:
123
+ - spec/certificate_spec.rb
124
+ - spec/distribute_spec.rb
125
+ - spec/profiles/adhoc.mobileprovision
126
+ - spec/profiles/development.mobileprovision
127
+ - spec/profiles/distribution.mobileprovision
128
+ - spec/spec_helper.rb
129
+ - spec/xcjobs_spec.rb
130
+ - spec/xcodebuild_spec.rb