@@ -33,3 +33,48 @@ task uploadCoverageMeasurements(type: UploadMeasurementsTask) {
33
33
reportFiles = files(" $buildDir /coverage-report.json" )
34
34
uploader = " https://storage.googleapis.com/firebase-engprod-metrics/upload_tool.jar"
35
35
}
36
+
37
+ /* Creates a combined jacoco coverage reports of all products. */
38
+ def jacocoReportTasks = rootProject. subprojects. tasks* . withType(JacocoReport )* . toArray(). flatten()
39
+ task createCombinedReport (type : JacocoReport ) {
40
+ mustRunAfter jacocoReportTasks
41
+ classDirectories = files(jacocoReportTasks. classDirectories)
42
+ sourceDirectories = files(jacocoReportTasks. sourceDirectories)
43
+ executionData files(jacocoReportTasks. executionData)
44
+ reports {
45
+ xml {
46
+ enabled true
47
+ destination file(" ${ jacoco.reportsDir} /jacocoCombinedReport.xml" )
48
+ }
49
+ }
50
+ }
51
+
52
+ /* https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables */
53
+ def job = System . getenv(" PROW_JOB_ID" )
54
+ def build = System . getenv(" BUILD_ID" )
55
+ def branch = System . getenv(" PULL_BASE_REF" )
56
+ def base = System . getenv(" PULL_BASE_SHA" )
57
+ def head = System . getenv(" PULL_PULL_SHA" )
58
+ def pr = System . getenv(" PULL_NUMBER" )
59
+
60
+ def commit = head ?: base
61
+
62
+ /* Uploads coverage reports to codecov.io. */
63
+ task codecov (type : Exec ) {
64
+ dependsOn createCombinedReport
65
+
66
+ environment " VCS_COMMIT_ID" , " $commit "
67
+ environment " VCS_BRANCH_NAME" , " $branch "
68
+ environment " VCS_PULL_REQUEST" , " $pr "
69
+ environment " VCS_SLUG" , " firebase/firebase-android-sdk"
70
+ environment " VCS_TAG" , " "
71
+ environment " CI_BUILD_URL" , " "
72
+ environment " CI_BUILD_ID" , " $build "
73
+ environment " CI_JOB_ID" , " $job "
74
+
75
+ commandLine ' bash' , ' /opt/codecov/uploader.sh'
76
+ }
77
+
78
+ // TODO(yifany@): Uploads coverage reports to coveralls.
79
+ // https://github.com/kt3k/coveralls-gradle-plugin
80
+ // https://docs.coveralls.io/supported-ci-services
0 commit comments