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
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# StencilSwiftKit

[![Build Status](https://travis-ci.org/SwiftGen/StencilSwiftKit.svg?branch=master)](https://travis-ci.org/SwiftGen/StencilSwiftKit)
[![CircleCI](https://circleci.com/gh/SwiftGen/StencilSwiftKit/tree/master.svg?style=svg)](https://circleci.com/gh/SwiftGen/StencilSwiftKit/tree/master)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/StencilSwiftKit.svg)](https://img.shields.io/cocoapods/v/StencilSwiftKit.svg)
[![Platform](https://img.shields.io/cocoapods/p/StencilSwiftKit.svg?style=flat)](http://cocoadocs.org/docsets/StencilSwiftKit)
![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg)
Expand Down
45 changes: 34 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
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

desc 'Run Unit Tests'
task :test => :build_for_testing do
sh "swift test"
xcpretty "xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests test-without-building"
namespace :spm do
desc 'Build using SPM'
task :build do
plain("swift build", "spm_build")
end

desc 'Run SPM Unit Tests'
task :test => :build do
plain("swift test", "spm_build")
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the name param be spm_test there instead of spm_build (especially to avoid the risk of overriding the log output from build)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried using a ruby trick to get the calling method's name, but keep getting block (2 levels) in <top (required)>, so gave up on that.

Copy link
Contributor

@AliSoftware AliSoftware Feb 19, 2017

Choose a reason for hiding this comment

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

You could do that by capturing the 1st argument passed to the block, which is the rake task object itself, and has a .name property:

namespace :foo do
  task :bar do |task|
    puts "Name: #{task.name}" // task.name is indeed "foo:bar"
  end
end

end
end

namespace :xcode do
desc 'Build using Xcode'
task :build do
xcpretty("xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing", "xcode_build")
end

desc 'Run Xcode Unit Tests'
task :test => :build do
xcpretty("xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests test-without-building", "xcode_test")
end
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"
17 changes: 17 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
machine:
xcode:
version: 8.2

dependencies:
pre:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- if [[ $CIRCLE_BRANCH == master ]]; then pod setup; fi
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be converted to the "download_from_s3" trick

Copy link
Member Author

Choose a reason for hiding this comment

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

Jup, added it while you were typing 😆

cache_directories:
- "~/.cocoapods/repos/master"
Copy link
Contributor

Choose a reason for hiding this comment

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

@djbe Well I think we still need to change that pod setup + cache_directories strategy to use what @dantoml told us about in Slack, to improve that part before consider merging.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I meant with input from @dantoml 😄


test:
override:
- rake xcode:test
- rake spm:test
post:
- if [[ $CIRCLE_BRANCH == master ]]; then rake lint; fi