Skip to content

Commit

Permalink
add ci file and script to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmairoldi committed Dec 29, 2015
1 parent c8b2cb5 commit cdb8b07
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
osx_image: xcode7.2
language: objective-c

env:
global:
- LANG=en_US.UTF-8

cache:
- bundler

before_install:
- brew update
- brew install carthage
- carthage bootstrap

script:
- rake test

# after_success:
# - bash <(curl -s https://codecov.io/bash)
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "rake"
gem "xcpretty"
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
rake (10.4.2)
rouge (1.10.1)
xcpretty (0.2.2)
rouge (~> 1.8)

PLATFORMS
ruby

DEPENDENCIES
rake
xcpretty

BUNDLED WITH
1.11.2
86 changes: 86 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
def type
:project # set `:project` for xcodeproj and `:workspace` for xcworkspace
end

def project_name
"Charts/Charts.xcodeproj"
end

def configuration
"Debug"
end

def test_targets
[
:ios,
# :tvos #no tvOS fbsnapshot
]
end

def schemes
{
ios: 'Charts-iOS',
tvos: 'Charts-TV'
}
end

def sdks
{
ios: 'iphonesimulator',
osx: 'macosx',
tvos: 'appletvsimulator'
}
end

def devices
{
ios: "name='iPhone 6s'",
osx: "arch='x86_64'",
tvos: "name='Apple TV 1080p'"
}
end

def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcprety_args: '')

# set either workspace or project flag for xcodebuild
case type
when :project
project_type = "-project"
when :workspace
project_type = "-workspace"
else
abort "Invalid project type, use `:project` for xcodeproj and `:workspace` for xcworkspace."
end

sh "set -o pipefail && xcodebuild #{project_type} '#{name}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination #{destination} #{tasks} | xcpretty -c #{xcprety_args}"

end

def execute(tasks, platform, xcprety_args)

# platform specific settings
sdk = sdks[platform]
scheme = schemes[platform]
destination = devices[platform]

# check if xcodebuild needs to be run on multiple devices
if destination.respond_to?('map')
destination.map do |destination|
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
end
else
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
end

end

desc 'Build, then run tests.'
task :test do

test_targets.map do |platform|
execute 'build test', platform, xcprety_args: '--test'
end

sh "killall Simulator"

end

0 comments on commit cdb8b07

Please sign in to comment.