Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Circle CI #20

Merged
merged 16 commits into from
Feb 24, 2017
39 changes: 28 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
def xcpretty(cmd)
if `which xcpretty` && $?.success?
def xcpretty(cmd, name)
if ENV['CI']
sh "set -o pipefail && #{cmd} | tee \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\" | xcpretty --color --report junit --output \"#{ENV['CIRCLE_TEST_REPORTS']}/xcode/#{name}.xml\""
elsif `which xcpretty` && $?.success?
sh "set -o pipefail && #{cmd} | xcpretty -c"
else
sh cmd
end
end

task :build_for_testing do
sh "swift build"
xcpretty "xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing"
def plain(cmd, name)
if ENV['CI']
sh "set -o pipefail && #{cmd} | tee \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\""
else
sh cmd
end
end

task :spm_build do
plain("swift build", "spm_build")
end

task :xcode_build do
xcpretty("xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing", "xcode_build")
end

desc 'Run Xcode Unit Tests'
task :xcode_test => :xcode_build do
xcpretty("xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests test-without-building", "xcode_test")
end

desc 'Run Unit Tests'
task :test => :build_for_testing do
sh "swift test"
xcpretty "xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests test-without-building"
desc 'Run SPM Unit Tests'
task :spm_test => :spm_build do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: you can use take namespaces to group relative tasks together.

A namespace 'spm' do … end and a namespace 'xcodebuild' do … end would be nicer to read, and then you can name your tasks just build and test and refer to them as rake spm:test etc.

plain("swift test", "spm_build")
end

desc 'Lint the Pod'
task :lint do
sh "pod lib lint StencilSwiftKit.podspec --quick"
plain("pod lib lint StencilSwiftKit.podspec --quick", "lint")
end

task :default => :test
task :default => :xcode_test
10 changes: 2 additions & 8 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ dependencies:

test:
override:
- set -o pipefail
- swift test | tee $CIRCLE_ARTIFACTS/spm_test_raw.log
- xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing build-for-testing |
tee $CIRCLE_ARTIFACTS/xcode_build_raw.log |
xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/build.xml
- xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing test-without-building |
tee $CIRCLE_ARTIFACTS/xcode_test_raw.log |
xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/test.xml
- rake xcode_test
- rake spm_test
post:
- if [[ $CIRCLE_BRANCH == master ]]; then rake lint; fi