-
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
Conversation
2ac219c
to
dff7b4b
Compare
dff7b4b
to
f0939f9
Compare
We should create the Rakefle for each repo before starting to adjust the circle.yml files: it would be more readable for |
Sure, but we should add versions depending on environment. If CI, output logs to |
Rakefile
Outdated
sh "swift test" | ||
xcpretty "xcodebuild -workspace StencilSwiftKit.xcworkspace -scheme Tests test-without-building" | ||
desc 'Run SPM Unit Tests' | ||
task :spm_test => :spm_build do |
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.
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.
782c800
to
15c5f60
Compare
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.
👌
Only missing thing is a review from Danielle and we're good to go. Edit: well that, and switch the github configuration to require circle builds instead of travis. |
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.
TODO: Improve CP setup caching
circle.yml
Outdated
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet | ||
- if [[ $CIRCLE_BRANCH == master ]]; then pod setup; fi | ||
cache_directories: | ||
- "~/.cocoapods/repos/master" |
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.
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.
That's what I meant with input from @dantoml 😄
Rakefile
Outdated
|
||
desc 'Run SPM Unit Tests' | ||
task :test => :build do | ||
plain("swift test", "spm_build") |
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.
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)?
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.
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.
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.
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
08a440b
to
703c749
Compare
1317734
to
011f3a3
Compare
278fb85
to
d25548d
Compare
d25548d
to
68c23f0
Compare
Rakefile
Outdated
desc 'Lint the code' | ||
task :code do |task| | ||
plain("PROJECT_DIR=. ./Scripts/swiftlint-code.sh", task) | ||
end |
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 have rake swiftlint:install
, rake swiftlint:sourcecode
and rake swiftlint:tests
tasks? (and then concerning the pod lib lint
, not sure it's worth having a dedicated rake task?)
@@ -0,0 +1,30 @@ | |||
{ | |||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "804E0A642F9B0288E24EC6843BD9BD71D8BD7EA7", |
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.
I never know if this file should be pushed on git, I see it being ignored by a lot of .gitignored on OSS projects and I generally gitignore it too, I think because otherwise it gets updated almost on every commit… I believe it's only useful for Xcode to have metadata about the repo, but who uses Xcode's integrated SCM tool anyway
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.
Huh, I thought I deleted that. Must be in another branch
func testRender() { | ||
|
||
func testRender() throws { |
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.
I didn't even know XCTest would still recognize functions as tests when they are marked with throws
, I thought only func test<Whatever>()
functions with this exact signature type would be recognized! (wait, that test actually does get executed, right?)
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.
I saw it as a little know trick recently related to XCTest, maybe one of Natasha's newsletters or something? Can't remember.
Anyway, the test still gets executed, during testing it just has a different name (AndReturnError:
gets appended): [Tests.CallNodeTests testRenderAndReturnError:]
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.
👍
"\(lhsNum)\n" + | ||
"======\n" + | ||
"\(rhsNum)\n" + | ||
"<<<<<< expected" |
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.
I think an array of strings that gets join
'd is more efficient that successive string concatenation… and compiles faster (because +
is so overloaded) too
circle.yml
Outdated
@@ -5,13 +5,15 @@ machine: | |||
dependencies: | |||
pre: | |||
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet | |||
- Scripts/install_swiftlint.sh | |||
- if [[ $CIRCLE_BRANCH == master ]]; then pod setup; fi |
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.
This needs to be converted to the "download_from_s3" trick
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.
Jup, added it while you were typing 😆
circle.yml
Outdated
- rake xcode:test | ||
- rake spm:test | ||
post: | ||
- if [[ $CIRCLE_BRANCH == master ]]; then rake lint; fi | ||
- if [[ $CIRCLE_BRANCH == master ]]; then rake lint:pod; fi |
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.
Other alternative: [[ $CIRCLE_BRANCH == master ]] && rake lint:pod
(which would actually be [[ $CIRCLE_BRANCH == master ]] && pod lib lint --quick
if we take the pod lint out of the Rakefile).
I have no real preference, just saying in case you prefer &&
over if; then; fi
db5de2c
to
8837c49
Compare
@@ -42,7 +45,14 @@ func diff(_ result: String, _ expected: String) -> String? { | |||
} | |||
let lhsNum = addLineNumbers(slice(lhsLines, 4)).joined(separator: "\n") | |||
let rhsNum = addLineNumbers(slice(rhsLines, 4)).joined(separator: "\n") | |||
return "\(msgColor)Mismatch at line \(badLineIdx)\(reset)\n>>>>>> result\n\(lhsNum)\n======\n\(rhsNum)\n<<<<<< expected" | |||
return [ | |||
"\(msgColor)Mismatch at line \(badLineIdx)\(reset)\n", |
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.
Extra \n
(which should be added by the join
: is it intentional (so that it ends up with two \n for this line and thus a blank line in the result) or not?
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.
No, not intentional
8837c49
to
97e78a3
Compare
How do we merge this PR? The github configuration'll need to be changed to require circle tests instead of travis before we can merge it. |
Done :) |
Note: Once this is merged, don't forget to: