Fix: Running Fastlane with a single device
This commit is contained in:
parent
44eba4a03d
commit
d0e74a8d02
|
|
@ -5,6 +5,7 @@
|
|||
## Build generated
|
||||
build/
|
||||
DerivedData
|
||||
logs/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[submodule "fastlane/actions"]
|
||||
path = fastlane/actions
|
||||
[submodule "fastlane/actions/codecov"]
|
||||
path = fastlane/actions/codecov
|
||||
url = https://gist.github.com/04126b3051f6cd6aebe041bb1dfe14e9.git
|
||||
|
|
|
|||
16
.travis.yml
16
.travis.yml
|
|
@ -1,22 +1,8 @@
|
|||
osx_image: xcode9
|
||||
language: objective-c
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEVICE="iPhone X (11.0)"
|
||||
- DEVICE="iPhone 7 (10.0)"
|
||||
- DEVICE="iPhone 6 (9.0)"
|
||||
- DEVICE="iPhone 5 (8.1)"
|
||||
|
||||
script:
|
||||
- bundle exec fastlane test
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: dependency managers
|
||||
script: bundle exec fastlane pod_lint
|
||||
-
|
||||
script: bundle exec fastlane carthage_lint
|
||||
- bundle exec fastlane ci
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
|
|
|
|||
|
|
@ -1,11 +1,3 @@
|
|||
# Customise this file, documentation can be found here:
|
||||
# https://docs.fastlane.tools/actions/
|
||||
# All available actions: https://docs.fastlane.tools/actions
|
||||
# can also be listed using the `fastlane actions` command
|
||||
|
||||
# Change the syntax highlighting to Ruby
|
||||
# All lines starting with a # are ignored when running `fastlane`
|
||||
|
||||
# If you want to automatically update fastlane if a new version is available:
|
||||
# update_fastlane
|
||||
|
||||
|
|
@ -18,18 +10,34 @@ default_platform :ios
|
|||
platform :ios do
|
||||
skip_docs
|
||||
|
||||
lane :cov do
|
||||
devices = [
|
||||
"iPhone X (11.0)",
|
||||
"iPhone 7 (10.0)",
|
||||
"iPhone 6 (9.0)",
|
||||
"iPhone 5s (8.1)",
|
||||
]
|
||||
|
||||
desc "Runs the following lanes:\n- test\n- pod_lint\n- carthage_lint"
|
||||
lane :ci do
|
||||
test
|
||||
pod_lint
|
||||
carthage_lint
|
||||
end
|
||||
|
||||
desc "Runs all the tests"
|
||||
lane :test do
|
||||
ios_simulator(
|
||||
devices: devices,
|
||||
reset_before_launching: is_ci,
|
||||
)
|
||||
|
||||
cocoapods(
|
||||
podfile: "Example/Podfile"
|
||||
podfile: "Example/Podfile",
|
||||
)
|
||||
|
||||
swiftlint(
|
||||
executable: "Example/Pods/Swiftlint/swiftlint",
|
||||
strict: true
|
||||
strict: true,
|
||||
)
|
||||
|
||||
# The problem lies in the fact (or rather: serious bug in xcodebuild) that
|
||||
|
|
@ -39,19 +47,23 @@ platform :ios do
|
|||
# xcodebuild will give this "Canceling tests due to timeout" error.
|
||||
# https://stackoverflow.com/questions/37922146/xctests-failing-on-physical-device-canceling-tests-due-to-timeout/40790171#40790171
|
||||
scan(
|
||||
workspace: "Example/ReCaptcha.xcworkspace",
|
||||
build_for_testing: true,
|
||||
devices: devices,
|
||||
scheme: "ReCaptcha-Example",
|
||||
device: ENV["DEVICE"],
|
||||
workspace: "Example/ReCaptcha.xcworkspace",
|
||||
code_coverage: true,
|
||||
build_for_testing: true
|
||||
buildlog_path: File.join(ENV['BITRISE_DEPLOY_DIR'] || '.', "logs/build"),
|
||||
xcargs: '-maximum-concurrent-test-device-destinations=1',
|
||||
)
|
||||
|
||||
scan(
|
||||
workspace: "Example/ReCaptcha.xcworkspace",
|
||||
test_without_building: true,
|
||||
devices: devices,
|
||||
scheme: "ReCaptcha-Example",
|
||||
device: ENV["DEVICE"],
|
||||
workspace: "Example/ReCaptcha.xcworkspace",
|
||||
code_coverage: true,
|
||||
test_without_building: true
|
||||
buildlog_path: File.join(ENV['BITRISE_DEPLOY_DIR'] || '.', "logs/run"),
|
||||
xcargs: '-maximum-concurrent-test-device-destinations=1',
|
||||
)
|
||||
|
||||
if is_ci
|
||||
|
|
@ -67,14 +79,7 @@ platform :ios do
|
|||
|
||||
desc "Lint Cocoapods Lib"
|
||||
lane :pod_lint do
|
||||
cocoapods(
|
||||
podfile: "Example/Podfile",
|
||||
repo_update: true
|
||||
)
|
||||
|
||||
pod_lib_lint(
|
||||
allow_warnings: true # Remove this when RxSwift stops warning
|
||||
)
|
||||
pod_lib_lint
|
||||
end
|
||||
|
||||
desc "Lint Carthage lib"
|
||||
|
|
@ -89,33 +94,38 @@ platform :ios do
|
|||
command: "build",
|
||||
platform: "iOS",
|
||||
cache_builds: true,
|
||||
no_skip_current: true
|
||||
no_skip_current: true,
|
||||
)
|
||||
end
|
||||
|
||||
desc "Deploy a new version to Github and Cocoapods"
|
||||
lane :release do
|
||||
carthage "archive"
|
||||
ci unless is_ci
|
||||
|
||||
carthage(
|
||||
command: "archive",
|
||||
)
|
||||
|
||||
pod_push(
|
||||
path: "ReCaptcha.podspec",
|
||||
verbose: true
|
||||
verbose: true,
|
||||
)
|
||||
|
||||
prev_tag = sh "git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`"
|
||||
changelog = changelog_from_git_commits(
|
||||
tag_match_pattern: "*",
|
||||
between: [last_git_tag, prev_tag.strip],
|
||||
pretty: "- %s"
|
||||
)
|
||||
|
||||
set_github_release(
|
||||
repository_name: "fjcaetano/ReCaptcha",
|
||||
tag_name: last_git_tag,
|
||||
upload_assets: ["ReCaptcha.framework"],
|
||||
description: changelog
|
||||
name: last_git_tag,
|
||||
upload_assets: ["ReCaptcha.framework.zip"],
|
||||
description: changelog,
|
||||
)
|
||||
end
|
||||
|
||||
# You can define as many lanes as you want
|
||||
|
||||
after_all do |lane|
|
||||
# This block is called, only if the executed lane was successful
|
||||
|
||||
|
|
@ -131,10 +141,3 @@ platform :ios do
|
|||
# )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
|
||||
# All available actions: https://docs.fastlane.tools/actions
|
||||
|
||||
# fastlane reports which actions are used. No personal data is recorded.
|
||||
# Learn more at https://github.com/fastlane/fastlane#metrics
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 75911fa21bda7824d7fe638eb3ff0f5d5f8ffe9a
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 2f03a689732adc3a6d1ccc4143b57a5de206d131
|
||||
|
|
@ -0,0 +1 @@
|
|||
codecov/codecov.rb
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
module Fastlane
|
||||
module Actions
|
||||
module SharedValues
|
||||
IOS_SIMULATOR_CUSTOM_VALUE = :IOS_SIMULATOR_CUSTOM_VALUE
|
||||
end
|
||||
|
||||
class IosSimulatorAction < Action
|
||||
@@already_booted_code = 164
|
||||
|
||||
def self.run(params)
|
||||
devices = params[:devices] || Array(params[:device])
|
||||
available_sims = FastlaneCore::Simulator.all
|
||||
|
||||
devices.each do |device|
|
||||
sim = available_sims.detect { |d| device == "#{d.name} (#{d.os_version})" }
|
||||
if sim.nil?
|
||||
UI.error "Device not found: #{device}"
|
||||
next
|
||||
end
|
||||
|
||||
if params[:reset_before_launching]
|
||||
sim.reset
|
||||
end
|
||||
|
||||
`xcrun simctl boot #{sim.udid} > /dev/null 2>&1`
|
||||
if $?.exitstatus == @@already_booted_code
|
||||
UI.important "Skipping #{device} (already booted)"
|
||||
end
|
||||
|
||||
UI.message "Booted #{device} [#{sim.udid}]" unless $?.exitstatus == @@already_booted_code
|
||||
end
|
||||
end
|
||||
|
||||
#####################################################
|
||||
# @!group Documentation
|
||||
#####################################################
|
||||
|
||||
def self.description
|
||||
"Launch iOS simulators beforehand to allow for boot time"
|
||||
end
|
||||
|
||||
def self.details
|
||||
"Run `xcrun instruments -s` for the list of available simulators"
|
||||
end
|
||||
|
||||
def self.available_options
|
||||
[
|
||||
FastlaneCore::ConfigItem.new(key: :device,
|
||||
env_name: "SCAN_DEVICE",
|
||||
description: "The name of the simulator type you want to run tests on (e.g. 'iPhone 6 (10.0)')", # a short description of this parameter
|
||||
conflicting_options: [:devices],
|
||||
),
|
||||
FastlaneCore::ConfigItem.new(key: :devices,
|
||||
env_name: "SCAN_DEVICES",
|
||||
description: "Array of devices to run the tests on (e.g. ['iPhone 6 (10.0)', 'iPad Air (8.3)'])",
|
||||
is_string: false,
|
||||
conflicting_options: [:device],
|
||||
optional: true,
|
||||
),
|
||||
FastlaneCore::ConfigItem.new(key: :reset_before_launching,
|
||||
env_name: "FL_IOS_SIMULATOR_RESET",
|
||||
description: "Should reset simulators before launching",
|
||||
is_string: false,
|
||||
default_value: false,
|
||||
),
|
||||
]
|
||||
end
|
||||
|
||||
def self.author
|
||||
"Flávio Caetano (@fjcaetano)"
|
||||
end
|
||||
|
||||
def self.is_supported?(platform)
|
||||
platform == :ios
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
if $(which bundle &> /dev/null); then
|
||||
bundle exec fastlane test
|
||||
bundle exec fastlane ci
|
||||
elif $(which fastlane &> /dev/null); then
|
||||
fastlane test
|
||||
fastlane ci
|
||||
else
|
||||
echo 'Fastlane not installed; Run `bundle install` or install Fastlane directly'
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue