Skip to content

Commit

Permalink
Merge pull request #14 from tinkoff-mobile-tech/add_workflow
Browse files Browse the repository at this point in the history
Add workflow
  • Loading branch information
Nov1kov authored Mar 31, 2022
2 parents 67447ee + 47b02a9 commit 09ccf62
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 91 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/merge_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: merge request

on:
pull_request:
branches:
- 'master'

jobs:
check:
uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.merge_request.yml@v1
with:
xcodeproj_path: "TinkoffID.xcodeproj"
scheme_name: "TinkoffID-Package"
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: publish

on:
workflow_dispatch:
inputs:
bump_type:
required: true
type: string
description: "bump type for version"

jobs:
publish:
uses: tinkoff-mobile-tech/workflows/.github/workflows/ios_lib.publish.yml@v1
with:
xcodeproj_path: "TinkoffID.xcodeproj"
scheme_name: "TinkoffID-Package"
bump_type: ${{ inputs.bump_type }}
secrets:
cocapods_trunk_token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ fastlane/test_output
.DS_Store
TinkoffID Debug/TinkoffID Debug.xcodeproj/xcuserdata
.build

# AppCode
.idea

.swiftpm
73 changes: 73 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
90 changes: 4 additions & 86 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,86 +1,4 @@
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.
path: "fastlane/Fastfile" # The path of the Fastfile in the repository.
)
5 changes: 0 additions & 5 deletions fastlane/Pluginfile

This file was deleted.

0 comments on commit 09ccf62

Please sign in to comment.