Skip to content

Commit 025eecd

Browse files
authored
Add multiple workflows for coverage tests. (#7470)
Add all SDKs to code coverage workflows. Limit report to only frameworks and exclude xctest etc.
1 parent 9fadbaf commit 025eecd

File tree

3 files changed

+320
-7
lines changed

3 files changed

+320
-7
lines changed

.github/workflows/test_coverage.yml

Lines changed: 201 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ jobs:
1212
if: github.repository == 'Firebase/firebase-ios-sdk' && (github.event.action == 'opened' || github.event.action == 'synchronize')
1313
name: Check changed files
1414
outputs:
15+
abtesting_run_job: ${{ steps.check_files.outputs.abtesting_run_job }}
16+
auth_run_job: ${{ steps.check_files.outputs.auth_run_job }}
1517
database_run_job: ${{ steps.check_files.outputs.database_run_job }}
18+
dynamiclinks_run_job: ${{ steps.check_files.outputs.dynamiclinks_run_job }}
19+
firestore_run_job: ${{ steps.check_files.outputs.firestore_run_job }}
1620
functions_run_job: ${{ steps.check_files.outputs.functions_run_job }}
21+
inappmessaging_run_job: ${{ steps.check_files.outputs.inappmessaging_run_job }}
22+
instanceid_run_job: ${{ steps.check_files.outputs.instanceid_run_job }}
23+
messaging_run_job: ${{ steps.check_files.outputs.messaging_run_job }}
24+
performance_run_job: ${{ steps.check_files.outputs.performance_run_job }}
25+
remoteconfig_run_job: ${{ steps.check_files.outputs.remoteconfig_run_job }}
26+
storage_run_job: ${{ steps.check_files.outputs.storage_run_job }}
1727
base_commit: ${{ steps.check_files.outputs.base_commit }}
1828
runs-on: ubuntu-latest
1929
steps:
@@ -66,8 +76,198 @@ jobs:
6676
name: codecoverage
6777
path: /Users/runner/*.xcresult
6878

79+
pod-lib-lint-abtesting:
80+
needs: check
81+
# Don't run on private repo unless it is a PR.
82+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.abtesting_run_job == 'true'|| github.event.pull_request.merged)
83+
runs-on: macOS-latest
84+
strategy:
85+
matrix:
86+
target: [ios]
87+
steps:
88+
- uses: actions/checkout@v2
89+
- name: Setup Bundler
90+
run: scripts/setup_bundler.sh
91+
- name: Build and test
92+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseABTesting "${{ matrix.target }}"
93+
- uses: actions/upload-artifact@v2
94+
with:
95+
name: codecoverage
96+
path: /Users/runner/*.xcresult
97+
98+
pod-lib-lint-auth:
99+
needs: check
100+
# Don't run on private repo unless it is a PR.
101+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.auth_run_job == 'true'|| github.event.pull_request.merged)
102+
runs-on: macOS-latest
103+
strategy:
104+
matrix:
105+
target: [ios]
106+
steps:
107+
- uses: actions/checkout@v2
108+
- name: Setup Bundler
109+
run: scripts/setup_bundler.sh
110+
- name: Build and test
111+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseAuth "${{ matrix.target }}"
112+
- uses: actions/upload-artifact@v2
113+
with:
114+
name: codecoverage
115+
path: /Users/runner/*.xcresult
116+
117+
pod-lib-lint-dynamiclinks:
118+
needs: check
119+
# Don't run on private repo unless it is a PR.
120+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.dynamiclinks_run_job == 'true'|| github.event.pull_request.merged)
121+
runs-on: macOS-latest
122+
strategy:
123+
matrix:
124+
target: [ios]
125+
steps:
126+
- uses: actions/checkout@v2
127+
- name: Setup Bundler
128+
run: scripts/setup_bundler.sh
129+
- name: Build and test
130+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseDynamicLinks "${{ matrix.target }}"
131+
- uses: actions/upload-artifact@v2
132+
with:
133+
name: codecoverage
134+
path: /Users/runner/*.xcresult
135+
136+
pod-lib-lint-firestore:
137+
needs: check
138+
# Don't run on private repo unless it is a PR.
139+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.firestore_run_job == 'true'|| github.event.pull_request.merged)
140+
runs-on: macOS-latest
141+
strategy:
142+
matrix:
143+
target: [ios]
144+
steps:
145+
- uses: actions/checkout@v2
146+
- name: Setup Bundler
147+
run: scripts/setup_bundler.sh
148+
- name: Build and test
149+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseFirestore "${{ matrix.target }}"
150+
- uses: actions/upload-artifact@v2
151+
with:
152+
name: codecoverage
153+
path: /Users/runner/*.xcresult
154+
155+
pod-lib-lint-inappmessaging:
156+
needs: check
157+
# Don't run on private repo unless it is a PR.
158+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.inappmessaging_run_job == 'true'|| github.event.pull_request.merged)
159+
runs-on: macOS-latest
160+
strategy:
161+
matrix:
162+
target: [ios]
163+
steps:
164+
- uses: actions/checkout@v2
165+
- name: Setup Bundler
166+
run: scripts/setup_bundler.sh
167+
- name: Build and test
168+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInAppMessaging "${{ matrix.target }}"
169+
- uses: actions/upload-artifact@v2
170+
with:
171+
name: codecoverage
172+
path: /Users/runner/*.xcresult
173+
174+
pod-lib-lint-instanceid:
175+
needs: check
176+
# Don't run on private repo unless it is a PR.
177+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.instanceid_run_job == 'true'|| github.event.pull_request.merged)
178+
runs-on: macOS-latest
179+
strategy:
180+
matrix:
181+
target: [ios]
182+
steps:
183+
- uses: actions/checkout@v2
184+
- name: Setup Bundler
185+
run: scripts/setup_bundler.sh
186+
- name: Build and test
187+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseInstanceID "${{ matrix.target }}"
188+
- uses: actions/upload-artifact@v2
189+
with:
190+
name: codecoverage
191+
path: /Users/runner/*.xcresult
192+
193+
pod-lib-lint-messaging:
194+
needs: check
195+
# Don't run on private repo unless it is a PR.
196+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.messaging_run_job == 'true'|| github.event.pull_request.merged)
197+
runs-on: macOS-latest
198+
strategy:
199+
matrix:
200+
target: [ios]
201+
steps:
202+
- uses: actions/checkout@v2
203+
- name: Setup Bundler
204+
run: scripts/setup_bundler.sh
205+
- name: Build and test
206+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseMessaging "${{ matrix.target }}"
207+
- uses: actions/upload-artifact@v2
208+
with:
209+
name: codecoverage
210+
path: /Users/runner/*.xcresult
211+
212+
pod-lib-lint-performance:
213+
needs: check
214+
# Don't run on private repo unless it is a PR.
215+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.performance_run_job == 'true'|| github.event.pull_request.merged)
216+
runs-on: macOS-latest
217+
strategy:
218+
matrix:
219+
target: [ios]
220+
steps:
221+
- uses: actions/checkout@v2
222+
- name: Setup Bundler
223+
run: scripts/setup_bundler.sh
224+
- name: Build and test
225+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebasePerformance "${{ matrix.target }}"
226+
- uses: actions/upload-artifact@v2
227+
with:
228+
name: codecoverage
229+
path: /Users/runner/*.xcresult
230+
231+
pod-lib-lint-remoteconfig:
232+
needs: check
233+
# Don't run on private repo unless it is a PR.
234+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.remoteconfig_run_job == 'true'|| github.event.pull_request.merged)
235+
runs-on: macOS-latest
236+
strategy:
237+
matrix:
238+
target: [ios]
239+
steps:
240+
- uses: actions/checkout@v2
241+
- name: Setup Bundler
242+
run: scripts/setup_bundler.sh
243+
- name: Build and test
244+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseRemoteConfig "${{ matrix.target }}"
245+
- uses: actions/upload-artifact@v2
246+
with:
247+
name: codecoverage
248+
path: /Users/runner/*.xcresult
249+
250+
pod-lib-lint-storage:
251+
needs: check
252+
# Don't run on private repo unless it is a PR.
253+
if: always() && github.repository == 'Firebase/firebase-ios-sdk' && (needs.check.outputs.storage_run_job == 'true'|| github.event.pull_request.merged)
254+
runs-on: macOS-latest
255+
strategy:
256+
matrix:
257+
target: [ios]
258+
steps:
259+
- uses: actions/checkout@v2
260+
- name: Setup Bundler
261+
run: scripts/setup_bundler.sh
262+
- name: Build and test
263+
run: ./scripts/code_coverage_report/pod_test_code_coverage_report.sh FirebaseStorage "${{ matrix.target }}"
264+
- uses: actions/upload-artifact@v2
265+
with:
266+
name: codecoverage
267+
path: /Users/runner/*.xcresult
268+
69269
create_report:
70-
needs: [check, pod-lib-lint-functions, pod-lib-lint-database]
270+
needs: [check, pod-lib-lint-abtesting, pod-lib-lint-auth, pod-lib-lint-database, pod-lib-lint-dynamiclinks, pod-lib-lint-firestore, pod-lib-lint-functions, pod-lib-lint-inappmessaging, pod-lib-lint-instanceid, pod-lib-lint-messaging, pod-lib-lint-performance, pod-lib-lint-remoteconfig, pod-lib-lint-storage]
71271
env:
72272
metrics_service_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
73273
if: always()
Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,63 @@
11
[
2+
{
3+
"sdk": "abtesting",
4+
"filePatterns": [
5+
"FirebaseABTesting.*",
6+
"Interop/Analytics/Public/[^/]+\\.h",
7+
"\\.github/workflows/abtesting\\.yml",
8+
"Gemfile"
9+
]
10+
},
11+
{
12+
"sdk": "auth",
13+
"filePatterns": [
14+
"FirebaseAuth.*",
15+
"Interop/Auth/Public/[^/]+\\.h",
16+
"\\.github/workflows/auth\\.yml",
17+
"Gemfile"
18+
]
19+
},
220
{
321
"sdk": "database",
422
"filePatterns": [
523
"FirebaseDatabase.*",
624
"\\.github/workflows/database\\.yml",
725
"Example/Database/",
8-
"Interop/Auth/Public/.*\\.h"
26+
"Interop/Auth/Public/[^/]+\\.h",
27+
"Gemfile"
28+
]
29+
},
30+
{
31+
"sdk": "dynamiclinks",
32+
"filePatterns": [
33+
"FirebaseDynamicLinks.*",
34+
"\\.github/workflows/dynamiclinks\\.yml",
35+
"Interop/Analytics/Public/[^/]+\\.h",
36+
"Gemfile"
37+
]
38+
},
39+
{
40+
"sdk": "firestore",
41+
"filePatterns": [
42+
"Firestore/.*",
43+
"Interop/Auth/Public/[^/]+\\.h",
44+
"FirebaseCore/Sources/Private",
45+
"FirebaseCore/Sources/Public",
46+
"FirebaseFirestore\\.podspec",
47+
"CMakeLists\\.txt",
48+
"cmake/.*",
49+
"scripts/binary_to_array\\.py",
50+
"scripts/build\\.sh",
51+
"scripts/install_prereqs\\.sh",
52+
"scripts/localize_podfile\\.swift",
53+
"scripts/pod_lib_lint\\.rb",
54+
"scripts/run_firestore_emulator\\.sh",
55+
"scripts/setup_[^/]+",
56+
"scripts/sync_project\\.rb",
57+
"scripts/test_quickstart\\.sh",
58+
"scripts/xcresult_logs\\.py",
59+
"\\.github/workflows/firestore\\.yml",
60+
"Gemfile"
961
]
1062
},
1163
{
@@ -14,7 +66,65 @@
1466
"Functions.*",
1567
"\\.github/workflows/functions\\.yml",
1668
"Interop/Auth/Public/.*\\.h",
17-
"FirebaseMessaging/Sources/Interop/.*\\.h"
69+
"FirebaseMessaging/Sources/Interop/[^/]+\\.h",
70+
"Gemfile"
71+
]
72+
},
73+
{
74+
"sdk": "inappmessaging",
75+
"filePatterns": [
76+
"FirebaseInAppMessaging.*",
77+
"Interop/Analytics/Public/[^/]+\\.h",
78+
"\\.github/workflows/inappmessaging\\.yml",
79+
"Gemfile"
80+
]
81+
},
82+
{
83+
"sdk": "instanceid",
84+
"filePatterns": [
85+
"FirebaseInstanceID.*",
86+
"Firebase/InstanceID/.*",
87+
"Example/InstanceID/.*",
88+
"\\.github/workflows/instanceid\\.yml",
89+
"Gemfile"
90+
]
91+
},
92+
{
93+
"sdk": "messaging",
94+
"filePatterns": [
95+
"FirebaseMessaging/.*",
96+
"Interop/Analytics/Public/[^/]+\\.h",
97+
"FirebaseMessaging\\.podspec",
98+
"\\.github/workflows/messaging\\.yml",
99+
"Gemfile"
100+
]
101+
},
102+
{
103+
"sdk": "performance",
104+
"filePatterns": [
105+
"FirebasePerformance/.*",
106+
"FirebasePerformance\\.podspec",
107+
"\\.github/workflows/performance\\.yml",
108+
"Gemfile"
109+
]
110+
},
111+
{
112+
"sdk": "remoteconfig",
113+
"filePatterns": [
114+
"FirebaseRemoteConfig.*",
115+
"Interop/Analytics/Public/[^/]+\\.h",
116+
"\\.github/workflows/remoteconfig\\.yml",
117+
"Gemfile",
118+
"scripts/generate_access_token\\.sh"
119+
]
120+
},
121+
{
122+
"sdk": "storage",
123+
"filePatterns": [
124+
"FirebaseStorage.*",
125+
"Interop/Auth/Public/[^/]+\\.h",
126+
"\\.github/workflows/storage\\.yml",
127+
"Gemfile"
18128
]
19129
}
20130
]

scripts/code_coverage_report/generate_code_coverage_report/Sources/CoverageReportGenerator/CoverageReportParser.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,29 @@ extension CoverageReportRequestData {
6363
// Get sdk name. resultBundle is like ${SDK}-${platform}. E.g. FirebaseDatabase-ios.
6464
// To display only sdk related tests and exclude non related testing, e.g.
6565
// FirebaseDatabase-ios-GoogleDataTransport.framework,
66+
// FirebaseDatabase-ios-FirebaseCore-Unit-unit.xctest,
6667
// FirebaseDatabase-ios-FirebaseCore.framework, a regex pattern will be
6768
// used to exclude results that are not related in terms of the target names.
6869
let sdk_name = resultBundle.components(separatedBy: "-")[0]
6970
let range = NSRange(location: 0, length: target.name.utf16.count)
71+
let target_pattern = ".*\(sdk_name).*framework"
7072
let sdk_related_coverage_file_pattern = try! NSRegularExpression(
71-
pattern: ".*\(sdk_name).*",
73+
pattern: target_pattern,
7274
options: NSRegularExpression.Options(rawValue: 0)
7375
)
76+
print("Target: \(target.name) is detected.")
7477

7578
if sdk_related_coverage_file_pattern.firstMatch(in: target.name, range: range) != nil {
79+
print(
80+
"Target, \(target.name), fit the pattern, \(target_pattern), and will be involved in the report."
81+
)
7682
results
7783
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: "",
7884
value: target.lineCoverage))
7985
for file in target.files {
8086
results
8187
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: file.name,
8288
value: file.lineCoverage))
83-
results
84-
.append(FileCoverage(sdk: resultBundle + "-" + target.name, type: file.name,
85-
value: file.lineCoverage))
8689
}
8790
}
8891
}

0 commit comments

Comments
 (0)