Skip to content

Commit 2bde3f0

Browse files
authored
readme enhancements (#61)
* add compatibility note * setup jacoco test coverage * update gha to push report to codecov * add badges * gha fix * gha fix * add more badges * add more badges * filter out generated serializer from coverage report * fix codecov issue
1 parent d3a1a99 commit 2bde3f0

File tree

7 files changed

+73
-7
lines changed

7 files changed

+73
-7
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Android CI
1+
name: CI
22

33
on:
44
push:
@@ -27,6 +27,10 @@ jobs:
2727
${{ runner.os }}-gradle-core-
2828
- name: Run Tests
2929
run: ./gradlew core:test
30+
- name: Generate coverage report
31+
run: ./gradlew core:codeCoverageReport
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@v2
3034

3135
android-test:
3236

@@ -47,6 +51,10 @@ jobs:
4751
${{ runner.os }}-gradle-android-
4852
- name: Run Tests
4953
run: ./gradlew android:test
54+
- name: Generate coverage report
55+
run: ./gradlew android:codeCoverageReport
56+
- name: Upload coverage to Codecov
57+
uses: codecov/codecov-action@v2
5058

5159
destination-test:
5260

@@ -67,6 +75,10 @@ jobs:
6775
${{ runner.os }}-gradle-dest-
6876
- name: Run Tests
6977
run: ./gradlew samples:kotlin-android-app-destinations:test
78+
- name: Generate coverage report
79+
run: ./gradlew samples:kotlin-android-app-destinations:codeCoverageReport
80+
- name: Upload coverage to Codecov
81+
uses: codecov/codecov-action@v2
7082

7183
security:
7284

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Analytics-Kotlin
22
[![](https://jitpack.io/v/segmentio/analytics-kotlin.svg)](https://jitpack.io/#segmentio/analytics-kotlin)
3+
[![](https://github.com/segmentio/analytics-kotlin/actions/workflows/build.yml/badge.svg)](https://github.com/segmentio/analytics-kotlin/actions)
4+
[![codecov](https://codecov.io/gh/segmentio/analytics-kotlin/branch/master/graph/badge.svg)](https://codecov.io/gh/segmentio/analytics-kotlin)
5+
[![Known Vulnerabilities](https://snyk.io/test/github/segmentio/analytics-kotlin/badge.svg)](https://snyk.io/test/github/segmentio/analytics-kotlin)
6+
[![](https://img.shields.io/github/license/segmentio/analytics-kotlin)](https://github.com/segmentio/analytics-kotlin/blob/main/LICENSE)
7+
38

49
The hassle-free way to add Segment analytics to your kotlin app (Android/JVM). Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.
510

611
NOTE: This project is currently in the Beta phase and is covered by Segment's [First Access & Beta Preview Terms](https://segment.com/legal/first-access-beta-preview/). We encourage you
712
to try out this new library. Please provide feedback via Github issues/PRs, and feel free to submit pull requests. This library will eventually
813
supplant our `analytics-android` library.
914

10-
NOTE: If you use pure Java codebase, please refer to [Java Compatibility](JAVA_COMPAT.md) for sample usages.
11-
1215
## How to get started
1316
1. **Collect analytics data** from your app(s).
1417
- The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
@@ -51,6 +54,14 @@ You can find usage documentation at [https://segment.com/docs/sources/mobile/kot
5154

5255
Explore more via the [example projects](samples) which showcase analytics instrumentation on different platforms/languages and usage of plugins. These projects contain sample [plugins](samples/kotlin-android-app/src/main/java/com/segment/analytics/next/plugins) and [destination plugins](samples/kotlin-android-app-destinations/src/main/java/com/segment/analytics/destinations/plugins)
5356

57+
## Compatibility
58+
59+
* If you use pure Java codebase, please refer to [Java Compatibility](JAVA_COMPAT.md) for sample usages.
60+
* The SDK internally uses a number of Java 8 language API through desugaring (see [Java 8+ API desugaring support](https://developer.android.com/studio/write/java8-support#library-desugaring)). Please make sure your project:
61+
* either using Android Gradle plugin 4.0.0 or higher
62+
* or requiring a minimum API level of 26.
63+
64+
5465
## Contributing
5566

5667
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ dependencies {
7777
testImplementation 'androidx.test:core:1.4.0'
7878
}
7979

80-
apply from: rootProject.file('gradle/jitpack-android.gradle')
80+
apply from: rootProject.file('gradle/jitpack-android.gradle')
81+
apply from: rootProject.file('gradle/codecov.gradle')

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ snyk {
4646

4747
task clean(type: Delete) {
4848
delete rootProject.buildDir
49-
}
49+
}
50+
51+
apply from: rootProject.file('gradle/codecov.gradle')

core/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ dependencies {
2929
testImplementation "org.junit.jupiter:junit-jupiter"
3030
}
3131

32-
apply from: rootProject.file('gradle/jitpack-core.gradle')
32+
apply from: rootProject.file('gradle/jitpack-core.gradle')
33+
apply from: rootProject.file('gradle/codecov.gradle')

gradle/codecov.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: 'jacoco'
2+
3+
jacoco {
4+
toolVersion = "0.8.7"
5+
}
6+
7+
task codeCoverageReport(type: JacocoReport) {
8+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', "**/**/*serializer*.*", "**/**/*Companion*.*" ]
9+
def mainSrc = []
10+
def debugTrees = []
11+
def execData = []
12+
if(project.name == rootProject.name) {
13+
subprojects.each {
14+
mainSrc.add("${it.projectDir}/src/main/java")
15+
debugTrees.add(fileTree(dir: "${it.buildDir}/classes", excludes: fileFilter))
16+
debugTrees.add(fileTree(dir: "${it.buildDir}/tmp/kotlin-classes/debugUnitTest", excludes: fileFilter))
17+
execData.add(fileTree(dir: "${it.buildDir}/jacoco", includes: ["*.exec"]))
18+
}
19+
}
20+
else {
21+
mainSrc.add("${project.projectDir}/src/main/java")
22+
debugTrees.add(fileTree(dir: "${project.buildDir}/classes", excludes: fileFilter))
23+
debugTrees.add(fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/debugUnitTest", excludes: fileFilter))
24+
execData.add(fileTree(dir: "${project.buildDir}/jacoco", includes: ["*.exec"]))
25+
}
26+
27+
sourceDirectories.setFrom(files(mainSrc))
28+
classDirectories.setFrom(files(debugTrees))
29+
executionData.setFrom(execData)
30+
31+
reports {
32+
xml.enabled true
33+
xml.destination file("${buildDir}/reports/jacoco/report.xml")
34+
html.enabled true
35+
csv.enabled false
36+
}
37+
}

samples/kotlin-android-app-destinations/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ dependencies {
103103
// For JSON Object testing
104104
testImplementation 'org.json:json:20200518'
105105
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
106-
}
106+
}
107+
108+
apply from: rootProject.file('gradle/codecov.gradle')

0 commit comments

Comments
 (0)