Skip to content

Commit a4a5698

Browse files
committed
Merge pull request #43 from ReactKit/fastlane
2 parents 8fc3e7b + a4cd736 commit a4a5698

File tree

5 files changed

+241
-25
lines changed

5 files changed

+241
-25
lines changed

.gitignore

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# Xcode
1+
## Build generated
22
build/
3+
DerivedData/
4+
5+
## Various settings
36
*.pbxuser
47
!default.pbxuser
58
*.mode1v3
@@ -8,14 +11,32 @@ build/
811
!default.mode2v3
912
*.perspectivev3
1013
!default.perspectivev3
11-
xcuserdata
12-
*.xccheckout
14+
xcuserdata/
15+
16+
## Other
1317
*.moved-aside
14-
DerivedData
18+
*.xccheckout
19+
*.xcscmblueprint
20+
21+
## Obj-C/Swift specific
1522
*.hmap
1623
*.ipa
17-
*.xcuserstate
1824

25+
## Playgrounds
26+
timeline.xctimeline
27+
playground.xcworkspace
28+
29+
# Swift Package Manager
30+
Packages/
31+
.build/
32+
33+
# CocoaPods
34+
Pods/
35+
36+
# Carthage
1937
Carthage/Build
20-
.build
21-
Packages/
38+
39+
# fastlane
40+
fastlane/report.xml
41+
fastlane/screenshots
42+
fastlane/test_output

circle.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,4 @@ test:
1919
# http://qiita.com/noboru_i/items/431aa190d131795aeddc
2020
- ln -s /Applications/Xcode-7.2.app /Applications/Xcode.app
2121

22-
- set -o pipefail &&
23-
xcodebuild
24-
-scheme "SwiftState"
25-
clean build test |
26-
tee $CIRCLE_ARTIFACTS/xcode_raw-OSX.log |
27-
xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results-OSX.xml
28-
29-
- set -o pipefail &&
30-
xcodebuild
31-
CODE_SIGNING_REQUIRED=NO
32-
CODE_SIGN_IDENTITY=
33-
PROVISIONING_PROFILE=
34-
-sdk iphonesimulator
35-
-destination 'platform=iOS Simulator,OS=9.2,name=iPhone 6s'
36-
-scheme "SwiftState"
37-
clean build test |
38-
tee $CIRCLE_ARTIFACTS/xcode_raw-iOS.log |
39-
xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results-iOS.xml
22+
- fastlane test_all

fastlane/Fastfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
fastlane_version "1.59.0"
2+
default_platform :mac
3+
4+
UNIVERSAL_SCHEME = "SwiftState"
5+
RELEASE_BRANCH = "swift/2.0"
6+
7+
before_all do
8+
#carthage(use_submodules: true, no_build: true) # checkout only
9+
sh("git submodule sync && git submodule update --init --recursive") # for non-Carthage users
10+
end
11+
12+
desc "Lints Podspec"
13+
lane :pod_lint do
14+
sh("cd .. && pod lib lint")
15+
end
16+
17+
desc "Runs tests in all platforms"
18+
lane :test_all do |options|
19+
test_universal_framework(platform: :OSX, scheme: UNIVERSAL_SCHEME)
20+
test_universal_framework(platform: :iOS, scheme: UNIVERSAL_SCHEME)
21+
test_universal_framework(platform: :tvOS, scheme: UNIVERSAL_SCHEME)
22+
# test_universal_framework(platform: :watchOS, scheme: UNIVERSAL_SCHEME) # no XCTest in watchOS
23+
end
24+
25+
desc "Release new version"
26+
lane :bump do |options|
27+
bump_local(options)
28+
#bump_remote # TODO
29+
end
30+
31+
desc "Prepare release for new version (no remote push)"
32+
lane :bump_local do |options|
33+
target_version = options[:version]
34+
raise "Parameter `version` is missing. Use `fastlane release version:{version_number}`.`" if target_version.nil?
35+
36+
ensure_git_branch(branch: RELEASE_BRANCH)
37+
ensure_git_status_clean
38+
39+
test_all
40+
pod_lint
41+
42+
increment_version_number(version_number: target_version)
43+
44+
version_bump_podspec(path: "SwiftState.podspec", version_number: target_version)
45+
46+
git_commit(
47+
path: ["SwiftState.podspec", "Sources/Info.plist", "Tests/Info.plist"],
48+
message: "Bump version to #{target_version}"
49+
)
50+
add_git_tag tag: target_version
51+
end
52+
53+
platform :mac do
54+
lane :test do
55+
test_universal_framework(platform: :OSX, scheme: UNIVERSAL_SCHEME)
56+
end
57+
end
58+
59+
platform :ios do
60+
lane :test do
61+
test_universal_framework(platform: :iOS, scheme: UNIVERSAL_SCHEME)
62+
end
63+
end
64+
65+
after_all do |lane|
66+
end
67+
68+
error do |lane, exception|
69+
end

fastlane/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
fastlane documentation
2+
================
3+
# Installation
4+
```
5+
sudo gem install fastlane
6+
```
7+
# Available Actions
8+
### pod_lint
9+
```
10+
fastlane pod_lint
11+
```
12+
Lints Podspec
13+
### carthage_build
14+
```
15+
fastlane carthage_build
16+
```
17+
Builds dependencies using Carthage
18+
### test_all
19+
```
20+
fastlane test_all
21+
```
22+
Runs tests in all platforms
23+
### bump
24+
```
25+
fastlane bump
26+
```
27+
Release new version
28+
### bump_local
29+
```
30+
fastlane bump_local
31+
```
32+
33+
34+
----
35+
36+
## Mac
37+
### mac test
38+
```
39+
fastlane mac test
40+
```
41+
42+
43+
----
44+
45+
## iOS
46+
### ios test
47+
```
48+
fastlane ios test
49+
```
50+
51+
52+
----
53+
54+
This README.md is auto-generated and will be re-generated every time to run [fastlane](https://fastlane.tools).
55+
More information about fastlane can be found on [https://fastlane.tools](https://fastlane.tools).
56+
The documentation of fastlane can be found on [GitHub](https://github.com/fastlane/fastlane).
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
module Fastlane
2+
module Actions
3+
class SimulatorWatch < FastlaneCore::Simulator
4+
class << self
5+
def requested_os_type
6+
'watchOS'
7+
end
8+
end
9+
end
10+
11+
_ios_sim = FastlaneCore::Simulator.all.last
12+
_tvos_sim = FastlaneCore::SimulatorTV.all.last
13+
_watchos_sim = SimulatorWatch.all.last
14+
15+
BUILD_LOG_DIR = ENV['CIRCLE_ARTIFACTS'] || "fastlane/test_output/build_log"
16+
TEST_REPORTS_DIR = ENV['CIRCLE_TEST_REPORTS'] || "fastlane/test_output/test_report"
17+
18+
SIMULATORS = {
19+
:OSX => "platform=OS X",
20+
:iOS => _ios_sim && "platform=iOS Simulator,name=#{_ios_sim}",
21+
:tvOS => _tvos_sim && "platform=tvOS Simulator,name=#{_tvos_sim}",
22+
:watchOS => _watchos_sim && "platform=watchOS Simulator,name=#{_watchos_sim}"
23+
}
24+
25+
class TestUniversalFrameworkAction < Action
26+
27+
def self._test_platform(platform, scheme: "OSX")
28+
if SIMULATORS[platform.to_sym].nil? then
29+
raise "Simulator not found for #{platform}."
30+
end
31+
32+
require 'scan'
33+
34+
config = FastlaneCore::Configuration.create(Scan::Options.available_options, {
35+
scheme: scheme,
36+
destination: SIMULATORS[platform],
37+
code_coverage: true,
38+
buildlog_path: "#{BUILD_LOG_DIR}/#{platform}",
39+
output_directory: "#{TEST_REPORTS_DIR}/#{platform}",
40+
clean: true
41+
})
42+
43+
Fastlane::Actions::ScanAction.run(config)
44+
end
45+
46+
def self.run(params)
47+
Helper.log.info "Run TestUniversalFrameworkAction."
48+
49+
_test_platform(params[:platform], scheme: params[:scheme])
50+
end
51+
52+
#####################################################
53+
# @!group Documentation
54+
#####################################################
55+
56+
def self.description
57+
"Runs tests in target platform."
58+
end
59+
60+
def self.available_options
61+
[
62+
FastlaneCore::ConfigItem.new(key: :platform,
63+
env_name: "FL_TEST_UNIVERSAL_FRAMEWORK_PLATFORM",
64+
description: "Xcode simulator platform for testing universal framework",
65+
is_string: false,
66+
verify_block: proc do |value|
67+
raise "No platform for TestUniversalFramework given, pass using `platform: 'platform'`".red unless (value and not value.empty?)
68+
end),
69+
FastlaneCore::ConfigItem.new(key: :scheme,
70+
env_name: "FL_TEST_UNIVERSAL_FRAMEWORK_SCHEME",
71+
description: "Xcode scheme for testing universal framework",
72+
verify_block: proc do |value|
73+
raise "No scheme for TestUniversalFramework given, pass using `scheme: 'scheme'`".red unless (value and not value.empty?)
74+
end)
75+
]
76+
end
77+
78+
def self.authors
79+
["Yasuhiro Inami"]
80+
end
81+
82+
def self.is_supported?(platform)
83+
true
84+
end
85+
end
86+
end
87+
end

0 commit comments

Comments
 (0)