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
Merged

Configure Circle CI #20

merged 16 commits into from
Feb 24, 2017

Conversation

djbe
Copy link
Member

@djbe djbe commented Feb 15, 2017

Note: Once this is merged, don't forget to:

  • Adapt the GitHub settings of this repo to make circle the mandatory status check instead of travis

@djbe djbe force-pushed the feature/circleci branch 3 times, most recently from 2ac219c to dff7b4b Compare February 15, 2017 23:22
@AliSoftware
Copy link
Contributor

AliSoftware commented Feb 19, 2017

We should create the Rakefle for each repo before starting to adjust the circle.yml files: it would be more readable for circle.yml to invoke rake test than the whole xcodebuild command

@djbe
Copy link
Member Author

djbe commented Feb 19, 2017

Sure, but we should add versions depending on environment. If CI, output logs to $CIRCLE_ARTIFACTS and $CIRCLE_TEST_REPORTS. Also each rake task should be separate, so we can eventually parallelize stuff.

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
Copy link
Contributor

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.

Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

👌

@djbe
Copy link
Member Author

djbe commented Feb 19, 2017

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.

Copy link
Contributor

@AliSoftware AliSoftware left a 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"
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 😄

Rakefile Outdated

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

Rakefile Outdated
desc 'Lint the code'
task :code do |task|
plain("PROJECT_DIR=. ./Scripts/swiftlint-code.sh", task)
end
Copy link
Contributor

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",
Copy link
Contributor

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

Copy link
Member Author

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 {
Copy link
Contributor

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?)

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 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:]

Copy link
Contributor

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"
Copy link
Contributor

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
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 😆

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
Copy link
Contributor

@AliSoftware AliSoftware Feb 23, 2017

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

@@ -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",
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, not intentional ☹️

@djbe
Copy link
Member Author

djbe commented Feb 24, 2017

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.

@AliSoftware
Copy link
Contributor

Done :)

@AliSoftware AliSoftware merged commit a336166 into master Feb 24, 2017
@AliSoftware AliSoftware deleted the feature/circleci branch February 24, 2017 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants