davidliu
Committed by GitHub

Jacoco reporting (#228)

* Jacoco test coverage reporting

* jacoco github action

* fix github action

* publish only summary

* fix github action

* only run unit tests for now

* asdf

* fix file path

* remove github actions for now
... ... @@ -48,6 +48,33 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean assembleRelease livekit-android-sdk:testRelease
# TODO: Figure out appropriate place to run this. Takes ~3 mins, so pretty slow.
# # generates coverage-report.md and publishes as checkrun
# - name: JaCoCo Code Coverage Report
# id: jacoco_reporter
# uses: PavanMudigonda/jacoco-reporter@v4.8
# with:
# coverage_results_path: "client-sdk-android/livekit-android-sdk/build/jacoco/jacoco.xml"
# coverage_report_name: Coverage
# coverage_report_title: JaCoCo
# github_token: ${{ secrets.GITHUB_TOKEN }}
# skip_check_run: false
# minimum_coverage: 60
# fail_below_threshold: false
# publish_only_summary: false
#
# # Publish Coverage Job Summary
# - name: Add Coverage Job Summary
# run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY
#
# # uploads the coverage-report.md artifact
# - name: Upload Code Coverage Artifacts
# uses: actions/upload-artifact@v2
# with:
# name: code-coverage-report-markdown
# path: "*/coverage-results.md"
# retention-days: 7
- name: Import video test keys into gradle properties
if: github.event_name == 'push'
run: |
... ... @@ -58,11 +85,11 @@ jobs:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
- name: Build video test app
if: github.event_name == 'push'
run: ./gradlew video-encode-decode-test:assembleDebug video-encode-decode-test:assembleDebugAndroidTest
- name: Video Encode Decode App upload and Set app id in environment variable.
if: github.event_name == 'push'
run: |
... ... @@ -100,7 +127,7 @@ jobs:
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: Trigger BrowserStack tests
if: github.event_name == 'push'
run: |
... ... @@ -109,7 +136,7 @@ jobs:
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: get version name
if: github.event_name == 'push'
run: echo "::set-output name=version_name::$(cat gradle.properties | grep VERSION_NAME | cut -d "=" -f2)"
... ...
... ... @@ -4,15 +4,17 @@ buildscript {
apply from: 'deps.gradle'
repositories {
google()
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.19'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
... ...
#Thu Apr 29 14:50:17 JST 2021
#Mon May 22 01:18:06 JST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
... ...
... ... @@ -5,6 +5,8 @@ plugins {
id 'kotlin-kapt'
id 'kotlinx-serialization'
id 'com.google.protobuf'
id 'jacoco'
id 'com.dicedmelon.gradle.jacoco-android'
}
android {
... ... @@ -88,6 +90,19 @@ protobuf {
}
}
jacoco {
toolVersion = "0.8.10"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
jacocoAndroidUnitTestReport {
excludes += ['livekit/**',]
}
dokkaHtml {
moduleName.set("livekit-android-sdk")
dokkaSourceSets {
... ...
... ... @@ -17,6 +17,9 @@ class RTCConfigurationTest : BaseTest() {
newConfig::class.java
.declaredFields
.forEach { field ->
if (field.isSynthetic) {
return@forEach
}
assertEquals("Failed on ${field.name}", field.get(originalConfig), field.get(newConfig))
}
}
... ... @@ -53,7 +56,10 @@ class RTCConfigurationTest : BaseTest() {
if (field.name == "iceServers") {
return@forEach
}
// Ignore synthetic fields. Jacoco will create some that aren't relevant to this test.
if (field.isSynthetic) {
return@forEach
}
val value = field.get(config)
val newValue = if (value == null) {
when (field.type) {
... ...