Skip to content

Commit 8256dde

Browse files
authored
Add doc for binary size measurement. (#8930)
* Add doc for binary size measurement.
1 parent 6ba7371 commit 8256dde

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

scripts/health_metrics/README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# Code Coverage Report Generation
1+
# SDK Health Metrics Report Generation
2+
This directory includes code coverage report generation and binary size report generation.
3+
4+
## Code Coverage Report Generation
25

36
This tool is to help generate coverage reports for pull requests. It's defined by the [test_coverage workflow](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/health_metrics/code_coverage_file_list.json).
47

58
Coverage reports of SDK frameworks will be displayed in a pull request if the change is under corresponding SDK file patterns.
69

710
[UpdatedFilesCollector](https://github.com/firebase/firebase-ios-sdk/tree/master/scripts/health_metrics/generate_code_coverage_report/Sources/UpdatedFilesCollector) will detect file changes and compare file paths to file patterns in [code_coverage_file_list.json](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/health_metrics/code_coverage_file_list.json). If updated file paths fit any patterns, corresponding SDK coverage job will be triggered.
811

9-
## Add a new coverage workflow
12+
### Add a new coverage workflow
1013

1114
To create a code coverage workflow for a new SDK,
1215
1. Add `newsdk` and its patterns in [code_coverage_file_list.json](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/health_metrics/code_coverage_file_list.json).
@@ -35,3 +38,35 @@ pod-lib-lint-newsdk:
3538
Add the job name to the [`needs` of `create_report` job](https://github.com/firebase/firebase-ios-sdk/blob/64d50a7f7b3af104a88f9c9203285ae20ea309d4/.github/workflows/test_coverage.yml#L277).
3639

3740
4. If this newsdk podspec has unit test setup, e.g. [database](https://github.com/firebase/firebase-ios-sdk/blob/64d50a7f7b3af104a88f9c9203285ae20ea309d4/FirebaseDatabase.podspec#L44-L57), with `unit_tests.scheme = { :code_coverage => true }`, the code coverage workflow should run unit tests through podspecs and utilize those coverage data and nothing is needed to update here. Otherwise, add [another way of running tests](https://github.com/firebase/firebase-ios-sdk/blob/64d50a7f7b3af104a88f9c9203285ae20ea309d4/scripts/health_metrics/pod_test_code_coverage_report.sh#L26) and generating xcresult bundles with code coverage data in pod_test_code_coverage_report.sh.
41+
42+
## Binary Size Report Generation
43+
44+
This tool is to generate a report for SDK binary sizes.
45+
[create_binary_size_report.sh](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/health_metrics/create_binary_size_report.sh)
46+
will trigger [BinarySizeReportGenerator](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/health_metrics/generate_code_coverage_report/Sources/BinarySizeReportGenerator/BinarySizeReportGeneration.swift)
47+
which will run [cocoapods-size](https://github.com/google/cocoapods-size)
48+
to create a binary size report and either post it in PRs in presubmits or
49+
upload it to the Metrics Service.
50+
51+
### Replicate a binary size measurement for a released SDK
52+
53+
To replicate an SDK binary size measurement locally, we can run the following
54+
script to get the binary size of the latest released FirebaseABTesting SDK.
55+
```
56+
git clone https://github.com/google/cocoapods-size
57+
cd cocoapods-size
58+
python3 measure_cocoapod_size.py --cocoapods FirebaseABTesting
59+
```
60+
61+
More about CocoaPods Size measurement could be found [here](https://github.com/google/cocoapods-size#cocoapods-size-measurement)
62+
63+
### Environment Setup
64+
65+
The `binary_size_metrics` on GitHub Actions [workflow](https://github.com/firebase/firebase-ios-sdk/blob/master/.github/workflows/health-metrics-presubmit.yml)
66+
is running binary size measurement presubmits and postsubmits. The environment for this job
67+
could be found in `runs-on`. More details about the envionment could be found [here](https://github.com/actions/virtual-environments#available-environments).
68+
69+
Factors below might also affect the binary size:
70+
- Each testapp is measured by a default version Xcode from the GitHub Actions environment above.
71+
- Architecture is set to `arm64` and the destination is `generic/platform=iOS Simulator` when a testapp is built.
72+
- The source of dependencies is the [SpecStaging repo](https://github.com/firebase/SpecsStaging), which is for prerelease, and [CocoaPods CDN](https://cdn.cocoapods.org).

0 commit comments

Comments
 (0)