Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dd5dc39
Remove unnecessary gitignore file
RowbDowg Dec 27, 2022
300911f
Update deprecated junit imports
RowbDowg Dec 27, 2022
477b2af
Fix incorrect way round "expected" and "actual" values
RowbDowg Dec 27, 2022
1a30857
Mock responses to convert them to actual unit tests
RowbDowg Dec 27, 2022
7857429
Refactor to share folding logic
RowbDowg Dec 27, 2022
7c3c3d2
Refactor to share get identity and traits request
RowbDowg Dec 27, 2022
7ece258
Refactor to share get feature flag logic
RowbDowg Dec 27, 2022
7964e8a
Use default baseUrl rather than allowing nullable string
RowbDowg Dec 27, 2022
a363359
Combine analytics creation logic
RowbDowg Dec 27, 2022
d98737f
Neaten api endpoints enum
RowbDowg Dec 27, 2022
9ab02dd
Add android verification workflow
RowbDowg Jan 2, 2023
77b7dfc
Update gradle version
RowbDowg Jan 2, 2023
7c9da2b
Change gradle settings to kotlin
RowbDowg Jan 2, 2023
f5a9dc9
Require repositories to be declared in global gradle settings not gra…
RowbDowg Jan 2, 2023
3c8c620
Update global gradle build file to kotlin
RowbDowg Jan 2, 2023
a765639
Update library gradle build file to kotlin
RowbDowg Jan 2, 2023
ed06768
Improve gradle task test reporting
RowbDowg Jan 2, 2023
f6ebb15
Improve gradle task test reporting
RowbDowg Jan 3, 2023
7ec7e62
Bump plugin versions
RowbDowg Jan 3, 2023
febc919
Bump dependency versions
RowbDowg Jan 4, 2023
966746d
Minor update to improve names
RowbDowg Jan 6, 2023
e2dfd7e
Add kover to report code coverage
RowbDowg Jan 8, 2023
4563cc3
Add code coverage to verify workflow
RowbDowg Jan 8, 2023
91cb558
Verify code coverage is at the level required after uploading coverag…
RowbDowg Jan 8, 2023
62547b4
Remove currently unused dependencies
RowbDowg Jan 8, 2023
b182618
Upload merged xml report and generate code coverage comment
RowbDowg Jan 8, 2023
3594761
Fix spelling mistake
RowbDowg Jan 8, 2023
3fc1243
Fix report location
RowbDowg Jan 8, 2023
71fb1ae
Stop using merged reports as we only have one module that matters
RowbDowg Jan 8, 2023
bba2c0c
Merge remote-tracking branch 'origin/main' into monitor-test-coverage
RowbDowg Jan 9, 2023
d3884f1
Add test to verify analytics creation behaviour
RowbDowg Jan 10, 2023
de61fea
Update verify workflow to give it more permissions
RowbDowg Jan 11, 2023
2093e40
Give the verify workflow more permissions
RowbDowg Jan 11, 2023
234d508
Separate reporting workflow from verifying one
RowbDowg Jan 13, 2023
81be6b6
Reference local action
RowbDowg Jan 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/prepare-gradle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Configure gradle"
description: ""

inputs:
java-version:
description: "Java Version"
default: "11"
distribution:
description: "Java Distribution"
default: "temurin"

runs:
using: "composite"
steps:
- name: Setup JDK 11
uses: actions/setup-java@v3
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.distribution }}
cache: gradle
- name: Grant execute permission for gradlew
shell: bash
run: chmod +x gradlew
31 changes: 31 additions & 0 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Report test results

on:
pull_request:
branches:
- "main"

jobs:
report:
name: Report Code Coverage
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-gradle

- name: Generate coverage report
run: ./gradlew koverXmlReport
- name: Report test code coverage
id: kover
uses: mi-kas/kover-report@v1
with:
path: ${{ github.workspace }}/FlagsmithClient/build/reports/kover/xml/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: Code Coverage
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 80
15 changes: 5 additions & 10 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
cache: gradle
- uses: ./.github/actions/prepare-gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Unit tests
run: ./gradlew test --stacktrace
- name: Run unit tests
run: ./gradlew check -x koverVerify
- name: Verify code coverage level
run: ./gradlew koverVerify
25 changes: 23 additions & 2 deletions FlagsmithClient/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import groovy.time.TimeCategory
import kotlinx.kover.api.CounterType
import kotlinx.kover.api.VerificationTarget
import kotlinx.kover.api.VerificationValueType
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import java.util.Date

plugins {
id("com.android.library")
kotlin("android")
id("org.jetbrains.kotlinx.kover")
id("maven-publish")
}

Expand Down Expand Up @@ -51,8 +55,25 @@ dependencies {
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
testImplementation("org.mock-server:mockserver-netty-no-dependencies:5.14.0")
androidTestImplementation("androidx.test.ext:junit:1.1.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
}

kover {
filters {
classes {
excludes += listOf("${android.namespace}.BuildConfig")
}
}
verify {
rule {
target = VerificationTarget.ALL
bound {
minValue = 60
maxValue = 100
counter = CounterType.LINE
valueType = VerificationValueType.COVERED_PERCENTAGE
}
}
}
}

tasks.withType(Test::class) {
Expand Down
13 changes: 13 additions & 0 deletions FlagsmithClient/src/test/java/com/flagsmith/FeatureFlagTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertThrows
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -130,4 +131,16 @@ class FeatureFlagTests {
assertTrue(result.getOrThrow())
}
}

@Test
fun testThrowsExceptionWhenCreatingAnalyticsWithoutAContext() {
val exception = assertThrows(IllegalArgumentException::class.java) {
flagsmith = Flagsmith(
environmentKey = "",
baseUrl = "http://localhost:${mockServer.localPort}",
enableAnalytics = true
)
}
assertEquals("Flagsmith requires a context to use the analytics feature", exception.message)
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("com.android.application").version("7.3.1").apply(false)
id("com.android.library").version("7.3.1").apply(false)
kotlin("android").version("1.8.0").apply(false)
id("org.jetbrains.kotlinx.kover").version("0.6.1").apply(false)
}

val clean by tasks.registering(Delete::class) {
Expand Down