fastlane-plugin-stream_actions 0.3.40 → 0.3.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d07284bafaf1a903c4ec18f02f3236b9618a11175e0e80014b5a2b208e6adee
4
- data.tar.gz: 25157db9413e49166e0200ca96f685f5e88c8667a35b54105f61797a0d78aea9
3
+ metadata.gz: 374b135474111aaf84a321bdb82a6f96105b7db75bbf2ac3793b588a61c42728
4
+ data.tar.gz: df090e406e1ba7d1c36b5ee8875faec2212808f3683a58f37fc4edb1f90cf2c8
5
5
  SHA512:
6
- metadata.gz: c6743a7959c88d2557bfd4150828bced03de863a75777cbc2ac905adee2b5bd2932a9754440014bdbf5573d18669c06a571ed0515e934c9a7a2d016a471f715c
7
- data.tar.gz: bf7f59c648b09424cf150e11e63b7b5a88a7aa5274f3785c2837e54e3d791d20ceb986efa0ca1a177a576d4ba6fb7748276600b6cd80d343f4babaa1c21ee05e
6
+ metadata.gz: a6feab6e28f7c8734a6361b94a9d90e38c44cde0b8526f3e2821491211472bea19b5cdadfa6a5321bb5cb716858675fa6bc67a54ebb986f738f441dca9b52e0f
7
+ data.tar.gz: f55efa6df99c473b300ceaf7dec15867cd2e457ddb5afbfe9caa9a92d173cf295fc80b623c1400a2bf09bc7343622bd7a8f111042f2dfeacc79508f35cfea0a4
@@ -0,0 +1,55 @@
1
+ module Fastlane
2
+ module Actions
3
+ class GitStatusAction < Action
4
+ def self.run(params)
5
+ UI.user_error!('Extension should be provided') unless params[:ext]
6
+
7
+ untracked_files = sh('git status -s', log: false).split("\n").map(&:strip)
8
+ UI.important("Git Status: #{untracked_files}")
9
+
10
+ deleted_files = select_files_from(files: untracked_files, with_extension: params[:ext], that_start_with: 'D')
11
+ added_files = select_files_from(files: untracked_files, with_extension: params[:ext], that_start_with: ['A', '??'])
12
+ renamed_files = select_files_from(files: untracked_files, with_extension: params[:ext], that_start_with: 'R')
13
+ modified_files = select_files_from(files: untracked_files, with_extension: params[:ext], that_start_with: 'M')
14
+
15
+ renamed_files.each do |renamed_file|
16
+ content = renamed_file.split.drop(1).join.split('->').map(&:strip)
17
+ deleted_files << content.first
18
+ added_files << content.last
19
+ end
20
+ { a: added_files, d: deleted_files, m: modified_files }
21
+ end
22
+
23
+ def select_files_from(files:, with_extension:, that_start_with:)
24
+ files.select do |f|
25
+ f.start_with?(*that_start_with)
26
+ end.map do |f|
27
+ f.split.drop(1).join(' ')
28
+ end.select do |f|
29
+ f.gsub(/['"]/, '').end_with?(with_extension)
30
+ end
31
+ end
32
+
33
+ #####################################################
34
+ # @!group Documentation
35
+ #####################################################
36
+
37
+ def self.description
38
+ 'Git status'
39
+ end
40
+
41
+ def self.available_options
42
+ [
43
+ FastlaneCore::ConfigItem.new(
44
+ key: :ext,
45
+ description: 'Extension'
46
+ )
47
+ ]
48
+ end
49
+
50
+ def self.is_supported?(platform)
51
+ true
52
+ end
53
+ end
54
+ end
55
+ end
@@ -3,11 +3,22 @@ module Fastlane
3
3
  class PrCommentAction < Action
4
4
  def self.run(params)
5
5
  if params[:pr_num]
6
- last_comment = sh("gh pr view #{params[:pr_num]} --json comments --jq '.comments | map(select(.author.login == \"Stream-SDK-Bot\")) | last'")
7
- edit_last_comment = params[:edit_last_comment_with_text] && last_comment.include?(params[:edit_last_comment_with_text]) ? '--edit-last' : ''
8
- sh("gh pr comment #{params[:pr_num]} #{edit_last_comment} -b '#{params[:text]}'")
6
+ additional_args = []
7
+ if params[:edit_last_comment_with_text]
8
+ UI.message('Checking last comment for required pattern.')
9
+ last_comment = sh("gh pr view #{params[:pr_num]} --json comments --jq '.comments | map(select(.author.login == \"Stream-SDK-Bot\")) | last'")
10
+ last_comment_match = params[:edit_last_comment_with_text] && last_comment.include?(params[:edit_last_comment_with_text])
11
+
12
+ if last_comment_match
13
+ additional_args << '--edit-last'
14
+ else
15
+ UI.important('Last comment does not match the pattern.')
16
+ end
17
+ end
18
+ sh("gh pr comment #{params[:pr_num]} -b '#{params[:text]}' #{additional_args.join(' ')}")
19
+ UI.success('PR comment been added.')
9
20
  else
10
- UI.important('Skipping the PR comment because PR number has not been provided.')
21
+ UI.error('Skipping the PR comment because PR number has not been provided.')
11
22
  end
12
23
  end
13
24
 
@@ -0,0 +1,65 @@
1
+ module Fastlane
2
+ module Actions
3
+ class PrCreateAction < Action
4
+ def self.run(params)
5
+ params[:base_branch] ||= 'develop'
6
+ sh("git checkout -b #{params[:head_branch]}")
7
+ sh('git restore Brewfile.lock.json || true')
8
+ sh('git add -A')
9
+ sh("git commit -m '#{params[:title]}'")
10
+ other_action.push_to_git_remote(tags: false)
11
+
12
+ other_action.create_pull_request(
13
+ api_token: ENV.fetch('GITHUB_TOKEN'),
14
+ repo: params[:github_repo],
15
+ title: params[:title],
16
+ head: params[:head_branch],
17
+ base: params[:base_branch],
18
+ body: 'This PR was created automatically by CI.'
19
+ )
20
+ end
21
+
22
+ #####################################################
23
+ # @!group Documentation
24
+ #####################################################
25
+
26
+ def self.description
27
+ 'Create PR'
28
+ end
29
+
30
+ def self.available_options
31
+ [
32
+ FastlaneCore::ConfigItem.new(
33
+ env_name: 'GITHUB_REPOSITORY',
34
+ key: :github_repo,
35
+ description: 'GitHub repo name',
36
+ verify_block: proc do |name|
37
+ UI.user_error!("GITHUB_REPOSITORY should not be empty") if name.to_s.empty?
38
+ end
39
+ ),
40
+ FastlaneCore::ConfigItem.new(
41
+ key: :base_branch,
42
+ description: 'Base branch',
43
+ is_string: true
44
+ ),
45
+ FastlaneCore::ConfigItem.new(
46
+ key: :head_branch,
47
+ description: 'Head branch',
48
+ is_string: true,
49
+ optional: false
50
+ ),
51
+ FastlaneCore::ConfigItem.new(
52
+ key: :title,
53
+ description: 'Title',
54
+ is_string: true,
55
+ optional: false
56
+ )
57
+ ]
58
+ end
59
+
60
+ def self.is_supported?(platform)
61
+ true
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,6 +1,6 @@
1
1
  module Fastlane
2
2
  module Actions
3
- class ShowFrameworksSizeAction < Action
3
+ class ShowSdkSizeAction < Action
4
4
  def self.run(params)
5
5
  warning_status = '🟡' # Warning if a branch is #{max_tolerance} less performant than the benchmark
6
6
  fail_status = '🔴' # Failure if a branch is more than #{max_tolerance} less performant than the benchmark
@@ -18,13 +18,14 @@ module Fastlane
18
18
 
19
19
  table_header = '## SDK Size'
20
20
  markdown_table = "#{table_header}\n| `title` | `#{is_release ? 'previous release' : 'develop'}` | `#{is_release ? 'current release' : 'branch'}` | `diff` | `status` |\n| - | - | - | - | - |\n"
21
- params[:sdk_names].each do |title|
22
- benchmark_value = benchmark_sizes[title]
23
- branch_value = params[:branch_sizes][title.to_sym]
24
- max_tolerance = 0.5 # Max Tolerance is 0.5MB
25
- fine_tolerance = 0.25 # Fine Tolerance is 0.25MB
21
+ params[:branch_sizes].each do |sdk_name, branch_value_kb|
22
+ branch_value_mb = (branch_value_kb / 1024).round(2)
23
+ benchmark_value_kb = benchmark_sizes[sdk_name]
24
+ benchmark_value_mb = (benchmark_value_kb / 1024).round(2)
25
+ max_tolerance = 500 # Max Tolerance is 500KB
26
+ fine_tolerance = 250 # Fine Tolerance is 250KB
26
27
 
27
- diff = (branch_value - benchmark_value).round(2)
28
+ diff = branch_value_kb - benchmark_value_kb
28
29
 
29
30
  status_emoji =
30
31
  if diff < 0
@@ -37,7 +38,7 @@ module Fastlane
37
38
  success_status
38
39
  end
39
40
 
40
- markdown_table << "|#{title}|#{benchmark_value}MB|#{branch_value}MB|#{diff}MB|#{status_emoji}|\n"
41
+ markdown_table << "|#{sdk_name}|#{benchmark_value_mb}MB|#{branch_value_mb}MB|#{diff.round(2)}KB|#{status_emoji}|\n"
41
42
  end
42
43
 
43
44
  FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: benchmark_sizes)
@@ -69,7 +70,7 @@ module Fastlane
69
70
  #####################################################
70
71
 
71
72
  def self.description
72
- 'Show frameworks size'
73
+ 'Show SDKs size'
73
74
  end
74
75
 
75
76
  def self.available_options
@@ -82,14 +83,6 @@ module Fastlane
82
83
  UI.user_error!("GITHUB_REPOSITORY should not be empty") if name.to_s.empty?
83
84
  end
84
85
  ),
85
- FastlaneCore::ConfigItem.new(
86
- key: :sdk_names,
87
- description: 'SDK names',
88
- is_string: false,
89
- verify_block: proc do |sdks|
90
- UI.user_error!("SDK names array has to be specified") unless sdks.kind_of?(Array) && sdks.size.positive?
91
- end
92
- ),
93
86
  FastlaneCore::ConfigItem.new(
94
87
  key: :branch_sizes,
95
88
  description: 'Branch sizes',
@@ -0,0 +1,47 @@
1
+ module Fastlane
2
+ module Actions
3
+ class UpdateSdkSizeInReadmeAction < Action
4
+ def self.run(params)
5
+ readme_content = File.read(params[:readme_path])
6
+
7
+ params[:sizes].each do |key, value|
8
+ framework_size_kb = value
9
+ framework_size_mb = (framework_size_kb / 1024).round(2)
10
+ readme_content.gsub!(%r{(https://img.shields.io/badge/#{key}-)(.*?)(-blue)}, "\\1#{framework_size_mb}\\3")
11
+ end
12
+
13
+ File.write(params[:readme_path], readme_content)
14
+ UI.success('Successfully updated the SDK size labels in README.md!')
15
+ end
16
+
17
+ #####################################################
18
+ # @!group Documentation
19
+ #####################################################
20
+
21
+ def self.description
22
+ 'Update SDKs size in README.md'
23
+ end
24
+
25
+ def self.available_options
26
+ [
27
+ FastlaneCore::ConfigItem.new(
28
+ key: :readme_path,
29
+ description: 'Path to README.md',
30
+ verify_block: proc do |name|
31
+ UI.user_error!("Path to README.md should not be empty") if name.to_s.empty?
32
+ end
33
+ ),
34
+ FastlaneCore::ConfigItem.new(
35
+ key: :sizes,
36
+ description: 'SDK sizes',
37
+ is_string: false
38
+ )
39
+ ]
40
+ end
41
+
42
+ def self.is_supported?(platform)
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module StreamActions
3
- VERSION = '0.3.40'
3
+ VERSION = '0.3.42'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-stream_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.40
4
+ version: 0.3.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - GetStream
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xctest_list
@@ -235,19 +235,22 @@ files:
235
235
  - lib/fastlane/plugin/stream_actions/actions/build_app_for_ios_simulator.rb
236
236
  - lib/fastlane/plugin/stream_actions/actions/current_branch.rb
237
237
  - lib/fastlane/plugin/stream_actions/actions/custom_match.rb
238
+ - lib/fastlane/plugin/stream_actions/actions/git_status.rb
238
239
  - lib/fastlane/plugin/stream_actions/actions/is_check_required.rb
239
240
  - lib/fastlane/plugin/stream_actions/actions/pod_push_safely.rb
240
241
  - lib/fastlane/plugin/stream_actions/actions/pr_comment.rb
242
+ - lib/fastlane/plugin/stream_actions/actions/pr_create.rb
241
243
  - lib/fastlane/plugin/stream_actions/actions/prepare_simulator.rb
242
244
  - lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb
243
245
  - lib/fastlane/plugin/stream_actions/actions/read_changelog.rb
244
246
  - lib/fastlane/plugin/stream_actions/actions/release_ios_sdk.rb
245
247
  - lib/fastlane/plugin/stream_actions/actions/retrieve_xctest_names.rb
246
248
  - lib/fastlane/plugin/stream_actions/actions/setup_git_config.rb
247
- - lib/fastlane/plugin/stream_actions/actions/show_frameworks_size.rb
249
+ - lib/fastlane/plugin/stream_actions/actions/show_sdk_size.rb
248
250
  - lib/fastlane/plugin/stream_actions/actions/testflight_build.rb
249
251
  - lib/fastlane/plugin/stream_actions/actions/touch_changelog.rb
250
252
  - lib/fastlane/plugin/stream_actions/actions/update_copyright.rb
253
+ - lib/fastlane/plugin/stream_actions/actions/update_sdk_size_in_readme.rb
251
254
  - lib/fastlane/plugin/stream_actions/actions/update_testplan.rb
252
255
  - lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb
253
256
  - lib/fastlane/plugin/stream_actions/version.rb