-
Notifications
You must be signed in to change notification settings - Fork 58
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
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2a9da2d
test
djbe a42fade
remove travis
djbe d2f5c1e
try caching cocoapods
djbe f0939f9
store output to designated circle paths
djbe 4ee70bf
rewrite rakefile to output circle artefacts on CI
djbe 15c5f60
namespace commands
djbe 18262e8
switch status image from travis to circle
djbe 703c749
small fix
djbe 011f3a3
get name from task
djbe e124d1e
code linting
djbe 10fa112
fix swift lint issues
djbe 68c23f0
use pod specs from S3
djbe 1539a66
use join instead of +
djbe 283e7e3
move swiftlint scripts into rakefile
djbe 10d9a3e
delete and ignore useless xcode file
djbe 97e78a3
forgot to update circle.yml
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 was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,57 @@ | ||
def xcpretty(cmd) | ||
if `which xcpretty` && $?.success? | ||
def xcpretty(cmd, task) | ||
name = task.name.gsub(/:/,"_") | ||
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, 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 'Lint the Pod' | ||
task :pod do |task| | ||
plain("pod lib lint StencilSwiftKit.podspec --quick", task) | ||
end | ||
|
||
desc 'Lint the code' | ||
task :code do |task| | ||
plain("PROJECT_DIR=. ./Scripts/swiftlint-code.sh", task) | ||
end | ||
end | ||
|
||
task :default => :test | ||
task :default => "xcode:test" |
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,25 @@ | ||
#!/bin/bash | ||
|
||
# Installs the SwiftLint package. | ||
# Tries to get the precompiled .pkg file from Github, but if that | ||
# fails just recompiles from source. | ||
# | ||
# Original script: https://alexplescan.com/posts/2016/03/03/setting-up-swiftlint-on-travis-ci/ | ||
|
||
set -e | ||
|
||
SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg" | ||
SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.16.1/SwiftLint.pkg" | ||
|
||
curl -Lo $SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL | ||
|
||
if [ -f $SWIFTLINT_PKG_PATH ]; then | ||
echo "SwiftLint package exists! Installing it..." | ||
sudo installer -pkg $SWIFTLINT_PKG_PATH -target / | ||
else | ||
echo "SwiftLint package doesn't exist. Compiling from source..." && | ||
git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint && | ||
cd /tmp/SwiftLint && | ||
git submodule update --init --recursive && | ||
sudo make install | ||
fi |
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,10 @@ | ||
if which swiftlint >/dev/null; then | ||
RESULT=0 | ||
|
||
swiftlint lint --no-cache --strict --path "${PROJECT_DIR}/Sources" || { RESULT=1; } | ||
swiftlint lint --no-cache --strict --path "${PROJECT_DIR}/Tests/StencilSwiftKitTests" || { RESULT=1; } | ||
|
||
exit $RESULT | ||
else | ||
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" | ||
fi |
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
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.
Just a thought: I'm not sure about the readability/logic of grouping those two commands, still undecided.
Because "linting a pod" and "linting the code" seems two different kinds of lints to me. One is checking that the podspec "compiles" (the podspec file doesn't have any syntax error, and that a project with that pod would compile), the other is checking for code style issues.
Maybe it would be more logical to put everything related to SwiftLint in the Rakefile anyway (I mean instead of having separate
.sh
scripts to install swiftlint and lint the code — which were there at first because we didn't have any Rakefile or because we found this install_swiftlint script as is) and haverake swiftlint:install
,rake swiftlint:sourcecode
andrake swiftlint:tests
tasks? (and then concerning thepod lib lint
, not sure it's worth having a dedicated rake task?)