From 24cf1bbfbcf3acaef1a0cead8bd64e3e70eeacfd Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 1 Mar 2022 18:11:51 +0300 Subject: [PATCH 1/7] add iOS merge request workflow --- .github/workflows/merge_request.yml | 10 ++++ fastlane/Fastfile | 91 ++--------------------------- 2 files changed, 15 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/merge_request.yml diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml new file mode 100644 index 0000000..b03eea6 --- /dev/null +++ b/.github/workflows/merge_request.yml @@ -0,0 +1,10 @@ +name: merge request + +on: + pull_request: + branches: + - 'master' + +jobs: + check: + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@add_ios diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 2cee46b..7848f31 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,86 +1,5 @@ -lane :release do |options| - # Checking bump type - bump_type = resolve_bump_type(options) - - # Checking that everything is alright - checkup - - # Checking git - ensure_git_status_clean - ensure_git_branch(branch: "master") - - # Bumping podspec version - version = version_bump_podspec(bump_type: bump_type) - - # Stamping changelog - stamp_changelog(section_identifier: version) - - # Creating release commit and tag - git_commit(path: "CHANGELOG.md", message: "Release #{version}") - add_git_tag(tag: version) - - # Pushing to remote repo - push_to_git_remote(tags: true) - - # Pushing podspec to Cocoapods repo - push_podspec -end - -lane :checkup do - # Linting ruby files - lint_fastfile - - # Linting podspec - pod_lib_lint(allow_warnings: true) - - # Buidling Swift package - build_swift_package -end - -lane :build_swift_package do - project_name = "TinkoffID.xcodeproj" - scheme_name = "TinkoffID-Package" - config_file_name = "Config.xcconfig" - - # Creating configuration file - sh("echo SWIFT_ACTIVE_COMPILATION_CONDITIONS=''> #{config_file_name}") - - # Generating xcode project - sh("swift package generate-xcodeproj --xcconfig-overrides #{config_file_name}") - - # Building generated xcode project - sh("xcodebuild clean build -project ../#{project_name} -sdk iphoneos -scheme '#{scheme_name}'") - - # Cleaning up - sh("rm -f #{config_file_name}") - sh("rm -rf ../#{project_name}") -end - -lane :lint_fastfile do - Dir.chdir("..") do - error_callback = lambda do |result| - UI.user_error!("rubocop execution failed: #{result}") - end - - sh('bundle exec rubocop -c .rubocop.yml', error_callback: error_callback) - end -end - -lane :push_podspec do - podspec_name = "TinkoffID.podspec" - - pod_push( - path: podspec_name, - allow_warnings: true, - skip_tests: true - ) -end - -def resolve_bump_type(options) - valid_bump_types = ['patch', 'minor', 'major'] - bump_type = valid_bump_types.include?(options[:type]) ? options[:type] : nil - - UI.abort_with_message!("Bump type is not specified or incorrect! You can use `type: #{valid_bump_types.join('/')}` to specify it.") unless bump_type - - return bump_type -end +import_from_git( + url: "https://github.com/tinkoff-mobile-tech/workflows.git", # The URL of the repository to import the Fastfile from. + branch: "add_ios", # The branch to checkout on the repository. + path: "fastlane/Fastfile" # The path of the Fastfile in the repository. +) From 321d729a8c1babab130f6d03a49375a096d99660 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Tue, 1 Mar 2022 18:18:14 +0300 Subject: [PATCH 2/7] add .idea to gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 7f53d5b..eb70493 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ fastlane/test_output .DS_Store TinkoffID Debug/TinkoffID Debug.xcodeproj/xcuserdata .build + +# AppCode +.idea + +.swiftpm From c5c8e4ef459284ccb53e90c3981eabc1089b724d Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Mon, 14 Mar 2022 18:54:24 +0300 Subject: [PATCH 3/7] ensure variables --- .github/workflows/merge_request.yml | 4 ++++ .github/workflows/publish.yml | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml index b03eea6..1c7c5f4 100644 --- a/.github/workflows/merge_request.yml +++ b/.github/workflows/merge_request.yml @@ -8,3 +8,7 @@ on: jobs: check: uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@add_ios + with: + xcodeproj_path: "TinkoffID.xcodeproj" + scheme_name: "TinkoffID-Package" + podspec_name: "TinkoffID.podspec" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3a86600 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,15 @@ +name: publish + +on: + pull_request: + branches: + - 'master' + +jobs: + publish: + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.publish.yml@add_ios + with: + xcodeproj_path: "TinkoffID.xcodeproj" + scheme_name: "TinkoffID-Package" + podspec_name: "TinkoffID.podspec" + bump_type: "patch" From 00905b7233dd4fa174cb2dfba73207befd8b4d64 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 17 Mar 2022 19:12:51 +0300 Subject: [PATCH 4/7] add ios publish workflow --- .github/workflows/publish.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3a86600..db12f9c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,13 @@ name: publish on: - pull_request: - branches: - - 'master' + workflow_dispatch: + inputs: + bump_type: + default: "patch" + required: true + type: string + description: "bump type for version" jobs: publish: @@ -12,4 +16,6 @@ jobs: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" podspec_name: "TinkoffID.podspec" - bump_type: "patch" + bump_type: ${{ inputs.bump_type }} + secrets: + cocapods_trunk_token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} \ No newline at end of file From 9d434c7ffb03d2ac417fdbc626219e30b18c7f21 Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 31 Mar 2022 01:39:02 +0300 Subject: [PATCH 5/7] fix review --- .github/workflows/merge_request.yml | 1 - .github/workflows/publish.yml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml index 1c7c5f4..cd4894f 100644 --- a/.github/workflows/merge_request.yml +++ b/.github/workflows/merge_request.yml @@ -11,4 +11,3 @@ jobs: with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" - podspec_name: "TinkoffID.podspec" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index db12f9c..8767682 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: inputs: bump_type: - default: "patch" required: true type: string description: "bump type for version" @@ -15,7 +14,6 @@ jobs: with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" - podspec_name: "TinkoffID.podspec" bump_type: ${{ inputs.bump_type }} secrets: cocapods_trunk_token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} \ No newline at end of file From 16ab8eba52217f31b97afd398453926c0f7d2cde Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 31 Mar 2022 02:23:19 +0300 Subject: [PATCH 6/7] add .swiftlint.yml --- .swiftlint.yml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .swiftlint.yml diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..34c85bf --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,73 @@ +warning_threshold: 1 + +excluded: +- Pods +- /**/Generated + +disabled_rules: +# У линий не должно пыть просбелов справа от текста +- trailing_whitespace +- class_delegate_protocol +# Делегаты должны быть weak, чтобы избежать цикла сильных ссылок +- weak_delegate +# Сложность тела функции должна быть ограничена +- cyclomatic_complexity +# Функции не должны быть слишком длинными +- function_body_length +# Файлы не должны быть слишком длинными +#- file_length +# ToDo remove below and fix violations! +- missing_docs +- legacy_random +- unused_closure_parameter +- colon +- force_try +- force_cast +- overridden_super_call +- vertical_whitespace +- leading_whitespace +- line_length +- operator_usage_whitespace +- trailing_comma +- trailing_newline +opt_in_rules: +# Некоторые переопределяемые методы всегда должны вызывать super +- overridden_super_call +# Некоторые методы не должны вызывать super +- prohibited_super_call +# Избегаем непосредственного вызова .init() +- explicit_init +# Операторы должны быть окружены одиночным пробелом +- operator_usage_whitespace +# Публичные методы/классы/.. должны быть документированы +- missing_docs + + +large_tuple: 4 + +line_length: 150 + +function_parameter_count: + warning: 10 + error: 15 + +file_length: + warning: 500 + +type_body_length: + warning: 400 + error: 450 + +nesting: + type_level: + warning: 3 + statement_level: + warning: 5 + +identifier_name: + min_length: 1 + max_length: 65 + +type_name: + min_length: 3 + max_length: 65 From 47b02a990ad3de1101d2cb5df5ac08a2ef9e8a3b Mon Sep 17 00:00:00 2001 From: "i.o.novikov" Date: Thu, 31 Mar 2022 02:44:04 +0300 Subject: [PATCH 7/7] use v1 version of workflows --- .github/workflows/merge_request.yml | 2 +- .github/workflows/publish.yml | 2 +- Gemfile | 1 + fastlane/Fastfile | 1 - fastlane/Pluginfile | 5 ----- 5 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 fastlane/Pluginfile diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml index cd4894f..b42a8f2 100644 --- a/.github/workflows/merge_request.yml +++ b/.github/workflows/merge_request.yml @@ -7,7 +7,7 @@ on: jobs: check: - uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@add_ios + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@v1 with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8767682..5b204da 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ on: jobs: publish: - uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.publish.yml@add_ios + uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.publish.yml@v1 with: xcodeproj_path: "TinkoffID.xcodeproj" scheme_name: "TinkoffID-Package" diff --git a/Gemfile b/Gemfile index 253977a..9731437 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" gem 'cocoapods', '~> 1.10.1' gem 'fastlane', '~> 2.172.0' +gem 'fastlane-plugin-changelog' gem 'rubocop', '~> 0.93.1' gem 'rubocop-require_tools' diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 7848f31..92939fd 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,5 +1,4 @@ import_from_git( url: "https://github.com/tinkoff-mobile-tech/workflows.git", # The URL of the repository to import the Fastfile from. - branch: "add_ios", # The branch to checkout on the repository. path: "fastlane/Fastfile" # The path of the Fastfile in the repository. ) diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile deleted file mode 100644 index 8f896e8..0000000 --- a/fastlane/Pluginfile +++ /dev/null @@ -1,5 +0,0 @@ -# Autogenerated by fastlane -# -# Ensure this file is checked in to source control! - -gem 'fastlane-plugin-changelog'