Skip to content

Commit

Permalink
Add linux job on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Jul 16, 2018
1 parent 3fb9bd4 commit 51163a2
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 10 deletions.
39 changes: 31 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults:
- &default-config
- &macos-config
parallelism: 1
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
Expand All @@ -8,6 +8,14 @@ defaults:
macos:
xcode: "9.3.0"
shell: /bin/bash --login -eo pipefail
- &linux-config
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
BUNDLE_PATH: vendor/bundle
docker:
- image: norionomura/jazzy:swift-4.1.2
shell: /bin/bash --login -eo pipefail
- &prepare-storage
run:
name: Create directories for artifacts and reports
Expand Down Expand Up @@ -41,7 +49,7 @@ defaults:
version: 2
jobs:
lint:
<<: *default-config
<<: *macos-config
steps:
- *prepare-storage
- checkout
Expand All @@ -57,7 +65,7 @@ jobs:
- *store-artifacts

xcode-build-and-test:
<<: *default-config
<<: *macos-config
steps:
- *prepare-storage
- checkout
Expand All @@ -72,8 +80,21 @@ jobs:
- *fetch-xcode-logs
- *store-artifacts

spm-build-and-test:
<<: *default-config
spm-linux-build-and-test:
<<: *linux-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Run all tests
command: bundle exec rake spm:test
- *store-artifacts

spm-mac-build-and-test:
<<: *macos-config
steps:
- *prepare-storage
- checkout
Expand All @@ -86,7 +107,7 @@ jobs:
- *store-artifacts

check-deploy:
<<: *default-config
<<: *macos-config
steps:
- *prepare-storage
- checkout
Expand All @@ -107,10 +128,12 @@ workflows:
lint-buildandtest-checkdeploy:
jobs:
- lint
- spm-build-and-test
- spm-linux-build-and-test
- spm-mac-build-and-test
- xcode-build-and-test
- check-deploy:
requires:
- lint
- spm-build-and-test
- spm-linux-build-and-test
- spm-mac-build-and-test
- xcode-build-and-test
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ line_length:
nesting:
type_level:
warning: 2

# Exclude generated files
excluded:
- Tests/StencilSwiftKitTests/XCTestManifests.swift
8 changes: 8 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import XCTest

import StencilSwiftKitTests

var tests = [XCTestCaseEntry]()
tests += StencilSwiftKitTests.__allTests()

XCTMain(tests)
181 changes: 181 additions & 0 deletions Tests/StencilSwiftKitTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import XCTest

extension CallNodeTests {
static let __allTests = [
("testParser", testParser),
("testParserFail", testParserFail),
("testParserWithArguments", testParserWithArguments),
("testRender", testRender),
("testRenderFail", testRenderFail),
("testRenderWithParameters", testRenderWithParameters),
("testRenderWithParametersFail", testRenderWithParametersFail),
]
}

extension ContextTests {
static let __allTests = [
("testEmpty", testEmpty),
("testWithContext", testWithContext),
("testWithParameters", testWithParameters),
]
}

extension MacroNodeTests {
static let __allTests = [
("testCallableBlockContext", testCallableBlockContext),
("testCallableBlockRender", testCallableBlockRender),
("testCallableBlockWithFilterExpressionParameter", testCallableBlockWithFilterExpressionParameter),
("testContextModification", testContextModification),
("testContextModificationWithParameters", testContextModificationWithParameters),
("testParser", testParser),
("testParserFail", testParserFail),
("testParserWithParameters", testParserWithParameters),
("testRender", testRender),
("testRenderWithParameters", testRenderWithParameters),
]
}

extension MapNodeTests {
static let __allTests = [
("testContext", testContext),
("testMapLoopContext", testMapLoopContext),
("testParser", testParser),
("testParserFail", testParserFail),
("testParserWithMapVariable", testParserWithMapVariable),
("testRender", testRender),
]
}

extension ParametersTests {
static let __allTests = [
("testBasic", testBasic),
("testDeepStructured", testDeepStructured),
("testParseInvalidKey", testParseInvalidKey),
("testParseInvalidStructure", testParseInvalidStructure),
("testParseInvalidSyntax", testParseInvalidSyntax),
("testRepeated", testRepeated),
("testStructured", testStructured),
]
}

extension ParseBoolTests {
static let __allTests = [
("testParseBool_FalseWithString", testParseBool_FalseWithString),
("testParseBool_TrueWithString", testParseBool_TrueWithString),
("testParseBool_WithEmptyArrayAndRequiredArg", testParseBool_WithEmptyArrayAndRequiredArg),
("testParseBool_WithEmptyArray", testParseBool_WithEmptyArray),
("testParseBool_WithEmptyStringAndRequiredArg", testParseBool_WithEmptyStringAndRequiredArg),
("testParseBool_WithEmptyString", testParseBool_WithEmptyString),
("testParseBool_WithNonZeroIndex", testParseBool_WithNonZeroIndex),
("testParseBool_WithOptionalDouble", testParseBool_WithOptionalDouble),
("testParseBool_WithOptionalInt", testParseBool_WithOptionalInt),
("testParseBool_WithRequiredDouble", testParseBool_WithRequiredDouble),
("testParseBool_WithRequiredInt", testParseBool_WithRequiredInt),
]
}

extension ParseEnumTests {
static let __allTests = [
("testParseEnum_WithBarString", testParseEnum_WithBarString),
("testParseEnum_WithBazString", testParseEnum_WithBazString),
("testParseEnum_WithEmptyArray", testParseEnum_WithEmptyArray),
("testParseEnum_WithFooString", testParseEnum_WithFooString),
("testParseEnum_WithNonZeroIndex", testParseEnum_WithNonZeroIndex),
("testParseEnum_WithUnknownArgument", testParseEnum_WithUnknownArgument),
]
}

extension ParseStringTests {
static let __allTests = [
("testParseString_FromValue_WithNil", testParseString_FromValue_WithNil),
("testParseString_FromValue_WithNonStringConvertableArgument", testParseString_FromValue_WithNonStringConvertableArgument),
("testParseString_FromValue_WithNSStringValue", testParseString_FromValue_WithNSStringValue),
("testParseString_FromValue_WithStringConvertableArgument", testParseString_FromValue_WithStringConvertableArgument),
("testParseString_FromValue_WithStringLosslessConvertableArgument", testParseString_FromValue_WithStringLosslessConvertableArgument),
("testParseString_FromValue_WithStringValue", testParseString_FromValue_WithStringValue),
("testParseStringArgument_WithEmptyArray", testParseStringArgument_WithEmptyArray),
("testParseStringArgument_WithNonStringConvertableArgument", testParseStringArgument_WithNonStringConvertableArgument),
("testParseStringArgument_WithNonZeroIndex", testParseStringArgument_WithNonZeroIndex),
("testParseStringArgument_WithStringArgument", testParseStringArgument_WithStringArgument),
("testParseStringArgument_WithStringConvertableArgument", testParseStringArgument_WithStringConvertableArgument),
("testParseStringArgument_WithStringLosslessConvertableArgument", testParseStringArgument_WithStringLosslessConvertableArgument),
]
}

extension SetNodeTests {
static let __allTests = [
("testContextModification", testContextModification),
("testContextPush", testContextPush),
("testDifferenceRenderEvaluate", testDifferenceRenderEvaluate),
("testParserEvaluateMode", testParserEvaluateMode),
("testParserFail", testParserFail),
("testParserRenderMode", testParserRenderMode),
("testRender", testRender),
("testSetWithFilterExpressionParameter", testSetWithFilterExpressionParameter),
("testWithExistingContext", testWithExistingContext),
]
}

extension StringFiltersTests {
static let __allTests = [
("testBasename", testBasename),
("testCamelToSnakeCase_WithFalse", testCamelToSnakeCase_WithFalse),
("testCamelToSnakeCase_WithNoArgsDefaultsToTrue", testCamelToSnakeCase_WithNoArgsDefaultsToTrue),
("testCamelToSnakeCase_WithTrue", testCamelToSnakeCase_WithTrue),
("testContains_WithFalseResult", testContains_WithFalseResult),
("testContains_WithTrueResult", testContains_WithTrueResult),
("testDirname", testDirname),
("testEscapeReservedKeywords", testEscapeReservedKeywords),
("testHasPrefix_WithFalseResult", testHasPrefix_WithFalseResult),
("testHasPrefix_WithTrueResult", testHasPrefix_WithTrueResult),
("testHasSuffix_WithFalseResult", testHasSuffix_WithFalseResult),
("testHasSuffix_WithTrueResult", testHasSuffix_WithTrueResult),
("testLowerFirstLetter", testLowerFirstLetter),
("testLowerFirstWord", testLowerFirstWord),
("testRemoveNewlines_WithAll", testRemoveNewlines_WithAll),
("testRemoveNewlines_WithLeading", testRemoveNewlines_WithLeading),
("testRemoveNewlines_WithNoArgsDefaultsToAll", testRemoveNewlines_WithNoArgsDefaultsToAll),
("testRemoveNewlines_WithWrongArgWillThrow", testRemoveNewlines_WithWrongArgWillThrow),
("testReplace", testReplace),
("testSnakeToCamelCase_WithFalse", testSnakeToCamelCase_WithFalse),
("testSnakeToCamelCase_WithNoArgsDefaultsToFalse", testSnakeToCamelCase_WithNoArgsDefaultsToFalse),
("testSnakeToCamelCase_WithTrue", testSnakeToCamelCase_WithTrue),
("testUpperFirstLetter", testUpperFirstLetter),
]
}

extension SwiftIdentifierTests {
static let __allTests = [
("testBasicString", testBasicString),
("testBasicStringWithForbiddenChars", testBasicStringWithForbiddenChars),
("testBasicStringWithForbiddenCharsAndUnderscores", testBasicStringWithForbiddenCharsAndUnderscores),
("testEmojis", testEmojis),
("testEmojis2", testEmojis2),
("testForbiddenChars", testForbiddenChars),
("testKeepUppercaseAcronyms", testKeepUppercaseAcronyms),
("testNumbersFirst", testNumbersFirst),
("testSpecialChars", testSpecialChars),
("testSwiftIdentifier_WithNoArgsDefaultsToNormal", testSwiftIdentifier_WithNoArgsDefaultsToNormal),
("testSwiftIdentifier_WithNormal", testSwiftIdentifier_WithNormal),
("testSwiftIdentifier_WithPretty", testSwiftIdentifier_WithPretty),
("testSwiftIdentifier_WithWrongArgWillThrow", testSwiftIdentifier_WithWrongArgWillThrow),
]
}

#if !os(macOS)
public func __allTests() -> [XCTestCaseEntry] {
return [
testCase(CallNodeTests.__allTests),
testCase(ContextTests.__allTests),
testCase(MacroNodeTests.__allTests),
testCase(MapNodeTests.__allTests),
testCase(ParametersTests.__allTests),
testCase(ParseBoolTests.__allTests),
testCase(ParseEnumTests.__allTests),
testCase(ParseStringTests.__allTests),
testCase(SetNodeTests.__allTests),
testCase(StringFiltersTests.__allTests),
testCase(SwiftIdentifierTests.__allTests),
]
}
#endif
21 changes: 19 additions & 2 deletions rakelib/utils.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Utils

# run a command using xcrun and xcpretty if applicable
def self.run(command, task, subtask = '', xcrun: false, formatter: :raw)
commands = if xcrun
commands = if xcrun and OS.mac?
[*command].map { |cmd| "#{version_select} xcrun #{cmd}" }
else
[*command]
Expand Down Expand Up @@ -117,7 +117,12 @@ class Utils
command = [*cmd].join(' && ')

if ENV['CI']
Rake.sh "set -o pipefail && (#{command}) | tee \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\""
if OS.mac?
Rake.sh "set -o pipefail && (#{command}) | tee \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\""
else
# dash on linux doesn't support `set -o`
Rake.sh "#{command} > \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\" 2>&1; cat \"#{ENV['CIRCLE_ARTIFACTS']}/#{name}_raw.log\""
end
else
Rake.sh command
end
Expand Down Expand Up @@ -171,6 +176,18 @@ class Utils
private_class_method :all_xcode_versions
end

# OS detection
#
module OS
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end

def OS.linux?
OS.unix? and not OS.mac?
end
end

# Colorization support for Strings
#
class String
Expand Down

0 comments on commit 51163a2

Please sign in to comment.