This repository has been archived by the owner on Sep 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Configure CircleCI #24
Merged
Merged
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
dfa6cef
circle setup
djbe 849d079
re-add the lint and compile steps
djbe 68be4ee
use curl
djbe a19704f
Fix text diffing function + some missing lines from output files
djbe 15e5ff2
disable cache for linting
djbe 8a95f49
modules: ensure script fails if compilation fails
djbe 9bbda4f
output: ensure script fails if one of the compilation tasks fails, bu…
djbe 365e10a
lint: fail on warnings
djbe 4cfaf83
smale namespace change
djbe a99b283
move swiftlint scripts into rakefile
djbe 21050b4
split rakefile into libs per functional unit
djbe 79c46e6
changelog entry
djbe 85b1611
use xcrun with version select
djbe 3951bb8
convert output compile scripts to ruby, also compile universal output…
djbe f234ca7
refactor ouput compile script to group outputs per file
djbe 4f22d0c
print info about task
djbe 99121eb
copy changes from stencilswiftkit
djbe 0e5b506
run lint steps in xcode when not on CI
djbe 1fc63cc
move files around to match kit repos
djbe 70f0499
fix some missed lint issues
djbe d5cecdf
add changelog reset command
djbe 33b6165
add gemfile and modify rake commands where needed
djbe 0b582fa
enable/disable lint tasks automatically
djbe 9696b6b
do the same for pod, spm and output
djbe 4ff63a7
better run function parameters
djbe 54bdd30
implement feedback
djbe 42384c3
synchronize common files
djbe be24a2e
Move output compilation back into rakefile
djbe 7101348
better output
djbe c8c1d60
pod update
djbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ xcuserdata/ | |
## Other | ||
*.moved-aside | ||
*.xcuserstate | ||
*.xcscmblueprint | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
def xcpretty(cmd) | ||
if `which xcpretty` && $?.success? | ||
sh "set -o pipefail && #{cmd} | xcpretty -c" | ||
else | ||
sh cmd | ||
end | ||
end | ||
#!/usr/bin/rake | ||
|
||
task :build_for_testing do | ||
xcpretty "xcodebuild -workspace Tests/Templates.xcworkspace -scheme Tests build-for-testing" | ||
end | ||
## [ Constants ] ############################################################## | ||
|
||
desc 'Run Unit Tests' | ||
task :test => :build_for_testing do | ||
xcpretty "xcodebuild -workspace Tests/Templates.xcworkspace -scheme Tests test-without-building" | ||
end | ||
WORKSPACE = 'Tests/Templates' | ||
TARGET_NAME = 'Tests' | ||
CONFIGURATION = 'Debug' | ||
|
||
task :default => :test | ||
|
||
task :default => "xcode:test" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,3 +182,5 @@ enum StoryboardSegue { | |
case ShowPassword | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,3 +182,5 @@ enum StoryboardSegue { | |
case ShowPassword | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,3 +182,5 @@ enum StoryboardSegue { | |
case showPassword = "ShowPassword" | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,3 +182,5 @@ enum StoryboardSegue { | |
case ShowPassword | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
machine: | ||
xcode: | ||
version: 8.2 | ||
|
||
dependencies: | ||
pre: | ||
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet | ||
- rake lint:install | ||
|
||
test: | ||
override: | ||
- rake lint:tests | ||
- rake xcode:test | ||
- rake output:compile | ||
- rake lint:output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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}", | ||
"sudo installer -pkg #{tmppath} -target /" | ||
], task) | ||
end | ||
end | ||
|
||
desc 'Lint the tests' | ||
task :tests => :install do |task| | ||
print_info 'Linting the unit test code' | ||
plain(%Q(swiftlint lint --no-cache --strict --path Tests/TestSuites), task) | ||
end | ||
|
||
desc 'Lint the output' | ||
task :output => :install do |task| | ||
print_info 'Linting the template output code' | ||
plain(%Q(swiftlint lint --no-cache --strict --path Tests/Expected), task) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
MODULE_INPUT_PATH = 'Fixtures/stub-env/Modules' | ||
MODULE_OUTPUT_PATH = 'Fixtures/stub-env' | ||
SDKS = { | ||
:macosx => 'x86_64-apple-macosx10.12', | ||
:iphoneos => 'armv7s-apple-ios10.0' | ||
} | ||
TOOLCHAINS = { | ||
:swift2 => { | ||
:module_path => "#{MODULE_OUTPUT_PATH}/swift2.3", | ||
:toolchain => 'com.apple.dt.toolchain.Swift_2_3' | ||
}, | ||
:swift3 => { | ||
:module_path => "#{MODULE_OUTPUT_PATH}/swift3", | ||
:toolchain => 'com.apple.dt.toolchain.XcodeDefault' | ||
} | ||
} | ||
|
||
namespace :output do | ||
desc 'Compile modules' | ||
task :modules do |task| | ||
print_info 'Compile output modules' | ||
|
||
# macOS | ||
modules = ['PrefsWindowController'] | ||
modules.each do |m| | ||
print "Compiling module #{m}… (macos)\n" | ||
compile_module(m, :macosx, task) | ||
end | ||
|
||
# iOS | ||
modules = ['CustomSegue', 'LocationPicker', 'SlackTextViewController'] | ||
modules.each do |m| | ||
print "Compiling module #{m}… (ios)\n" | ||
compile_module(m, :iphoneos, task) | ||
end | ||
|
||
# delete swiftdoc | ||
Dir.glob("#{MODULE_OUTPUT_PATH}/*.swiftdoc").each do |f| | ||
FileUtils.rm_rf(f) | ||
end | ||
end | ||
|
||
desc 'Compile output' | ||
task :compile => :modules do |task| | ||
print_info 'Compiling template output files' | ||
|
||
exit Dir.glob('Tests/Expected/**/*.swift').map { |f| | ||
print "Compiling #{f}…\n" | ||
compile_file(f, task) | ||
}.reduce(true) { |result, status| | ||
result && status | ||
} | ||
end | ||
|
||
def compile_module(m, sdk, task) | ||
target = SDKS[sdk] | ||
subtask = File.basename(m, '.*') | ||
commands = TOOLCHAINS.map do |key, toolchain| | ||
%Q(--toolchain #{toolchain[:toolchain]} -sdk #{sdk} swiftc -emit-module "#{MODULE_INPUT_PATH}/#{m}.swift" -module-name "#{m}" -emit-module-path "#{toolchain[:module_path]}" -target "#{target}") | ||
end | ||
|
||
xcrun(commands, task, subtask) | ||
end | ||
|
||
def compile_file(f, task) | ||
if f.match('swift3') | ||
toolchain = TOOLCHAINS[:swift3] | ||
else | ||
toolchain = TOOLCHAINS[:swift2] | ||
end | ||
|
||
if f.match('iOS') | ||
sdks = [:iphoneos] | ||
elsif f.match('macOS') | ||
sdks = [:macosx] | ||
else | ||
sdks = [:iphoneos, :macosx] | ||
end | ||
|
||
commands = sdks.map do |sdk| | ||
%Q(--toolchain #{toolchain[:toolchain]} -sdk #{sdk} swiftc -parse -target #{SDKS[sdk]} -I #{toolchain[:module_path]} "#{MODULE_OUTPUT_PATH}/Definitions.swift" #{f}) | ||
end | ||
subtask = File.basename(f, '.*') | ||
|
||
begin | ||
xcrun(commands, task, subtask) | ||
return true | ||
rescue | ||
return false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# run a command, pipe output through 'xcpretty' and store the output in CI artifacts | ||
def xcpretty(cmd, task, subtask = '') | ||
name = (task.name + (subtask.empty? ? '' : "_#{subtask}")).gsub(/[:-]/, "_") | ||
command = [*cmd].join(' && ') | ||
xcpretty = `which xcpretty` | ||
|
||
if ENV['CI'] | ||
sh "set -o pipefail && (#{command}) | 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 && (#{command}) | xcpretty -c" | ||
else | ||
sh command | ||
end | ||
end | ||
|
||
# run a command and store the output in CI artifacts | ||
def plain(cmd, task, subtask = '') | ||
name = (task.name + (subtask.empty? ? '' : "_#{subtask}")).gsub(/[:-]/, "_") | ||
command = [*cmd].join(' && ') | ||
|
||
if ENV['CI'] | ||
sh "set -o pipefail && (#{command}) | tee \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\"" | ||
else | ||
sh command | ||
end | ||
end | ||
|
||
# select the xcode version we want/support | ||
def version_select | ||
xcodes = `mdfind "kMDItemCFBundleIdentifier = 'com.apple.dt.Xcode' && kMDItemVersion = '8.*'"`.chomp.split("\n") | ||
if xcodes.empty? | ||
raise "\n[!!!] You need to have Xcode 8.x to compile SwiftGen.\n\n" | ||
end | ||
|
||
# Order by version and get the latest one | ||
vers = lambda { |path| `mdls -name kMDItemVersion -raw "#{path}"` } | ||
latest_xcode_version = xcodes.sort { |p1, p2| vers.call(p1) <=> vers.call(p2) }.last | ||
%Q(DEVELOPER_DIR="#{latest_xcode_version}/Contents/Developer") | ||
end | ||
|
||
# run a command using xcrun and xcpretty if applicable | ||
def xcrun(cmd, task, subtask = '') | ||
commands = [*cmd].map { |cmd| | ||
"#{version_select} xcrun #{cmd}" | ||
} | ||
|
||
if commands.join.match('xcodebuild') | ||
xcpretty(commands, task, subtask) | ||
else | ||
plain(commands, task, subtask) | ||
end | ||
end | ||
|
||
# print an info header | ||
def print_info(str) | ||
(red,clr) = (`tput colors`.chomp.to_i >= 8) ? %W(\e[33m \e[m) : ["", ""] | ||
puts red, "== #{str.chomp} ==", clr | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remarks for
rakelib/lint.rake
rakelib/utils.rake
here than the ones in SwiftGen/SwiftGen#269 (review)