-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseFastfile
More file actions
164 lines (134 loc) · 3.94 KB
/
Copy pathBaseFastfile
File metadata and controls
164 lines (134 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# frozen_string_literal: true
fastlane_require 'fileutils'
require './Helpers/AppInfoProvider.rb'
opt_out_usage
default_platform :ios
platform :ios do
#########################
# Environment Variables #
#########################
project_base_name = 'MobileCI'
ENV['CACHE_PREFIX'] = project_base_name
ENV['BUILD_FOLDER'] = File.join('fastlane', 'Build')
ENV['AWS_REGION'] = 'us-east-1'
# Files to ignore in code coverage, as an array of strings. Wildcards may be used.
coverage_files_to_ignore = [
'Sources/Resources/*',
'scripts/*',
'Pods/*',
'Carthage/*'
]
# Cache prefix used for Rome (e.g. carthage cache on S3).
rome_cache_prefix = ENV['CACHE_PREFIX']
# All schemes that will be run for testing. NOTE: make sure each is a shared scheme.
schemes_to_test = [
AppInfoProvider::Scheme::Development
]
#############################
## TESTING & CODE COVERAGE ##
#############################
desc 'Run tests for mac'
lane :test_mac do
run_tests_for_device(
schemes: ['MobileCI-macOS'],
device: '' # deliberately empty
)
end
desc 'Run tests for tvOS'
lane :test_tv_os do
run_tests_for_device(
schemes: ['MobileCI-tvOS'],
device: 'Apple TV'
)
end
desc ''
desc 'Run tests generating code coverage'
desc ''
lane :run_tests_for_device do |options|
test_schemes = options[:schemes] || schemes_to_test
project_name = options[:project_base_name] || project_base_name
device = options[:device] || 'iPhone 15 Pro'
test_schemes.each do |scheme|
UI.message "Running tests for scheme #{scheme}"
slather_tests(
scheme: scheme,
project_base_name: project_name,
device: device
)
end
end
desc ''
private_lane :slather_tests do |options|
scheme = options[:scheme]
project_name = options[:project_base_name] || project_base_name
scan(
scheme: scheme,
skip_slack: is_ci,
code_coverage: true,
device: options[:device] || 'iPhone 15 Pro',
buildlog_path: artifacts_path('xctest/logs'),
slack_only_on_failure: true
)
if is_ci?
slather(
circleci: true,
scheme: scheme,
cobertura_xml: true,
output_directory: artifacts_path,
proj: "#{project_name}.xcodeproj",
# workspace: "#{project_name}.xcworkspace",
ignore: coverage_files_to_ignore
)
elsif
slather_local(scheme: scheme, project_name: project_name)
end
end
desc 'Runs slather locally and opens the generated html page.'
desc ''
private_lane :slather_local do |options|
scheme = options[:scheme] || ENV['DEV_SCHEME']
project_name = options[:project_name] || project_base_name
slather(
scheme: scheme,
html: true,
show: !is_ci,
output_directory: artifacts_path,
proj: "#{project_name}.xcodeproj",
# workspace: "#{project_name}.xcworkspace",
ignore: coverage_files_to_ignore
)
end
desc 'If running in CI environment returns the build number; Else, get_build_number.to_s.'
def get_current_build_number
is_ci ? ci_build_number : get_build_number.to_s
end
##############
## Carthage ##
##############
desc 'Runs carthage update followed by Rome upload (iOS) to update the S3 cache.'
desc 'Options:'
desc 'cache_prefix - optional. Default is project_base_name.'
desc ''
lane :run_rome_update do |options|
cache_prefix = options[:cache_prefix] || project_base_name
carthage(
command: 'update',
platform: 'iOS',
cache_builds: true,
use_binaries: false
)
rome(
command: 'upload',
platform: 'iOS',
cacheprefix: cache_prefix
)
end
# @param [String] subdir
# @return [String] path to artifacts.
# => NOTE: base dir is using env variable ARTIFACTS_DIR
def artifacts_path(subdir = '')
base_path = ENV['ARTIFACTS_DIR']
return "#{base_path}/#{subdir}" if subdir != ''
base_path
end
end