diff --git a/.github/workflows/ios_sanity_full_test.yml b/.github/workflows/ios_sanity_full_test.yml new file mode 100644 index 00000000..3ca125cb --- /dev/null +++ b/.github/workflows/ios_sanity_full_test.yml @@ -0,0 +1,90 @@ +name: iOS Sanity Full Tests + +on: + schedule: + - cron: '0 0/3 * * *' + workflow_dispatch: + +defaults: + run: + working-directory: iosApp + +jobs: + test: + name: Test + runs-on: macOS-latest + timeout-minutes: 60 + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.10.0 + with: + access_token: ${{ github.token }} + + - name: Set up JAVA 11 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Checkout source code + uses: actions/checkout@v2.3.2 + with: + ref: develop + submodules: recursive + + - name: Setup Konfig Properties + env: + KMM_KONFIG_PROPERTIES: ${{ secrets.KMM_KONFIG_PROPERTIES }} + run: | + cd ../buildSrc/src/main/kotlin/appPackage + touch BuildKonfig.kt + echo $KMM_KONFIG_PROPERTIES | base64 --decode > BuildKonfig.kt + + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Install Bundle and check environment versions + run: | + echo 'Install Bundle' + bundle config path vendor/bundle + bundle install + echo 'Check environment setup versions' + ruby --version + gem --version + bundler --version + + - name: Cache Gradle + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/modules-* + ~/.gradle/caches/jars-* + ~/.gradle/caches/build-cache-* + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Generate KMM frameworks for Cocoapods + run: | + cd .. + ./gradlew generateDummyFramework + + - name: Cache Pods + uses: actions/cache@v2 + id: cocoapodCache + with: + path: Pods + key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + + - name: Install Pods Dependencies + run: bundle exec pod install + + - name: Build and Test + run: bundle exec fastlane build_and_full_test diff --git a/.swiftlint.yml b/.swiftlint.yml index 26b5e3dc..6f2b61c0 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,6 +1,120 @@ included: - - iosApp + - iosApp/Survey + - iosApp/SurveyTests + - iosApp/SurveyUITests excluded: + - iosApp/SurveyTests/Sources/Mocks/Sourcery/AutoMockable.generated.swift + - iosApp/Survey/Sources/Supports/Helpers/Rswift/R.generated.swift - iosApp/Pods + - iosApp/Derived + - iosApp/DerivedData - iosApp/vendor + +opt_in_rules: + - anyobject_protocol + - array_init + - attributes + - closure_end_indentation + - closure_spacing + - collection_alignment + - contains_over_first_not_nil + - convenience_type + - discouraged_object_literal + - discouraged_optional_boolean + - empty_count + - empty_string + - empty_xctest_method + - explicit_init + - fallthrough + - fatal_error_message + - file_name + - file_types_order + - first_where + - force_unwrapping + - identical_operands + - implicit_return + - joined_default_parameter + - last_where + - legacy_multiple + - legacy_random + - let_var_whitespace + - literal_expression_end_indentation + - lower_acl_than_parent + - modifier_order + - multiline_arguments + - multiline_function_chains + - multiline_literal_brackets + - multiline_parameters + - nimble_operator + - number_separator + - operator_usage_whitespace + - overridden_super_call + - override_in_extension + - private_action + - private_outlet + - prohibited_super_call + - quick_discouraged_focused_test + - quick_discouraged_pending_test + - reduce_into + - redundant_nil_coalescing + - single_test_class + - sorted_first_last + - static_operator + - strong_iboutlet + - toggle_bool + - type_contents_order + - unneeded_parentheses_in_closure_argument + - unowned_variable_capture + - untyped_error_in_catch + - vertical_parameter_alignment_on_call + - xct_specific_matcher + - yoda_condition +disabled_rules: + - todo + +attributes: + always_on_same_line: + - '@objc' +identifier_name: + excluded: + - id +line_length: + ignores_function_declarations: true + ignores_comments: true +modifier_order: + preferred_modifier_order: + - acl + - setterACL + - override + - dynamic + - mutators + - lazy + - final + - required + - convenience + - typeMethods + - owned +nesting: + type_level: + warning: 2 +number_separator: + minimum_fraction_length: 10 +trailing_whitespace: + ignores_empty_lines: true +implicit_return: + included: + - closure + - getter + +custom_rules: + multiline_collection_one_per_line: + name: 'Multiline Collection One Per Line' + message: 'Collection should be either on the same line, or one per line.' + regex: '\[\n([^\[\(])*(,([^\n\r])*[\w]+)([^\[])*\n(\s)*]' + severity: warning + multiline_arguments_one_per_line: + name: 'Multiline Arguments One Per Line' + message: 'Arguments should be either on the same line, or one per line.' + regex: '[^\n\r]\(\n([^\(<])*([^\n\r],([^\n\r])*[\w]+)([^\)])*\n(\s)*\)' + severity: warning diff --git a/iosApp/.swiftlint.yml b/iosApp/.swiftlint.yml deleted file mode 100644 index f1935253..00000000 --- a/iosApp/.swiftlint.yml +++ /dev/null @@ -1,119 +0,0 @@ -included: - - Survey - - SurveyTests - - SurveyUITests - -excluded: - - SurveyTests/Sources/Mocks/Sourcery/AutoMockable.generated.swift - - Survey/Sources/Supports/Helpers/Rswift/R.generated.swift - - Pods - - Derived - - DerivedData - -opt_in_rules: - - anyobject_protocol - - array_init - - attributes - - closure_end_indentation - - closure_spacing - - collection_alignment - - contains_over_first_not_nil - - convenience_type - - discouraged_object_literal - - discouraged_optional_boolean - - empty_count - - empty_string - - empty_xctest_method - - explicit_init - - fallthrough - - fatal_error_message - - file_name - - file_types_order - - first_where - - force_unwrapping - - identical_operands - - implicit_return - - joined_default_parameter - - last_where - - legacy_multiple - - legacy_random - - let_var_whitespace - - literal_expression_end_indentation - - lower_acl_than_parent - - modifier_order - - multiline_arguments - - multiline_function_chains - - multiline_literal_brackets - - multiline_parameters - - nimble_operator - - number_separator - - operator_usage_whitespace - - overridden_super_call - - override_in_extension - - private_action - - private_outlet - - prohibited_super_call - - quick_discouraged_focused_test - - quick_discouraged_pending_test - - reduce_into - - redundant_nil_coalescing - - single_test_class - - sorted_first_last - - static_operator - - strong_iboutlet - - toggle_bool - - type_contents_order - - unneeded_parentheses_in_closure_argument - - unowned_variable_capture - - untyped_error_in_catch - - vertical_parameter_alignment_on_call - - xct_specific_matcher - - yoda_condition -disabled_rules: - - todo - -attributes: - always_on_same_line: - - '@objc' -identifier_name: - excluded: - - id -line_length: - ignores_function_declarations: true - ignores_comments: true -modifier_order: - preferred_modifier_order: - - acl - - setterACL - - override - - dynamic - - mutators - - lazy - - final - - required - - convenience - - typeMethods - - owned -nesting: - type_level: - warning: 2 -number_separator: - minimum_fraction_length: 10 -trailing_whitespace: - ignores_empty_lines: true -implicit_return: - included: - - closure - - getter - -custom_rules: - multiline_collection_one_per_line: - name: 'Multiline Collection One Per Line' - message: 'Collection should be either on the same line, or one per line.' - regex: '\[\n([^\[\(])*(,([^\n\r])*[\w]+)([^\[])*\n(\s)*]' - severity: warning - multiline_arguments_one_per_line: - name: 'Multiline Arguments One Per Line' - message: 'Arguments should be either on the same line, or one per line.' - regex: '[^\n\r]\(\n([^\(<])*([^\n\r],([^\n\r])*[\w]+)([^\)])*\n(\s)*\)' - severity: warning diff --git a/iosApp/CICDTests.xctestplan b/iosApp/CICDTests.xctestplan index 869a08a6..03e38c55 100644 --- a/iosApp/CICDTests.xctestplan +++ b/iosApp/CICDTests.xctestplan @@ -4,7 +4,7 @@ "id" : "907BC089-7FF9-4CC2-B76C-526FB9AF9732", "name" : "Configuration 1", "options" : { - + "uiTestingScreenshotsLifetime" : "keepNever" } } ], diff --git a/iosApp/Dangerfile b/iosApp/Dangerfile index eb211fb2..752ffe77 100644 --- a/iosApp/Dangerfile +++ b/iosApp/Dangerfile @@ -9,7 +9,6 @@ swiftformat.check_format # Swiftlint swiftlint.binary_path = 'iosApp/Pods/SwiftLint/swiftlint' -swiftlint.config_file = '.swiftlint.yml' swiftlint.max_num_violations = 20 swiftlint.lint_all_files = true swiftlint.lint_files( @@ -33,7 +32,7 @@ xcode_summary.ignored_files = 'iosApp/Pods/**' xcode_summary.inline_mode = true xcode_summary.report xcresultPath -# # Xcov +# Xcov xcov.report( scheme: Constants.TESTS_SCHEME, workspace: "iosApp/#{Constants.WORKSPACE_PATH}", diff --git a/iosApp/fastlane/Constants/Constants.rb b/iosApp/fastlane/Constants/Constants.rb index 14aaea38..da1ce161 100644 --- a/iosApp/fastlane/Constants/Constants.rb +++ b/iosApp/fastlane/Constants/Constants.rb @@ -53,6 +53,11 @@ def self.TESTS_SCHEME 'Survey Staging' end + # a scheme name for testing + def self.FULL_TESTS_SCHEME + 'Survey Staging Extended Tests' + end + # a target name for tests def self.TESTS_TARGET 'SurveyTests' @@ -63,6 +68,11 @@ def self.UI_TESTS_TARGET 'SurveyUITests' end + # a target name for Test Plan + def self.TEST_PLAN + 'CICDTests' + end + # xcov output directory path def self.XCOV_OUTPUT_DIRECTORY_PATH './fastlane/xcov_output' diff --git a/iosApp/fastlane/Fastfile b/iosApp/fastlane/Fastfile index 6895020e..9a676e29 100644 --- a/iosApp/fastlane/Fastfile +++ b/iosApp/fastlane/Fastfile @@ -52,6 +52,14 @@ platform :ios do lane :build_and_test do test_manager.build_and_test( scheme: Constants.TESTS_SCHEME, + testplan: Constants.TEST_PLAN + ) + end + + desc 'Build and Full Test' + lane :build_and_full_test do + test_manager.build_and_test( + scheme: Constants.FULL_TESTS_SCHEME, targets: [Constants.TESTS_TARGET, Constants.UI_TESTS_TARGET] ) end diff --git a/iosApp/fastlane/Managers/TestManager.rb b/iosApp/fastlane/Managers/TestManager.rb index 0647cfbe..184dd0fb 100644 --- a/iosApp/fastlane/Managers/TestManager.rb +++ b/iosApp/fastlane/Managers/TestManager.rb @@ -20,4 +20,18 @@ def build_and_test(scheme:, targets:) fail_build: false ) end + + def build_and_test(scheme:, testplan:) + @fastlane.scan( + scheme: scheme, + device: @device, + output_directory: @output_directory, + code_coverage: true, + result_bundle: true, + testplan: testplan, + number_of_retries: 2, + output_remove_retry_attempts: true, + fail_build: false + ) + end end