diff --git a/.github/workflows/sdk-size-metrics.yml b/.github/workflows/sdk-size-metrics.yml index 50745c71..e88d63c6 100644 --- a/.github/workflows/sdk-size-metrics.yml +++ b/.github/workflows/sdk-size-metrics.yml @@ -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 }} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index ee83ca11..8ae5470f 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -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 @@ -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.')