diff --git a/.gitignore b/.gitignore index c623c4f..ef19cc2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ -# Xcode +## Build generated build/ +DerivedData/ + +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -8,14 +11,32 @@ build/ !default.mode2v3 *.perspectivev3 !default.perspectivev3 -xcuserdata -*.xccheckout +xcuserdata/ + +## Other *.moved-aside -DerivedData +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific *.hmap *.ipa -*.xcuserstate +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +Packages/ +.build/ + +# CocoaPods +Pods/ + +# Carthage Carthage/Build -.build -Packages/ \ No newline at end of file + +# fastlane +fastlane/report.xml +fastlane/screenshots +fastlane/test_output \ No newline at end of file diff --git a/circle.yml b/circle.yml index c975fc7..4f1db72 100644 --- a/circle.yml +++ b/circle.yml @@ -19,21 +19,4 @@ test: # http://qiita.com/noboru_i/items/431aa190d131795aeddc - ln -s /Applications/Xcode-7.2.app /Applications/Xcode.app - - set -o pipefail && - xcodebuild - -scheme "SwiftState" - clean build test | - tee $CIRCLE_ARTIFACTS/xcode_raw-OSX.log | - xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results-OSX.xml - - - set -o pipefail && - xcodebuild - CODE_SIGNING_REQUIRED=NO - CODE_SIGN_IDENTITY= - PROVISIONING_PROFILE= - -sdk iphonesimulator - -destination 'platform=iOS Simulator,OS=9.2,name=iPhone 6s' - -scheme "SwiftState" - clean build test | - tee $CIRCLE_ARTIFACTS/xcode_raw-iOS.log | - xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results-iOS.xml + - fastlane test_all diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..b9eaca2 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,69 @@ +fastlane_version "1.59.0" +default_platform :mac + +UNIVERSAL_SCHEME = "SwiftState" +RELEASE_BRANCH = "swift/2.0" + +before_all do + #carthage(use_submodules: true, no_build: true) # checkout only + sh("git submodule sync && git submodule update --init --recursive") # for non-Carthage users +end + +desc "Lints Podspec" +lane :pod_lint do + sh("cd .. && pod lib lint") +end + +desc "Runs tests in all platforms" +lane :test_all do |options| + test_universal_framework(platform: :OSX, scheme: UNIVERSAL_SCHEME) + test_universal_framework(platform: :iOS, scheme: UNIVERSAL_SCHEME) + test_universal_framework(platform: :tvOS, scheme: UNIVERSAL_SCHEME) + # test_universal_framework(platform: :watchOS, scheme: UNIVERSAL_SCHEME) # no XCTest in watchOS +end + +desc "Release new version" +lane :bump do |options| + bump_local(options) + #bump_remote # TODO +end + +desc "Prepare release for new version (no remote push)" +lane :bump_local do |options| + target_version = options[:version] + raise "Parameter `version` is missing. Use `fastlane release version:{version_number}`.`" if target_version.nil? + + ensure_git_branch(branch: RELEASE_BRANCH) + ensure_git_status_clean + + test_all + pod_lint + + increment_version_number(version_number: target_version) + + version_bump_podspec(path: "SwiftState.podspec", version_number: target_version) + + git_commit( + path: ["SwiftState.podspec", "Sources/Info.plist", "Tests/Info.plist"], + message: "Bump version to #{target_version}" + ) + add_git_tag tag: target_version +end + +platform :mac do + lane :test do + test_universal_framework(platform: :OSX, scheme: UNIVERSAL_SCHEME) + end +end + +platform :ios do + lane :test do + test_universal_framework(platform: :iOS, scheme: UNIVERSAL_SCHEME) + end +end + +after_all do |lane| +end + +error do |lane, exception| +end diff --git a/fastlane/README.md b/fastlane/README.md new file mode 100644 index 0000000..9cdb623 --- /dev/null +++ b/fastlane/README.md @@ -0,0 +1,56 @@ +fastlane documentation +================ +# Installation +``` +sudo gem install fastlane +``` +# Available Actions +### pod_lint +``` +fastlane pod_lint +``` +Lints Podspec +### carthage_build +``` +fastlane carthage_build +``` +Builds dependencies using Carthage +### test_all +``` +fastlane test_all +``` +Runs tests in all platforms +### bump +``` +fastlane bump +``` +Release new version +### bump_local +``` +fastlane bump_local +``` + + +---- + +## Mac +### mac test +``` +fastlane mac test +``` + + +---- + +## iOS +### ios test +``` +fastlane ios test +``` + + +---- + +This README.md is auto-generated and will be re-generated every time to run [fastlane](https://fastlane.tools). +More information about fastlane can be found on [https://fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [GitHub](https://github.com/fastlane/fastlane). \ No newline at end of file diff --git a/fastlane/actions/test_universal_framework.rb b/fastlane/actions/test_universal_framework.rb new file mode 100644 index 0000000..a5971b3 --- /dev/null +++ b/fastlane/actions/test_universal_framework.rb @@ -0,0 +1,87 @@ +module Fastlane + module Actions + class SimulatorWatch < FastlaneCore::Simulator + class << self + def requested_os_type + 'watchOS' + end + end + end + + _ios_sim = FastlaneCore::Simulator.all.last + _tvos_sim = FastlaneCore::SimulatorTV.all.last + _watchos_sim = SimulatorWatch.all.last + + BUILD_LOG_DIR = ENV['CIRCLE_ARTIFACTS'] || "fastlane/test_output/build_log" + TEST_REPORTS_DIR = ENV['CIRCLE_TEST_REPORTS'] || "fastlane/test_output/test_report" + + SIMULATORS = { + :OSX => "platform=OS X", + :iOS => _ios_sim && "platform=iOS Simulator,name=#{_ios_sim}", + :tvOS => _tvos_sim && "platform=tvOS Simulator,name=#{_tvos_sim}", + :watchOS => _watchos_sim && "platform=watchOS Simulator,name=#{_watchos_sim}" + } + + class TestUniversalFrameworkAction < Action + + def self._test_platform(platform, scheme: "OSX") + if SIMULATORS[platform.to_sym].nil? then + raise "Simulator not found for #{platform}." + end + + require 'scan' + + config = FastlaneCore::Configuration.create(Scan::Options.available_options, { + scheme: scheme, + destination: SIMULATORS[platform], + code_coverage: true, + buildlog_path: "#{BUILD_LOG_DIR}/#{platform}", + output_directory: "#{TEST_REPORTS_DIR}/#{platform}", + clean: true + }) + + Fastlane::Actions::ScanAction.run(config) + end + + def self.run(params) + Helper.log.info "Run TestUniversalFrameworkAction." + + _test_platform(params[:platform], scheme: params[:scheme]) + end + + ##################################################### + # @!group Documentation + ##################################################### + + def self.description + "Runs tests in target platform." + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :platform, + env_name: "FL_TEST_UNIVERSAL_FRAMEWORK_PLATFORM", + description: "Xcode simulator platform for testing universal framework", + is_string: false, + verify_block: proc do |value| + raise "No platform for TestUniversalFramework given, pass using `platform: 'platform'`".red unless (value and not value.empty?) + end), + FastlaneCore::ConfigItem.new(key: :scheme, + env_name: "FL_TEST_UNIVERSAL_FRAMEWORK_SCHEME", + description: "Xcode scheme for testing universal framework", + verify_block: proc do |value| + raise "No scheme for TestUniversalFramework given, pass using `scheme: 'scheme'`".red unless (value and not value.empty?) + end) + ] + end + + def self.authors + ["Yasuhiro Inami"] + end + + def self.is_supported?(platform) + true + end + end + end +end