fastlane-plugin-stream_actions 0.3.94 → 0.3.96

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: f9a5a2923c5b1d82d4317903160697b17155f1994ecddd28cff49c25ad0bd55a
4
- data.tar.gz: 69d56018e538008e9c9240373e5d4bfcaf0d04585baaf4e1c00a981a4b535dc2
3
+ metadata.gz: f4d4b91014b916f6635527970ef5af40a5dcec63b154961947fe0d8e59a7686f
4
+ data.tar.gz: '08668d238438d7f345bc28916e0de1433e9201758a07ccefedad4772798803d3'
5
5
  SHA512:
6
- metadata.gz: 905601f4a4cec4c236f9a6638a7e96ed83d4b0858f12a64ddb65febf621f44c06e2f1af9b42077c7b8ac2f26ea04f39a5a29243f8792d96464d4d064df5b975c
7
- data.tar.gz: 4beb10e77c0df972b27366af49ad5ca3fee7c922bb801cc93b57d25c65cda51484c68f93a952c75cc8dc5639cdb58e47e5897ce0def27a52191db33149411129
6
+ metadata.gz: ac4c06140fbbce4f1e2d2310e0c854ccbbd71434ba566b70c428893bd20241696a11ccc7fcbdac042188c64bf6ef2fb9bf46945977c8e7e71c182deab45544de
7
+ data.tar.gz: 5cfeb923189bdcd5aab64d9b293170cca8ccb932d07cdae4a2002aea7730f280c286b36e496a21939bbe6878b6446ee85946a67da2d08945686ed9f5c9014544
@@ -2,42 +2,87 @@ module Fastlane
2
2
  module Actions
3
3
  class ShowDetailedSdkSizeAction < Action
4
4
  def self.run(params)
5
+ is_release = other_action.current_branch.include?('release/')
5
6
  metrics_dir = 'metrics'
6
7
  FileUtils.remove_dir(metrics_dir, force: true)
7
8
  sh("git clone git@github.com:GetStream/stream-internal-metrics.git #{metrics_dir}")
8
9
 
9
10
  params[:sdk_names].each do |sdk|
10
- old_linkmap = "metrics/linkmaps/#{sdk}-LinkMap.txt"
11
- new_linkmap = "linkmaps/#{sdk}-LinkMap.txt"
12
- details = other_action.xcsize_diff(
13
- old_linkmap: old_linkmap,
14
- new_linkmap: new_linkmap,
15
- threshold: 1
11
+ metrics_path = "metrics/linkmaps/#{sdk}.json"
12
+ metrics_branch = is_release ? 'release' : 'develop'
13
+ metrics = JSON.parse(File.read(metrics_path))
14
+ old_details = metrics[metrics_branch]
15
+ new_details = other_action.xcsize(
16
+ linkmap: "linkmaps/#{sdk}-LinkMap.txt",
17
+ threshold: params[:threshold]
16
18
  )[:details]
17
19
 
18
- header = "## XCSize: #{sdk}"
20
+ # Compare old linkmap and new linkmap objects sizes
21
+ differences = {}
22
+
23
+ # Handle old linkmap objects
24
+ old_details.each do |object, value|
25
+ new_value = new_details[object] || 0
26
+ diff = new_value - value
27
+ if diff.abs >= params[:threshold]
28
+ differences[object] = diff > 0 ? "+#{diff}" : diff.to_s
29
+ end
30
+ end
31
+
32
+ # Handle objects that are present only in new linkmap
33
+ new_details.each do |object, value|
34
+ if value >= params[:threshold] && !old_details.key?(object)
35
+ differences[object] = "+#{value}"
36
+ end
37
+ end
38
+
39
+ header = "## #{sdk} XCSize"
19
40
  content = "#{header}\nNo changes in SDK size."
20
- unless details.empty?
21
- table = "| `Object` | `Diff (bytes)` |\n| - | - |\n"
22
- details.each { |object, diff| table << "| #{object} | #{diff} |\n" }
23
- content = "#{header}\n#{table}"
41
+ unless differences.empty?
42
+ content = "#{header}\n#{build_collapsible_table(differences)}"
24
43
  end
44
+ UI.important(content)
25
45
 
26
- if ENV['GITHUB_EVENT_NAME'].to_s == 'push' && other_action.current_branch == 'develop'
27
- File.write(old_linkmap, File.read(new_linkmap))
46
+ next unless other_action.is_ci
47
+
48
+ if is_release || (ENV['GITHUB_EVENT_NAME'].to_s == 'push' && other_action.current_branch == 'develop')
49
+ metrics[metrics_branch] = new_details
50
+ File.write(metrics_path, JSON.pretty_generate(metrics))
28
51
  Dir.chdir(metrics_dir) do
29
52
  if sh('git status -s').to_s.empty?
30
53
  UI.important('No changes in linkmap.')
31
54
  else
32
55
  sh('git add -A')
33
- sh("git commit -m 'Update #{sdk_size_path}'")
56
+ sh("git commit -m 'Update #{metrics_path}'")
34
57
  sh('git push')
35
58
  end
36
59
  end
37
60
  end
38
61
 
39
- other_action.pr_comment(text: content, edit_last_comment_with_text: header) if other_action.is_ci
62
+ other_action.pr_comment(text: content, edit_last_comment_with_text: header)
63
+ end
64
+ end
65
+
66
+ def self.build_collapsible_table(differences)
67
+ differences_list = differences.to_a
68
+ visible_count = [5, differences_list.length].min
69
+ hidden_count = differences_list.length - visible_count
70
+ main_row = "| `Object` | `Diff (bytes)` |\n| - | - |\n"
71
+
72
+ table = main_row
73
+ differences_list.first(visible_count).each do |object, diff|
74
+ table << "| #{object} | #{diff} |\n"
40
75
  end
76
+
77
+ if hidden_count > 0
78
+ table << "\n<details>\n<summary>Show #{hidden_count} more objects</summary>\n\n#{main_row}"
79
+ differences_list[visible_count..-1].each do |object, diff|
80
+ table << "| #{object} | #{diff} |\n"
81
+ end
82
+ table << "</details>"
83
+ end
84
+
85
+ table
41
86
  end
42
87
 
43
88
  #####################################################
@@ -45,7 +90,7 @@ module Fastlane
45
90
  #####################################################
46
91
 
47
92
  def self.description
48
- 'Show SDKs objects size'
93
+ 'Show SDK objects size'
49
94
  end
50
95
 
51
96
  def self.available_options
@@ -57,6 +102,13 @@ module Fastlane
57
102
  verify_block: proc do |sdks|
58
103
  UI.user_error!("SDK names array has to be specified") unless sdks.kind_of?(Array) && sdks.size.positive?
59
104
  end
105
+ ),
106
+ FastlaneCore::ConfigItem.new(
107
+ key: :threshold,
108
+ description: 'Set minimum size threshold in bytes',
109
+ optional: true,
110
+ is_string: false,
111
+ default_value: 1
60
112
  )
61
113
  ]
62
114
  end
@@ -58,25 +58,23 @@ module Fastlane
58
58
  FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: benchmark_sizes)
59
59
  FastlaneCore::PrintTable.print_values(title: 'SDK Size', config: params[:branch_sizes])
60
60
 
61
- if other_action.is_ci
62
- if is_release || (ENV['GITHUB_EVENT_NAME'].to_s == 'push' && ["main", "develop"].include?(other_action.current_branch))
63
- benchmark_config[benchmark_key] = params[:branch_sizes]
64
- File.write(sdk_size_path, JSON.pretty_generate(benchmark_config))
65
- Dir.chdir(File.dirname(sdk_size_path)) do
66
- if sh('git status -s').to_s.empty?
67
- UI.important('No changes in SDK sizes benchmarks.')
68
- else
69
- sh('git add -A')
70
- sh("git commit -m 'Update #{sdk_size_path}'")
71
- sh('git push')
72
- end
61
+ return unless other_action.is_ci
62
+
63
+ if is_release || (ENV['GITHUB_EVENT_NAME'].to_s == 'push' && other_action.current_branch == 'develop')
64
+ benchmark_config[benchmark_key] = params[:branch_sizes]
65
+ File.write(sdk_size_path, JSON.pretty_generate(benchmark_config))
66
+ Dir.chdir(File.dirname(sdk_size_path)) do
67
+ if sh('git status -s').to_s.empty?
68
+ UI.important('No changes in SDK sizes benchmarks.')
69
+ else
70
+ sh('git add -A')
71
+ sh("git commit -m 'Update #{sdk_size_path}'")
72
+ sh('git push')
73
73
  end
74
74
  end
75
-
76
- other_action.pr_comment(text: markdown_table, edit_last_comment_with_text: table_header)
77
75
  end
78
76
 
79
- UI.user_error!("#{table_header} benchmark failed.") if markdown_table.include?(fail_status)
77
+ other_action.pr_comment(text: markdown_table, edit_last_comment_with_text: table_header)
80
78
  end
81
79
 
82
80
  #####################################################
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module StreamActions
3
- VERSION = '0.3.94'
3
+ VERSION = '0.3.96'
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.94
4
+ version: 0.3.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - GetStream
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-09 00:00:00.000000000 Z
11
+ date: 2025-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xctest_list