diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..c8c3976 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,28 @@ +name: Verify + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + +jobs: + test: + name: Run Unit Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup JDK 11 + uses: actions/setup-java@v3 + with: + java-version: "11" + distribution: "temurin" + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Unit tests + run: ./gradlew test --stacktrace \ No newline at end of file diff --git a/FlagsmithClient/build.gradle b/FlagsmithClient/build.gradle deleted file mode 100644 index 5ccb0df..0000000 --- a/FlagsmithClient/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -plugins { - id 'com.android.library' - id 'org.jetbrains.kotlin.android' - id 'maven-publish' -} - -android { - compileSdk 33 - - defaultConfig { - minSdk 21 - targetSdk 33 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - - versionCode 2 - versionName "1.0.0" - - namespace 'com.flagsmith.kotlin' - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - kotlinOptions { - jvmTarget = '1.8' - } - - testOptions { - unitTests.returnDefaultValues = true - } -} - -dependencies { - implementation 'com.google.code.gson:gson:2.9.0' - implementation 'com.github.kittinunf.fuel:fuel:2.3.1' - implementation 'com.github.kittinunf.fuel:fuel-gson:2.3.1' - - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1' - 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' -} - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - from components.release - - groupId = 'com.github.Flagsmith' - artifactId = 'flagsmith-kotlin-android-client' - version = '1.0.0' - } - } - } -} \ No newline at end of file diff --git a/FlagsmithClient/build.gradle.kts b/FlagsmithClient/build.gradle.kts new file mode 100644 index 0000000..c2d99a5 --- /dev/null +++ b/FlagsmithClient/build.gradle.kts @@ -0,0 +1,141 @@ +import groovy.time.TimeCategory +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("maven-publish") +} + +android { + compileSdk = 33 + + defaultConfig { + minSdk = 21 + targetSdk = 33 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + version = "1.0.0" + namespace = "com.flagsmith.kotlin" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + + testOptions { + unitTests.isReturnDefaultValues = true + } +} + +dependencies { + implementation("com.google.code.gson:gson:2.10") + implementation("com.github.kittinunf.fuel:fuel:2.3.1") + implementation("com.github.kittinunf.fuel:fuel-gson:2.3.1") + + 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") +} + +tasks.withType(Test::class) { + testLogging { + events( + TestLogEvent.FAILED, + TestLogEvent.PASSED, + TestLogEvent.SKIPPED, + TestLogEvent.STANDARD_OUT + ) + showExceptions = true + showCauses = true + showStackTraces = true + showStandardStreams = true + exceptionFormat = TestExceptionFormat.FULL + + debug { + events( + TestLogEvent.STARTED, + TestLogEvent.FAILED, + TestLogEvent.PASSED, + TestLogEvent.SKIPPED, + TestLogEvent.STANDARD_ERROR, + TestLogEvent.STANDARD_OUT + ) + exceptionFormat = TestExceptionFormat.FULL + } + info.events = debug.events + info.exceptionFormat = debug.exceptionFormat + } + + afterSuite(KotlinClosure2({ desc: TestDescriptor, result: TestResult -> + if (desc.parent == null) { + val summary = "Results: ${result.resultType} " + + "(" + + "${result.testCount} tests, " + + "${result.successfulTestCount} passed, " + + "${result.failedTestCount} failed, " + + "${result.skippedTestCount} skipped" + + ")" + val fullSummaryLine = summary.contentLine(summary.length) + val lineLength = fullSummaryLine.length + val suiteDescription = "${this.project.name}:${this.name}" + val duration = "in ${TimeCategory.minus(Date(result.endTime), Date(result.startTime))}" + val separator = tableLine(lineLength, "│", "│") + println(""" + ${tableLine(lineLength, "┌", "┐")} + ${suiteDescription.contentLine(lineLength)} + $separator + $fullSummaryLine + $separator + ${duration.contentLine(lineLength)} + ${tableLine(lineLength, "└", "┘")} + Report file: ./${this.reports.html.entryPoint.relativeTo(rootProject.rootDir)} + """.trimIndent() + ) + } + })) +} + +fun String.padToLength(length: Int) = + this + " ".repeat(maxOf(length - this.length, 0)) + +fun String.wrapWith(leading: String, trailing: String = leading) = + "$leading$this$trailing" + +fun String.contentLine(length: Int, extraPadding: String = " ") = + "$extraPadding$this$extraPadding".padToLength(length - 2) + .wrapWith("│") + +fun tableLine(length: Int, leading: String, trailing: String) = + "─".repeat(length - 2).wrapWith(leading, trailing) + +publishing { + publications { + register("release") { + groupId = "com.github.Flagsmith" + artifactId = "flagsmith-kotlin-android-client" + version = "1.0.0" + + afterEvaluate { + from(components["release"]) + } + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index ce9450e..0000000 --- a/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false - id 'org.jetbrains.kotlin.android' version '1.7.20' apply false -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..328306d --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,9 @@ +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) +} + +val clean by tasks.registering(Delete::class) { + delete(rootProject.buildDir) +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..85ea6d8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Jan 02 04:33:47 GMT 2023 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle.kts similarity index 76% rename from settings.gradle rename to settings.gradle.kts index f8f39ef..5b231ab 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -7,13 +7,15 @@ pluginManagement { mavenCentral() } } + dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } + rootProject.name = "Flagsmith" -include ':FlagsmithClient' +include(":FlagsmithClient") \ No newline at end of file