Skip to content

Commit e2802b5

Browse files
authored
Post binary size reports in presubmits. (#8587)
* Post binary size reports in presubmits. * Compare to the targeted branch head.
1 parent e480aaa commit e2802b5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.github/workflows/health_metrics.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
performance_run_job: ${{ steps.check_files.outputs.performance_run_job }}
2929
remoteconfig_run_job: ${{ steps.check_files.outputs.remoteconfig_run_job }}
3030
storage_run_job: ${{ steps.check_files.outputs.storage_run_job }}
31-
base_commit: ${{ steps.check_files.outputs.base_commit }}
31+
target_branch_head: ${{ steps.check_files.outputs.target_branch_head }}
3232
runs-on: ubuntu-latest
3333
steps:
3434
- name: Checkout code
@@ -47,7 +47,7 @@ jobs:
4747
binary_size_metrics:
4848
needs: check
4949
# Prevent the job from being triggered in fork.
50-
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && github.event.pull_request.merged
50+
if: always() && github.repository == 'Firebase/firebase-ios-sdk'
5151
runs-on: macos-11
5252
strategy:
5353
matrix:
@@ -82,7 +82,7 @@ jobs:
8282
./scripts/health_metrics/create_binary_size_report.sh
8383
env:
8484
PULL_REQUEST_NUM: ${{ github.event.pull_request.number }}
85-
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
85+
BASE_COMMIT: ${{ needs.check.outputs.target_branch_head }}
8686
POSTSUBMIT: ${{ github.event.pull_request.merged }}
8787
SOURCE_BRANCH: ${{ github.base_ref }}
8888

@@ -326,7 +326,7 @@ jobs:
326326
- name: Compare Diff and Post a Report
327327
if: github.event.pull_request.merged != true && github.event.action != 'closed' && github.event.pull_request.head.repo.full_name == github.repository
328328
env:
329-
base_commit: ${{ github.event.pull_request.base.sha }}
329+
base_commit: ${{ needs.check.outputs.target_branch_head }}
330330
run: |
331331
# Get Head commit of the branch, instead of a merge commit created by actions/checkout.
332332
if [ -d "${{steps.download.outputs.download-path}}" ]; then

scripts/health_metrics/get_updated_files.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ set -ex
1717
# Updates in a pull request will generate a code coverage report in a PR.
1818

1919
# Get most rescent ancestor commit.
20-
common_commit=$(git merge-base remotes/origin/${pr_branch} remotes/origin/master)
20+
common_commit=$(git merge-base remotes/origin/${pr_branch} remotes/origin/${GITHUB_BASE_REF})
21+
target_branch_head=$(git rev-parse remotes/origin/${GITHUB_BASE_REF})
2122
echo "The common commit is ${common_commit}."
22-
# Set base commit and this will be used to compare diffs of coverage to the current commit.
23-
echo "::set-output name=base_commit::${common_commit}"
23+
echo "The target branch head commit is ${target_branch_head}."
24+
# Set target branch head and this will be used to compare diffs of coverage to the current commit.
25+
echo "::set-output name=target_branch_head::${target_branch_head}"
2426

2527
cd scripts/health_metrics/generate_code_coverage_report
2628

27-
# List changed file from the base commit. This is generated by comparing the
28-
# head of the branch and the common commit from the master branch.
29-
git diff --name-only $common_commit remotes/origin/${pr_branch} > updated_files.txt
29+
# List changed file from the merged commit. This is generated by comparing the
30+
# merge commit to the head commit from the target branch.
31+
git diff --name-only remotes/origin/${GITHUB_BASE_REF} ${GITHUB_SHA} > updated_files.txt
3032

3133
swift run UpdatedFilesCollector --changed-file-paths updated_files.txt --code-coverage-file-patterns ../code_coverage_file_list.json

0 commit comments

Comments
 (0)