Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix testflight

  • Loading branch information...
commit 5b3c3868d4edd499f13281feb50ff4ed1bbc936b 1 parent e63526e
@rayh authored
View
2  lib/xcode/builder.rb
@@ -1,7 +1,7 @@
require 'xcode/shell'
require 'xcode/provisioning_profile'
require 'xcode/test/parsers/ocunit_parser.rb'
-require 'xcode/testflight'
+require 'xcode/deploy/testflight'
require 'xcode/builder/base_builder.rb'
require 'xcode/builder/project_target_config_builder.rb'
require 'xcode/builder/scheme_builder.rb'
View
12 lib/xcode/builder/base_builder.rb
@@ -78,11 +78,19 @@ def test(options = {:sdk => 'iphonesimulator'}) #, :parser => :OCUnit })
report
end
+ #
+ # Upload to testflight
+ #
+ # The testflight object is yielded so further configuration can be performed before uploading
+ #
+ # @param api_token the API token for your testflight account
+ # @param team_token the token for the team you want to deploy to
+ #
def testflight(api_token, team_token)
raise "Can't find #{ipa_path}, do you need to call builder.package?" unless File.exists? ipa_path
- raise "Can't fins #{dsym_zip_path}, do you need to call builder.package?" unless File.exists? dsym_zip_path
+ raise "Can't find #{dsym_zip_path}, do you need to call builder.package?" unless File.exists? dsym_zip_path
- testflight = Xcode::Testflight.new(api_token, team_token)
+ testflight = Xcode::Deploy::Testflight.new(api_token, team_token)
yield(testflight) if block_given?
testflight.upload(ipa_path, dsym_zip_path)
end
View
60 lib/xcode/deploy/testflight.rb
@@ -0,0 +1,60 @@
+require 'rest-client'
+require 'json'
+
+module Xcode
+ module Deploy
+ class Testflight
+ attr_accessor :api_token, :team_token, :notify, :proxy, :notes, :lists
+
+ def initialize(api_token, team_token)
+ @api_token = api_token
+ @team_token = team_token
+ @notify = true
+ @notes = nil
+ @lists = []
+ @proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
+ end
+
+ def upload(ipa_path, dsymzip_path=nil)
+ puts "Uploading to Testflight..."
+
+ # RestClient.proxy = @proxy || ENV['http_proxy'] || ENV['HTTP_PROXY']
+ # RestClient.log = '/tmp/restclient.log'
+ #
+ # response = RestClient.post('http://testflightapp.com/api/builds.json',
+ # :file => File.new(ipa_path),
+ # :dsym => File.new(dsymzip_path),
+ # :api_token => @api_token,
+ # :team_token => @team_token,
+ # :notes => @notes,
+ # :notify => @notify ? 'True' : 'False',
+ # :distribution_lists => @lists.join(',')
+ # )
+ #
+ # json = JSON.parse(response)
+ # puts " + Done, got: #{json.inspect}"
+ # json
+
+ cmd = Xcode::Shell::Command.new 'curl'
+ cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy==''
+ cmd << "-X POST http://testflightapp.com/api/builds.json"
+ cmd << "-F file=@\"#{ipa_path}\""
+ cmd << "-F dsym=@\"#{dsymzip_path}\"" unless dsymzip_path.nil?
+ cmd << "-F api_token='#{@api_token}'"
+ cmd << "-F team_token='#{@team_token}'"
+ cmd << "-F notes=\"#{@notes}\"" unless @notes.nil?
+ cmd << "-F notify=#{@notify ? 'True' : 'False'}"
+ cmd << "-F distribution_lists='#{@lists.join(',')}'" unless @lists.count==0
+
+ response = Xcode::Shell.execute(cmd)
+
+ json = JSON.parse(response.join(''))
+ puts " + Done, got: #{json.inspect}"
+
+ yield(json) if block_given?
+
+ json
+ end
+ end
+ end
+end
View
4 lib/xcode/shell.rb
@@ -5,9 +5,9 @@ module Shell
class ExecutionError < StandardError; end
- def self.execute(bits, show_output=true)
+ def self.execute(cmd, show_output=true)
out = []
- cmd = bits.is_a?(Xcode::Shell::Command) ? bits.to_s : bits
+ cmd = cmd.to_s
puts "EXECUTE: #{cmd}"
IO.popen (cmd) do |f|
View
2  lib/xcode/shell/command.rb
@@ -3,7 +3,7 @@
module Xcode
module Shell
class Command
- attr_accessor :env
+ attr_accessor :env, :cmd, :args
def initialize(cmd, environment={})
@cmd = cmd
View
59 lib/xcode/testflight.rb
@@ -1,59 +0,0 @@
-require 'rest-client'
-require 'json'
-
-module Xcode
- class Testflight
- attr_accessor :api_token, :team_token, :notify, :proxy, :notes, :lists
-
- def initialize(api_token, team_token)
- @api_token = api_token
- @team_token = team_token
- @notify = true
- @notes = nil
- @lists = []
- @proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
- end
-
- def upload(ipa_path, dsymzip_path=nil)
- puts "Uploading to Testflight..."
-
- # RestClient.proxy = @proxy || ENV['http_proxy'] || ENV['HTTP_PROXY']
- # RestClient.log = '/tmp/restclient.log'
- #
- # response = RestClient.post('http://testflightapp.com/api/builds.json',
- # :file => File.new(ipa_path),
- # :dsym => File.new(dsymzip_path),
- # :api_token => @api_token,
- # :team_token => @team_token,
- # :notes => @notes,
- # :notify => @notify ? 'True' : 'False',
- # :distribution_lists => @lists.join(',')
- # )
- #
- # json = JSON.parse(response)
- # puts " + Done, got: #{json.inspect}"
- # json
-
- cmd = []
- cmd << 'curl'
- cmd << "--proxy #{@proxy}" unless @proxy.nil? or @proxy==''
- cmd << "-X POST http://testflightapp.com/api/builds.json"
- cmd << "-F file=@\"#{ipa_path}\""
- cmd << "-F dsym=@\"#{dsymzip_path}\"" unless dsymzip_path.nil?
- cmd << "-F api_token='#{@api_token}'"
- cmd << "-F team_token='#{@team_token}'"
- cmd << "-F notes=\"#{@notes}\"" unless @notes.nil?
- cmd << "-F notify=#{@notify ? 'True' : 'False'}"
- cmd << "-F distribution_lists='#{@lists.join(',')}'" unless @lists.count==0
-
- response = Xcode::Shell.execute(cmd)
-
- json = JSON.parse(response.join(''))
- puts " + Done, got: #{json.inspect}"
-
- yield(json) if block_given?
-
- json
- end
- end
-end
View
29 spec/builder_spec.rb
@@ -46,30 +46,31 @@
describe "#testflight" do
- let(:testflight_parameters) do
- ['curl',
- "--proxy http://proxyhost:8080",
- "-X POST http://testflightapp.com/api/builds.json",
- "-F file=@\"#{subject.ipa_path}\"",
- "-F dsym=@\"#{subject.dsym_zip_path}\"",
- "-F api_token='api_token'",
- "-F team_token='team_token'",
- "-F notes=\"some notes\"",
- "-F notify=True",
- "-F distribution_lists='List1,List2'"]
- end
+ # let(:testflight_parameters) do
+ # ['curl',
+ # "--proxy http://proxyhost:8080",
+ # "-X POST http://testflightapp.com/api/builds.json",
+ # "-F file=@\"#{subject.ipa_path}\"",
+ # "-F dsym=@\"#{subject.dsym_zip_path}\"",
+ # "-F api_token='api_token'",
+ # "-F team_token='team_token'",
+ # "-F notes=\"some notes\"",
+ # "-F notify=True",
+ # "-F distribution_lists='List1,List2'"]
+ # end
it "should upload ipa and dsym to testflight" do
subject.build.package
- Xcode::Shell.should_receive(:execute).with(testflight_parameters).and_return(['{}'])
- subject.testflight("api_token", "team_token") do |tf|
+ result = subject.testflight("api_token", "team_token") do |tf|
+ tf.should_receive(:upload).with(subject.ipa_path, subject.dsym_zip_path).and_return('result')
tf.proxy = "http://proxyhost:8080"
tf.notes = "some notes"
tf.lists << "List1"
tf.lists << "List2"
end
+ result.should == 'result'
end
end
View
27 spec/deploy_testflight_spec.rb
@@ -0,0 +1,27 @@
+require_relative 'spec_helper'
+
+describe Xcode::Deploy::Testflight do
+
+ let(:testflight) { Xcode::Deploy::Testflight.new 'api token', 'team token' }
+
+ it "should be configured with api and team token" do
+ testflight.api_token.should == 'api token'
+ testflight.team_token.should == 'team token'
+ end
+
+ it "should call curl with correct bulld paths" do
+ Xcode::Shell.should_receive(:execute) do |arg|
+ arg.is_a? Xcode::Shell::Command
+ arg.cmd.should == 'curl'
+ arg.args.should include('-F file=@"ipa path"')
+ arg.args.should include('-F dsym=@"dsym path"')
+ arg.args.should include("-F api_token='api token'")
+ arg.args.should include("-F team_token='team token'")
+
+ ['{"response":"ok"}']
+ end
+ response = testflight.upload('ipa path', 'dsym path')
+ response['response'].should == 'ok'
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.