diff --git a/.ci/gemfiles/Gemfile.travis b/.ci/gemfiles/Gemfile.travis new file mode 100644 index 000000000..b9c52c2b5 --- /dev/null +++ b/.ci/gemfiles/Gemfile.travis @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'xcpretty' +gem 'xcpretty-travis-formatter' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..6a900070a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,199 @@ +language: objective-c +xcode_project: GRDB.xcodeproj + +# Disable the default Travis-CI submodule logic +# The various make commands ensure that the appropriate submodules are retrieved +git: + submodules: false + +jobs: + include: + + ########################################### + ## Test GRDB + + # Test GRDBOSX (Xcode 8.3) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBOSX (Xcode 8.3, macOS 10.12) + script: make test_framework_GRDBOSX + + ## Test GRDBOSX (Xcode 8.2) + #- stage: Test GRDB + # gemfile: .ci/gemfiles/Gemfile.travis + # osx_image: xcode8.2 + # env: + # - TID=GRDBOSX (Xcode 8.2, macOS 10.12) + # script: make test_framework_GRDBOSX + + # Test GRDBOSX (Xcode 8.1) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBOSX (Xcode 8.1, macOS 10.12) + script: make test_framework_GRDBOSX + + # Test GRDBWatchOS (Xcode 8.3) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBWatchOS (Xcode 8.3, watchOS) + script: make test_framework_GRDBWatchOS + + # Test GRDBiOS (Xcode 8.3, iOS ) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBiOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBiOS_maxTarget + + # Test GRDBiOS (Xcode 8.3, iOS )) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBiOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBiOS_minTarget + + # Test GRDBiOS (Xcode 8.1, iOS 10.1) + - stage: Test GRDB + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBiOS (Xcode 8.1, iOS 10.1) + script: make test_framework_GRDBiOS_maxTarget + + ########################################### + ## Test GRDB (Custom SQLite) + + # Test GRDBCustomSQLiteOSX (Xcode 8.3) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCustomSQLiteOSX (Xcode 8.3, macOS 10.12) + script: make test_framework_GRDBCustomSQLiteOSX + + # Test GRDBCustomSQLiteOSX (Xcode 8.1) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBCustomSQLiteOSX (Xcode 8.1, macOS 10.12) + script: make test_framework_GRDBCustomSQLiteOSX + + # Test GRDBCustomSQLiteiOS (Xcode 8.3, iOS ) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCustomSQLiteiOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBCustomSQLiteiOS_maxTarget + + # Test GRDBCustomSQLiteiOS (Xcode 8.3, iOS )) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCustomSQLiteiOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBCustomSQLiteiOS_minTarget + + # Test GRDBCustomSQLiteiOS (Xcode 8.1, iOS 10.1) + - stage: Test GRDB + Custom SQLite + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBCustomSQLiteiOS (Xcode 8.1, iOS 10.1) + script: make test_framework_GRDBCustomSQLiteiOS_maxTarget + + ########################################### + ## Test GRDB (SQLCipher) + + # Test GRDBCipherOSX (Xcode 8.3) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCipherOSX (Xcode 8.3, macOS 10.12) + script: make test_framework_GRDBCipherOSX + + # Test GRDBCipherOSX (Xcode 8.1) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBCipherOSX (Xcode 8.1, macOS 10.12) + script: make test_framework_GRDBCipherOSX + + # Test GRDBCipheriOS (Xcode 8.3, iOS ) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCipheriOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBCipheriOS_maxTarget + + # Test GRDBCipheriOS (Xcode 8.3, iOS )) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=GRDBCipheriOS (Xcode 8.3, iOS ) + script: make test_framework_GRDBCipheriOS_minTarget + + # Test GRDBCipheriOS (Xcode 8.1, iOS 10.1) + - stage: Test GRDB + SQLCipher + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.1 + env: + - TID=GRDBCipheriOS (Xcode 8.1, iOS 10.1) + script: make test_framework_GRDBCipheriOS_maxTarget + + ########################################### + ## Test Installation Methods + + # Manual Install + - stage: Test Installation + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=Manual Install + script: make test_install_manual + + # Manual Install (GRDBCipher) + - stage: Test Installation + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode8.3 + env: + - TID=Manual Install (GRDBCipher) + script: make test_install_GRDBCipher + + # Cocoapods Lint + - stage: Test Installation + osx_image: xcode8.3 + install: + - gem install cocoapods # Since Travis is not always on latest version + env: + - TID=Cocoapods + script: make test_CocoaPodsLint + + # SPM Install + - stage: Test Installation + osx_image: xcode8.3 + env: + - TID=SPM + script: make test_install_SPM + + ## The following doesn’t work, as `make test_CarthageBuild` does not yet work. + ## Carthage Build + #- stage: Carthage + # osx_image: xcode8.3 + # before_install: + # - brew update + # - brew outdated carthage || brew upgrade carthage + # script: make test_CarthageBuild diff --git a/Makefile b/Makefile index b2b0076b1..08e277e39 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,18 @@ GIT := $(shell command -v git) JAZZY := $(shell command -v jazzy) POD := $(shell command -v pod) SWIFT := $(shell command -v swift) -XCODEBUILD := $(shell command -v xcodebuild) +XCODEBUILD := set -o pipefail && $(shell command -v xcodebuild) + +# Xcode Version Information +XCODEVERSION_FULL := $(word 2, $(shell xcodebuild -version)) +XCODEVERSION_MAJOR := $(shell xcodebuild -version 2>&1 | grep Xcode | cut -d' ' -f2 | cut -d'.' -f1) +XCODEVERSION_MINOR := $(shell xcodebuild -version 2>&1 | grep Xcode | cut -d' ' -f2 | cut -d'.' -f2) + +# The Xcode Version, containing only the "MAJOR.MINOR" (ex. "8.3" for Xcode 8.3, 8.3.1, etc.) +XCODEVERSION := $(XCODEVERSION_MAJOR).$(XCODEVERSION_MINOR) + +# Used to determine if xcpretty is available +XCPRETTY_PATH := $(shell command -v xcpretty 2> /dev/null) # Targets @@ -35,9 +46,31 @@ MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # xcodebuild destination to run tests on latest iOS (Xcode 8.3) MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 7,OS=10.3" +ifeq ($(XCODEVERSION),8.3) + # xcodebuild destination to run tests on latest iOS (Xcode 8.3) + # above (default) MAX_IOS_DESTINATION is appropriate +else ifeq ($(XCODEVERSION),8.2) + # xcodebuild destination to run tests on latest iOS (Xcode 8.2) + MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 7,OS=10.2” +else ifeq ($(XCODEVERSION),8.1) + # xcodebuild destination to run tests on latest iOS (Xcode 8.1) + MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 6s,OS=10.1" +else + # Xcode < 8.1 is not supported + # Xcode > 8.3.x may necessitate a new condition above + echo "Makefile does not explicitly support Xcode $(XCODEVERSION) ($(XCODEVERSION_FULL)).” +endif -# xcodebuild destination to run tests on latest iOS (Xcode 8.1) -# MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 6s,OS=10.1" +# If xcpretty is available, use it for xcodebuild output +XCPRETTY = +ifdef XCPRETTY_PATH + XCPRETTY = | xcpretty -c + + # On Travis-CI, use xcpretty-travis-formatter + ifeq ($(TRAVIS),true) + XCPRETTY += -f `xcpretty-travis-formatter` + endif +endif # We test framework test suites, and if GRBD can be installed in an application: test: test_framework test_install @@ -52,14 +85,16 @@ test_framework_GRDBOSX: $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBOSX \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBWatchOS: # XCTest is not supported for watchOS: we only make sure that the framework builds. $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBWatchOS \ - clean build + clean build \ + $(XCPRETTY) test_framework_GRDBiOS: test_framework_GRDBiOS_maxTarget test_framework_GRDBiOS_minTarget @@ -68,20 +103,23 @@ test_framework_GRDBiOS_maxTarget: -project GRDB.xcodeproj \ -scheme GRDBiOS \ -destination $(MAX_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBiOS_minTarget: $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBiOS \ -destination $(MIN_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCustomSQLiteOSX: SQLiteCustom $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBCustomSQLiteOSX \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCustomSQLiteiOS: test_framework_GRDBCustomSQLiteiOS_maxTarget test_framework_GRDBCustomSQLiteiOS_minTarget @@ -90,20 +128,23 @@ test_framework_GRDBCustomSQLiteiOS_maxTarget: SQLiteCustom -project GRDB.xcodeproj \ -scheme GRDBCustomSQLiteiOS \ -destination $(MAX_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCustomSQLiteiOS_minTarget: SQLiteCustom $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBCustomSQLiteiOS \ -destination $(MIN_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCipherOSX: SQLCipher $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBCipherOSX \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCipheriOS: test_framework_GRDBCipheriOS_maxTarget test_framework_GRDBCipheriOS_minTarget @@ -112,14 +153,16 @@ test_framework_GRDBCipheriOS_maxTarget: SQLCipher -project GRDB.xcodeproj \ -scheme GRDBCipheriOS \ -destination $(MAX_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_framework_GRDBCipheriOS_minTarget: SQLCipher $(XCODEBUILD) \ -project GRDB.xcodeproj \ -scheme GRDBCipheriOS \ -destination $(MIN_IOS_DESTINATION) \ - $(TEST_ACTIONS) + $(TEST_ACTIONS) \ + $(XCPRETTY) test_SPM: $(SWIFT) package clean @@ -133,7 +176,8 @@ test_install_manual: -scheme GRDBDemoiOS \ -configuration Release \ -destination $(MAX_IOS_DESTINATION) \ - clean build + clean build \ + $(XCPRETTY) test_install_GRDBCipher: SQLCipher $(XCODEBUILD) \ @@ -141,7 +185,8 @@ test_install_GRDBCipher: SQLCipher -scheme GRDBiOS \ -configuration Release \ -destination $(MAX_IOS_DESTINATION) \ - clean build + clean build \ + $(XCPRETTY) test_install_SPM: cd Tests/SPM && \