From 6a44d993205b723ead280137f13bb068b65292e3 Mon Sep 17 00:00:00 2001 From: Adam Law <> Date: Thu, 31 Oct 2019 10:59:40 +0000 Subject: [PATCH 01/10] * Now using `fastlane-plugin-test_center` for UI tests - https://github.com/lyndsey-ferguson/fastlane-plugin-test_center * Added new (optional) environment variable `MULTI_SCAN_TRY_COUNT` to set the number of times a test is retried before it's considered a fail. * `TAB_UI_TEST_DEVICES` now supports the setting of multiple devices, as the name implies. If setting multiple, these should be ':' separated. * Added new (optional) environment variable `MULTI_SCAN_PARALLEL_WORKER_COUNT` to set the number of simulators for batched UI tests. * Added new (optional) environment variable `TAB_UNIT_TEST_DEVICE` to be able to set a unit test device independently. The `device` scan parameter was used previously which conflicted with the use of `devices` by `multi-scan`. * Updated `changelog` for version 6.0.0 changes. * Updated `readme` for version 6.0.0 changes. --- CHANGELOG.md | 21 +++++++++++++-------- Fastfile | 42 +++++++++++++++++++++++++++++++++++------- README.md | 3 +++ 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d2b949..c96fe39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,25 @@ # CHANGELOG +## [6.0.0](https://github.com/theappbusiness/MasterFastfile/releases/tag/6.0.0) + +- UI tests are now executed using `fastlane-plugin-test_center` - https://github.com/lyndsey-ferguson/fastlane-plugin-test_center. +- Added new (optional) environment variable `MULTI_SCAN_TRY_COUNT` to set the number of times a test is retried before it's considered a fail. +- `TAB_UI_TEST_DEVICES` now supports the setting of multiple devices, as the name implies. If setting multiple, these should be ':' separated. +- Added new (optional) environment variable `MULTI_SCAN_PARALLEL_WORKER_COUNT` to set the number of simulators for batched UI tests. +- Added new (optional) environment variable `TAB_UNIT_TEST_DEVICE` to be able to set a unit test device independently. The `device` scan parameter was used previously which conflicted with the use of `devices` by `multi-scan`. + ## [5.0.1](https://github.com/theappbusiness/MasterFastfile/releases/tag/5.0.1) -Fixes an issue that was causing hockey uploads to fail. +- Fixes an issue that was causing hockey uploads to fail. ## [5.0.0](https://github.com/theappbusiness/MasterFastfile/releases/tag/5.0.0) -`TAB_PRIMARY_TARGET` environment variable is now mandatory for projects using Icon Overlay. - -As of v 2.86.0, fastlane requires a target for get_version_number, used for icon badging. +- `TAB_PRIMARY_TARGET` environment variable is now mandatory for projects using Icon Overlay. +- As of v 2.86.0, fastlane requires a target for get_version_number, used for icon badging. See discussion here: fastlane/fastlane#12177. See PR #64 for details. - -Use intended Bundle ID environment setting for each action - -Distinguishing between `FL_UPDATE_PLIST_APP_IDENTIFIER` and `FL_UPDATE_APP_IDENTIFIER`. See PR #63 for details. +- Use intended Bundle ID environment setting for each action +- Distinguishing between `FL_UPDATE_PLIST_APP_IDENTIFIER` and `FL_UPDATE_APP_IDENTIFIER`. See PR #63 for details. ## [4.0.0](https://github.com/theappbusiness/MasterFastfile/releases/tag/4.0.0) ### Changed diff --git a/Fastfile b/Fastfile index a3693a4..d19eddc 100644 --- a/Fastfile +++ b/Fastfile @@ -14,7 +14,10 @@ desc 'It\'s not recommended to include UI tests in this scheme, instead run the lane :test do _setup skip_slack = ENV['SCAN_SLACK_CHANNEL'].to_s.strip.empty? - scan(skip_slack: skip_slack) + scan( + skip_slack: skip_slack, + devices: ENV['TAB_UNIT_TEST_DEVICE'] || ['iPhone 8'] + ) end desc 'Runs UI tests that are included in the scheme.' @@ -22,10 +25,36 @@ desc 'Environment variables to use: `TAB_UI_TEST_DEVICES`, `TAB_REPORT_FORMATS`, lane :ui_test do _setup skip_slack = ENV['SCAN_SLACK_CHANNEL'].to_s.strip.empty? - scan(skip_slack: skip_slack, - devices: ENV['TAB_UI_TEST_DEVICES'], - output_types: ENV['TAB_REPORT_FORMATS'], - scheme: ENV['TAB_UI_TEST_SCHEME']) + + max_test_try_count = (ENV['MULTI_SCAN_TRY_COUNT'] || "1").to_i + test_run_block = lambda do |testrun_info| + failed_test_count = testrun_info[:failed].size + + if failed_test_count > 0 + try_attempt = testrun_info[:try_count] + if try_attempt < max_test_try_count + UI.header('Not all UI tests have passed. Attempting re-run of failed...') + else + UI.important('Not all UI tests have passed and the maximum try count has been reached.') + end + + UI.message("testrun_info: #{testrun_info}") + end + end + + result = multi_scan( + skip_slack: skip_slack, + devices: ENV['TAB_UI_TEST_DEVICES'].split(':'), + output_types: ENV['TAB_REPORT_FORMATS'], + scheme: ENV['TAB_UI_TEST_SCHEME'], + try_count: max_test_try_count, + fail_build: true, + testrun_completed_block: test_run_block, + parallel_testrun_count: (ENV['MULTI_SCAN_PARALLEL_WORKER_COUNT'] || "4").to_i + ) + unless result[:failed_testcount].zero? + UI.message("There are #{result[:failed_testcount]} legitimate failing tests") + end end desc 'Runs all unit tests before deploying to App Center.' @@ -75,12 +104,11 @@ end def _setup ENV['SCAN_SCHEME'] = ENV['GYM_SCHEME'] - ENV['SCAN_DEVICE'] ||= 'iPhone 6 (12.0)' xcode_select(ENV['TAB_XCODE_PATH']) if is_ci && !ENV['TAB_XCODE_PATH'].nil? unless ENV['TAB_UI_TEST_SCHEME'].nil? # rubocop:disable Style/GuardClause ENV['TAB_REPORT_FORMATS'] = 'html' if ENV['TAB_OUTPUT_TYPES'].nil? - ENV['TAB_UI_TEST_DEVICES'] ||= 'iPhone 8' + ENV['TAB_UI_TEST_DEVICES'] ||= ['iPhone 8'] end end diff --git a/README.md b/README.md index 4f9437a..03ad069 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,9 @@ The MasterFastfile uses whichever export options you have set for the `GYM_EXPOR ## Dependencies +### Test Center plugin +Add the test center plugin to your fastlane setup for the `ui_test` lane. Follow the guide [here](https://github.com/lyndsey-ferguson/fastlane-plugin-test_center) + ### App Center plugin Add the app center plugin to your fastlane setup for the app center lanes. Follow the guide [here](https://github.com/microsoft/fastlane-plugin-appcenter) From 2177dbd5b084f965f2edae0b76aae096d20108da Mon Sep 17 00:00:00 2001 From: Adam Law <> Date: Fri, 6 Dec 2019 10:25:34 +0000 Subject: [PATCH 02/10] * `TAB_OUTPUT_TYPES` wasn't being used anywhere which was incorrectly leading to `TAB_REPORT_FORMATS` being set (overridden) to `html`. This resulted in log warning during a UI test run due `junit` not being set --- Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index d19eddc..21faf02 100644 --- a/Fastfile +++ b/Fastfile @@ -107,7 +107,7 @@ def _setup xcode_select(ENV['TAB_XCODE_PATH']) if is_ci && !ENV['TAB_XCODE_PATH'].nil? unless ENV['TAB_UI_TEST_SCHEME'].nil? # rubocop:disable Style/GuardClause - ENV['TAB_REPORT_FORMATS'] = 'html' if ENV['TAB_OUTPUT_TYPES'].nil? + ENV['TAB_REPORT_FORMATS'] = 'html' if ENV['TAB_REPORT_FORMATS'].nil? ENV['TAB_UI_TEST_DEVICES'] ||= ['iPhone 8'] end end From 08d29d9e70bf5b1d4827052a96d8f97ef7439bb8 Mon Sep 17 00:00:00 2001 From: yasinahmed81 Date: Fri, 5 Jun 2020 15:22:38 +0100 Subject: [PATCH 03/10] Changes configuration to Debug --- Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index 21faf02..6390ff3 100644 --- a/Fastfile +++ b/Fastfile @@ -150,7 +150,7 @@ def _build_with_gym export_method = _get_export_method xcconfig_filename = Dir.pwd + '/TAB.release.xcconfig' create_xcconfig(filename: xcconfig_filename) - gym(export_method: export_method, xcconfig: xcconfig_filename) + gym(configuration: "Debug", export_method: export_method, xcconfig: xcconfig_filename) end def _get_export_method From 4358e3153ee44141ab9e8387947fbc235246fc29 Mon Sep 17 00:00:00 2001 From: yasinahmed81 Date: Mon, 8 Jun 2020 11:54:50 +0100 Subject: [PATCH 04/10] Adds configuration for Release or Debug --- Fastfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index 6390ff3..b481aa8 100644 --- a/Fastfile +++ b/Fastfile @@ -150,7 +150,11 @@ def _build_with_gym export_method = _get_export_method xcconfig_filename = Dir.pwd + '/TAB.release.xcconfig' create_xcconfig(filename: xcconfig_filename) - gym(configuration: "Debug", export_method: export_method, xcconfig: xcconfig_filename) + gym(configuration: _configuration, export_method: export_method, xcconfig: xcconfig_filename) +end + +def _configuration + return ENV['GYM_EXPORT_OPTIONS'].nil? ? "Release" : get_info_plist_value(path: ENV['GYM_EXPORT_OPTIONS'], key: 'configuration') end def _get_export_method From e1a03588a03b3f87a5961b6a0a643b03e49274af Mon Sep 17 00:00:00 2001 From: yasinahmed81 Date: Mon, 8 Jun 2020 12:00:52 +0100 Subject: [PATCH 05/10] Redefines logic --- Fastfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index b481aa8..967d196 100644 --- a/Fastfile +++ b/Fastfile @@ -154,7 +154,8 @@ def _build_with_gym end def _configuration - return ENV['GYM_EXPORT_OPTIONS'].nil? ? "Release" : get_info_plist_value(path: ENV['GYM_EXPORT_OPTIONS'], key: 'configuration') + value = get_info_plist_value(path: ENV['GYM_EXPORT_OPTIONS'], key: 'configuration') + return value.nil? ? "Release" : value end def _get_export_method From 8f655ae922037919202519b59ff8861af392ad3d Mon Sep 17 00:00:00 2001 From: yasinahmed81 Date: Mon, 8 Jun 2020 15:36:35 +0100 Subject: [PATCH 06/10] Uses ENV var for BUILD_CONFIGURATION --- Fastfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Fastfile b/Fastfile index 967d196..7886505 100644 --- a/Fastfile +++ b/Fastfile @@ -150,12 +150,11 @@ def _build_with_gym export_method = _get_export_method xcconfig_filename = Dir.pwd + '/TAB.release.xcconfig' create_xcconfig(filename: xcconfig_filename) - gym(configuration: _configuration, export_method: export_method, xcconfig: xcconfig_filename) + gym(configuration: _get_build_config, export_method: export_method, xcconfig: xcconfig_filename) end -def _configuration - value = get_info_plist_value(path: ENV['GYM_EXPORT_OPTIONS'], key: 'configuration') - return value.nil? ? "Release" : value +def _get_build_config + return ENV['BUILD_CONFIGURATION'].nil? ? "Release" : ENV['BUILD_CONFIGURATION'] end def _get_export_method From 8f26f848f395fcb20dcb60f9080b38ff4005d98c Mon Sep 17 00:00:00 2001 From: yasinahmed81 Date: Tue, 9 Jun 2020 09:33:25 +0100 Subject: [PATCH 07/10] Renames BUILD_CONFIGURATION to FL_BUILD_CONFIGURATION --- Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index 7886505..91a786e 100644 --- a/Fastfile +++ b/Fastfile @@ -154,7 +154,7 @@ def _build_with_gym end def _get_build_config - return ENV['BUILD_CONFIGURATION'].nil? ? "Release" : ENV['BUILD_CONFIGURATION'] + return ENV['FL_BUILD_CONFIGURATION'].nil? ? "Release" : ENV['FL_BUILD_CONFIGURATION'] end def _get_export_method From e9a27e06fdb461e82051f7f5567bca966dabb708 Mon Sep 17 00:00:00 2001 From: Adam Law <> Date: Thu, 18 Jun 2020 14:13:33 +0100 Subject: [PATCH 08/10] Code signing type (auto/manual) can now be configured * Added `FL_USE_AUTOMATIC_CODE_SIGNING` which can be used to optionally control automatic/manual code signing. --- Fastfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Fastfile b/Fastfile index 91a786e..1d6c656 100644 --- a/Fastfile +++ b/Fastfile @@ -147,6 +147,7 @@ end def _build_with_gym install_provisioning_profiles _update_team_id_if_necessary + _update_code_signing_type_if_necessary export_method = _get_export_method xcconfig_filename = Dir.pwd + '/TAB.release.xcconfig' create_xcconfig(filename: xcconfig_filename) @@ -181,6 +182,16 @@ def _update_team_id_if_necessary end end +def _update_code_signing_type_if_necessary + automatic_code_signing = ENV['FL_USE_AUTOMATIC_CODE_SIGNING'] + if automatic_code_signing + UI.message("Updating code signing to '#{automatic_code_signing == 'true' ? 'automatic' : 'manual'}'") + update_code_signing_settings( + use_automatic_signing: automatic_code_signing == 'true', + ) + end +end + def _get_team_id team_id = ENV['FL_PROJECT_TEAM_ID'] unless team_id From 14ce1b6add07e9241ca01e7741d8cc219f070482 Mon Sep 17 00:00:00 2001 From: Adam Law <> Date: Mon, 22 Jun 2020 14:45:29 +0100 Subject: [PATCH 09/10] Added support for settings of gym `xcargs` parameter for purposes of being able to set additional build arguments - https://docs.fastlane.tools/actions/build_app/ --- Fastfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Fastfile b/Fastfile index 1d6c656..a1dae58 100644 --- a/Fastfile +++ b/Fastfile @@ -151,7 +151,13 @@ def _build_with_gym export_method = _get_export_method xcconfig_filename = Dir.pwd + '/TAB.release.xcconfig' create_xcconfig(filename: xcconfig_filename) - gym(configuration: _get_build_config, export_method: export_method, xcconfig: xcconfig_filename) + + gym( + configuration: _get_build_config, + export_method: export_method, + xcconfig: xcconfig_filename, + xcargs: ENV['GYM_XCARGS'] || '' + ) end def _get_build_config From edb222d6587a123989e11e84356d789157137594 Mon Sep 17 00:00:00 2001 From: Eugene Prokoshev Date: Wed, 14 Oct 2020 15:33:29 +0100 Subject: [PATCH 10/10] Add intermediate logging for each attempt of multi_scan run. --- Fastfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Fastfile b/Fastfile index a1dae58..a7419e2 100644 --- a/Fastfile +++ b/Fastfile @@ -37,9 +37,9 @@ lane :ui_test do else UI.important('Not all UI tests have passed and the maximum try count has been reached.') end - - UI.message("testrun_info: #{testrun_info}") end + UI.message("Attempt #{testrun_info[:try_count]} out of #{max_test_try_count} run info: #{testrun_info}") + end result = multi_scan(