Skip to content

Commit

Permalink
Configure Circle CI (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe authored and AliSoftware committed Feb 24, 2017
1 parent 8095d3c commit a336166
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 248 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ xcuserdata/
## Other
*.moved-aside
*.xcuserstate
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
Expand Down
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

26 changes: 13 additions & 13 deletions Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
80 changes: 67 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,79 @@
def xcpretty(cmd)
if `which xcpretty` && $?.success?
def xcpretty(cmd, task)
name = task.name.gsub(/:/,"_")
xcpretty = `which xcpretty`

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 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, task)
name = task.name.gsub(/:/,"_")
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 |task|
plain("swift build", task)
end

desc 'Run SPM Unit Tests'
task :test => :build do |task|
plain("swift test", task)
end
end

desc 'Lint the Pod'
task :lint do
sh "pod lib lint StencilSwiftKit.podspec --quick"
namespace :xcode do
desc 'Build using Xcode'
task :build do |task|
xcpretty("xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests build-for-testing", task)
end

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

namespace :lint do
desc 'Install swiftlint'
task :install do |task|
swiftlint = `which swiftlint`

if !(swiftlint && $?.success?)
url = 'https://github.com/realm/SwiftLint/releases/download/0.16.1/SwiftLint.pkg'
tmppath = '/tmp/SwiftLint.pkg'

plain("curl -Lo #{tmppath} #{url}", task)
plain("sudo installer -pkg #{tmppath} -target /", task)
end
end

desc 'Lint the code'
task :code => :install do |task|
plain("swiftlint lint --no-cache --strict --path Sources", task)
end

desc 'Lint the tests'
task :tests => :install do |task|
plain("swiftlint lint --no-cache --strict --path Tests/StencilSwiftKitTests", task)
end
end

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

task :default => :test
task :default => "xcode:test"
8 changes: 5 additions & 3 deletions Sources/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public enum StencilContext {
- Parameter parameters: List of strings, will be parsed using the `Parameters.parse(items:)` method
- Parameter environment: Environment variables, defaults to `ProcessInfo().environment`
*/
public static func enrich(context: [String: Any], parameters: [String], environment: [String: String] = ProcessInfo().environment) throws -> [String: Any] {
public static func enrich(context: [String: Any],
parameters: [String],
environment: [String: String] = ProcessInfo().environment) throws -> [String: Any] {
var context = context

context[StencilContext.environment] = environment
context[StencilContext.parameters] = try Parameters.parse(items: parameters)

return context
}
}
2 changes: 1 addition & 1 deletion Sources/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public extension Extension {
public func stencilSwiftEnvironment() -> Environment {
let ext = Extension()
ext.registerStencilSwiftExtensions()

return Environment(extensions: [ext], templateClass: StencilSwiftTemplate.self)
}
10 changes: 8 additions & 2 deletions Sources/Filters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ struct StringFilters {
let camelCased = try NSRegularExpression(pattern: "([a-z\\d])([A-Z])", options: .dotMatchesLineSeparators)

let fullRange = NSRange(location: 0, length: string.unicodeScalars.count)
var result = longUpper.stringByReplacingMatches(in: string, options: .reportCompletion, range: fullRange, withTemplate: "$1_$2")
result = camelCased.stringByReplacingMatches(in: result, options: .reportCompletion, range: fullRange, withTemplate: "$1_$2")
var result = longUpper.stringByReplacingMatches(in: string,
options: .reportCompletion,
range: fullRange,
withTemplate: "$1_$2")
result = camelCased.stringByReplacingMatches(in: result,
options: .reportCompletion,
range: fullRange,
withTemplate: "$1_$2")
return result.replacingOccurrences(of: "-", with: "_")
}
}
Expand Down
Loading

0 comments on commit a336166

Please sign in to comment.