Skip to content

[CI] Adjust sdk size report on release PRs #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/sdk-size-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ jobs:

- uses: ./.github/actions/bootstrap

- name: Get branch name
id: get_branch_name
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT

- name: Run SDK Size Metrics
run: bundle exec fastlane show_frameworks_sizes
timeout-minutes: 30
env:
BRANCH_NAME: ${{ steps.get_branch_name.outputs.branch }}
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
Expand Down
16 changes: 10 additions & 6 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,16 @@ lane :show_frameworks_sizes do |options|
['metrics/'].each { |dir| FileUtils.remove_dir(dir, force: true) }

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

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

FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: develop_sizes)
FastlaneCore::PrintTable.print_values(title: 'Benchmark', config: benchmark_sizes)
FastlaneCore::PrintTable.print_values(title: 'SDK Size', config: branch_sizes)

if is_ci
if ENV['GITHUB_EVENT_NAME'].to_s == 'push'
File.write(sdk_size_path, JSON.pretty_generate(branch_sizes))
if is_release || ENV['GITHUB_EVENT_NAME'].to_s == 'push'
benchmark_config[benchmark_key] = branch_sizes
File.write(sdk_size_path, JSON.pretty_generate(benchmark_config))
Dir.chdir(File.dirname(sdk_size_path)) do
if sh('git status -s', log: false).to_s.empty?
UI.important('No changes in SDK sizes benchmarks.')
Expand Down
Loading