Skip to content

Commit 3d5e6a6

Browse files
[CI] Adjust sdk size report on release PRs (#563)
1 parent 2a63ee4 commit 3d5e6a6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.github/workflows/sdk-size-metrics.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ jobs:
2828

2929
- uses: ./.github/actions/bootstrap
3030

31+
- name: Get branch name
32+
id: get_branch_name
33+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
34+
3135
- name: Run SDK Size Metrics
3236
run: bundle exec fastlane show_frameworks_sizes
3337
timeout-minutes: 30
3438
env:
39+
BRANCH_NAME: ${{ steps.get_branch_name.outputs.branch }}
3540
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
3641
GITHUB_EVENT_NAME: ${{ github.event_name }}
3742
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}

fastlane/Fastfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,16 @@ lane :show_frameworks_sizes do |options|
495495
['metrics/'].each { |dir| FileUtils.remove_dir(dir, force: true) }
496496

497497
sh("git clone #{metrics_git} #{File.dirname(sdk_size_path)}")
498-
develop_sizes = JSON.parse(File.read(sdk_size_path))
498+
is_release = current_branch.include?('release/')
499+
benchmark_config = JSON.parse(File.read(sdk_size_path))
500+
benchmark_key = is_release ? 'release' : 'develop'
501+
benchmark_sizes = benchmark_config[benchmark_key]
499502
branch_sizes = options[:sizes] || frameworks_sizes
500503

501504
table_header = '## SDK Size'
502-
markdown_table = "#{table_header}\n| `title` | `develop` | `branch` | `diff` | `status` |\n| - | - | - | - | - |\n"
505+
markdown_table = "#{table_header}\n| `title` | `#{is_release ? 'previous release' : 'develop'}` | `#{is_release ? 'current release' : 'branch'}` | `diff` | `status` |\n| - | - | - | - | - |\n"
503506
sdk_names.each do |title|
504-
benchmark_value = develop_sizes[title]
507+
benchmark_value = benchmark_sizes[title]
505508
branch_value = branch_sizes[title.to_sym]
506509
max_tolerance = 0.5 # Max Tolerance is 0.5MB
507510
fine_tolerance = 0.25 # Fine Tolerance is 0.25MB
@@ -522,12 +525,13 @@ lane :show_frameworks_sizes do |options|
522525
markdown_table << "|#{title}|#{benchmark_value}MB|#{branch_value}MB|#{diff}MB|#{status_emoji}|\n"
523526
end
524527

525-
FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: develop_sizes)
528+
FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: benchmark_sizes)
526529
FastlaneCore::PrintTable.print_values(title: 'SDK Size', config: branch_sizes)
527530

528531
if is_ci
529-
if ENV['GITHUB_EVENT_NAME'].to_s == 'push'
530-
File.write(sdk_size_path, JSON.pretty_generate(branch_sizes))
532+
if is_release || ENV['GITHUB_EVENT_NAME'].to_s == 'push'
533+
benchmark_config[benchmark_key] = branch_sizes
534+
File.write(sdk_size_path, JSON.pretty_generate(benchmark_config))
531535
Dir.chdir(File.dirname(sdk_size_path)) do
532536
if sh('git status -s', log: false).to_s.empty?
533537
UI.important('No changes in SDK sizes benchmarks.')

0 commit comments

Comments
 (0)