Skip to content

Commit 512c940

Browse files
authored
Add code coverage README (#7613)
1 parent 7269b20 commit 512c940

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ files without real values, but can be replaced with real plist files. To get you
187187
identifier (e.g. `com.google.Database-Example`)
188188
4. Download the resulting `GoogleService-Info.plist` and add it to the Xcode project.
189189

190+
### Coverage Report Generation
191+
192+
See [scripts/code_coverage_report/README.md](scripts/code_coverage_report/README.md).
193+
190194
## Specific Component Instructions
191195
See the sections below for any special instructions for those components.
192196

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Code Coverage Report Generation
2+
3+
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/code_coverage_report/code_coverage_file_list.json).
4+
5+
Coverage reports of SDK frameworks will be displayed in a pull request if the change is under corresponding SDK file patterns.
6+
7+
[UpdatedFilesCollector](https://github.com/firebase/firebase-ios-sdk/tree/master/scripts/code_coverage_report/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/code_coverage_report/code_coverage_file_list.json). If updated file paths fit any patterns, corresponding SDK coverage job will be triggered.
8+
9+
## Add a new coverage workflow
10+
11+
To create a code coverage workflow for a new SDK,
12+
1. Add `newsdk` and its patterns in [code_coverage_file_list.json](https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/code_coverage_report/code_coverage_file_list.json).
13+
2. Add a new output flag, e.g. `newsdk_run_job`, in the [coverage workflow](https://github.com/firebase/firebase-ios-sdk/blob/64d50a7f7b3af104a88f9c9203285ae20ea309d4/.github/workflows/test_coverage.yml#L17). `newsdk_run_job` should be aligned with the name of SDK `newsdk` in code_coverage_file_list.json.
14+
3. Add a newsdk coverage job in the [workflow](https://github.com/firebase/firebase-ios-sdk/blob/master/.github/workflows/test_coverage.yml):
15+
```
16+
pod-lib-lint-newsdk:
17+
needs: check
18+
# Don't run on private repo unless it is a PR.
19+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.newsdk_run_job == 'true'|| github.event.pull_request.merged)
20+
runs-on: macOS-latest
21+
strategy:
22+
matrix:
23+
target: [iOS]
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Setup Bundler
27+
run: scripts/setup_bundler.sh
28+
- name: Build and test
29+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseNewSDK "${{ matrix.target }}"
30+
- uses: actions/upload-artifact@v2
31+
with:
32+
name: codecoverage
33+
path: /Users/runner/*.xcresult
34+
```
35+
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).
36+
37+
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/code_coverage_report/pod_test_code_coverage_report.sh#L26) and generating xcresult bundles with code coverage data in pod_test_code_coverage_report.sh.
38+

0 commit comments

Comments
 (0)