Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates dependencies and fixes tests #248

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 2
continuation_indent_size = 4
trim_trailing_whitespace = true

[*.{kt,kts}]
indent_style = space
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
indent_size = 2
# possible values: number (e.g. 2), "unset"
continuation_indent_size = 2
# true (recommended) / false
insert_final_newline = unset
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length = 100
trim_trailing_whitespace = true
ktlint_function_naming_ignore_when_annotated_with=Composable

[*.gradle]
indent_size = 2
continuation_indent_size = 2
indent_style = space
8 changes: 5 additions & 3 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest
env:
CC_TEST_REPORTER_ID: 4c45cf8b47a2ab0a5ae149b266e533747e8c3330aa3f5e7d2898d460c6d11562
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -70,7 +68,11 @@ jobs:
${{ runner.os }}-gradle-
- name: Run Tests
run: |
./gradlew testGithubDebugUnitTest --continue --no-daemon
./gradlew koverReport --continue --no-daemon
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ./app/build/reports/kover/project-xml/report.xml
- uses: actions/upload-artifact@v2
with:
name: test-results
Expand Down
107 changes: 38 additions & 69 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
import com.android.build.gradle.internal.lint.AndroidLintTask
import com.android.build.gradle.internal.tasks.factory.dependsOn
import com.google.protobuf.gradle.generateProtoTasks
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
import io.gitlab.arturbosch.detekt.Detekt
import java.io.ByteArrayOutputStream
import java.io.FileInputStream
Expand All @@ -13,15 +10,17 @@ import java.util.Properties
import java.util.TimeZone

plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("com.google.protobuf")
id("org.jmailen.kotlinter")
id("io.gitlab.arturbosch.detekt")
id("idea")
id("com.google.firebase.firebase-perf")
id(libs.plugins.android.application.get().pluginId)
id(libs.plugins.kotlinAndroid.get().pluginId)
id(libs.plugins.kotlinParcelize.get().pluginId)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.protobuf)
alias(libs.plugins.ksp)
alias(libs.plugins.firebasePerf) apply false
alias(libs.plugins.googleServices) apply false
alias(libs.plugins.crashlytics) apply false
alias(libs.plugins.kotlinter)
alias(libs.plugins.detekt)
}

object KeyLoader {
Expand Down Expand Up @@ -84,26 +83,28 @@ val version = "1.5.1"
val code = 124

android {
compileSdk = 31
compileSdk = 34

buildFeatures {
viewBinding = true
compose = true
buildConfig = true
}

defaultConfig {
namespace = "com.kelsos.mbrc"
applicationId = "com.kelsos.mbrc"
minSdk = 23
targetSdk = 31
minSdk = 28
targetSdk = 34
versionCode = code
versionName = version
buildConfigField("String", "GIT_SHA", "\"${gitHash()}\"")
buildConfigField("String", "BUILD_TIME", "\"${buildTime()}\"")

kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas")
}
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

Expand All @@ -122,14 +123,14 @@ android {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf(
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.time.ExperimentalTime",
)
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.get()
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}

signingConfigs {
Expand All @@ -155,7 +156,8 @@ android {
getByName("debug") {
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
isTestCoverageEnabled = true
enableUnitTestCoverage = true
enableAndroidTestCoverage = true

buildConfigField("String", "GIT_SHA", "\"debug_build\"")
buildConfigField("String", "BUILD_TIME", "\"debug_build\"")
Expand All @@ -166,15 +168,15 @@ android {

productFlavors {
create("play") {
apply(plugin = "com.google.gms.google-services")
apply(plugin = "com.google.firebase.crashlytics")
apply(plugin = "com.google.firebase.firebase-perf")
apply(plugin = libs.plugins.firebasePerf.get().pluginId)
apply(plugin = libs.plugins.googleServices.get().pluginId)
apply(plugin = libs.plugins.crashlytics.get().pluginId)
}

create("github") {}
}

packagingOptions {
packaging {
resources {
excludes += "META-INF/ASL2.0"
excludes += "META-INF/LICENSE"
Expand All @@ -185,12 +187,7 @@ android {
}
}

lintOptions {
isAbortOnError = false
}

lint {
isWarningsAsErrors = true
lintConfig = rootProject.file("config/lint.xml")
sarifReport = true
}
Expand All @@ -207,17 +204,6 @@ android {
}
}

detekt {
input = files("src/main/java", "src/main/kotlin")
config = rootProject.files("config/detekt/detekt.yml")
buildUponDefaultConfig = true
reports {
sarif {
enabled = true
}
}
}

val dummyGoogleServicesJson: Configuration by configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
Expand All @@ -227,13 +213,6 @@ val dummyGoogleServicesJson: Configuration by configurations.creating {
}
}

idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}

dependencies {
coreLibraryDesugaring(libs.com.android.tools.desugar)

Expand All @@ -252,7 +231,6 @@ dependencies {
testImplementation(libs.mockk)
testImplementation(libs.robolectric)

implementation(libs.arrowKt)
implementation(libs.androidx.activity.activityCompose)
implementation(libs.androidx.annotation)
implementation(libs.androidx.appcompat)
Expand All @@ -272,6 +250,7 @@ dependencies {
implementation(libs.bundles.androidx.lifecycle)
implementation(libs.bundles.androidx.navigation)
implementation(libs.bundles.androidx.room)
implementation(libs.bundles.arrow)
implementation(libs.bundles.coil)
implementation(libs.bundles.coroutines)
implementation(libs.bundles.google.accompanist)
Expand All @@ -280,11 +259,10 @@ dependencies {
implementation(libs.google.protobuf.javalite)
implementation(libs.squareup.moshi.lib)
implementation(libs.squareup.okio)
implementation(libs.squareup.picasso)
implementation(libs.timber)

kapt(libs.androidx.room.compiler)
kapt(libs.squareup.moshi.codegen)
ksp(libs.androidx.room.compiler)
ksp(libs.squareup.moshi.codegen)

debugImplementation(libs.androidx.fragment.testing)
debugImplementation(libs.squareup.leakcanary)
Expand All @@ -301,7 +279,7 @@ protobuf {

generateProtoTasks {
all().forEach { task ->
task.plugins {
task.builtins {
create("java") {
option("lite")
}
Expand Down Expand Up @@ -329,25 +307,16 @@ tasks {
jvmTarget = "1.8"
}

val lintReleaseSarifOutput =
project.layout.buildDirectory.file("reports/sarif/lint-results-release.sarif")
afterEvaluate {
// Needs to be in afterEvaluate because it's not created yet otherwise
named<AndroidLintTask>("lintGithubRelease") {
sarifReportOutputFile.set(lintReleaseSarifOutput)
}
}

val staticAnalysis by registering {
val detektAll by named<Detekt>("detekt")
val androidLintRelease = named<AndroidLintTask>("lintGithubRelease")
val androidLintRelease = named<AndroidLintTask>("lintReportGithubRelease")

dependsOn(detekt, detektAll, androidLintRelease, lintKotlin)
}

register<Sync>("collectSarifReports") {
val detektAll by named<Detekt>("detekt")
val androidLintRelease = named<AndroidLintTask>("lintGithubRelease")
val androidLintRelease = named<AndroidLintTask>("lintReportGithubRelease")

mustRunAfter(detekt, detektAll, androidLintRelease, lintKotlin, staticAnalysis)

Expand All @@ -357,11 +326,11 @@ tasks {
from(detekt.get().sarifReportFile) {
rename { "detekt.sarif" }
}
from(lintReleaseSarifOutput) {
from(androidLintRelease.get().sarifReportOutputFile) {
rename { "android-lint.sarif" }
}

into("$buildDir/reports/sarif")
into("${layout.buildDirectory}/reports/sarif")

doLast {
logger.info("Copied ${inputs.files.files.filter { it.exists() }} into ${outputs.files.files}")
Expand Down
1 change: 0 additions & 1 deletion app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.kelsos.mbrc"
android:installLocation="auto">

<application tools:ignore="AllowBackup,MissingApplicationIcon">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ class SingleFragmentActivity : AppCompatActivity() {
}

fun setFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
supportFragmentManager
.beginTransaction()
.add(R.id.single_fragment_content, fragment, "TEST")
.commit()
}

@Suppress("unused")
fun replaceFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.single_fragment_content, fragment).commit()
supportFragmentManager
.beginTransaction()
.replace(R.id.single_fragment_content, fragment)
.commit()
}
}
1 change: 0 additions & 1 deletion app/src/github/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.kelsos.mbrc"
android:installLocation="auto">

<application
Expand Down
10 changes: 3 additions & 7 deletions app/src/github/java/com/kelsos/mbrc/FlavorApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ package com.kelsos.mbrc

import com.kelsos.mbrc.metrics.DummySyncMetrics
import com.kelsos.mbrc.metrics.SyncMetrics
import org.koin.core.KoinExperimentalAPI
import org.koin.core.module.Module
import org.koin.dsl.module

@KoinExperimentalAPI
open class FlavorApp : App() {

override fun appModules(): List<Module> {
return super.appModules().plus(
override fun appModules(): List<Module> =
super.appModules().plus(
module {
single<SyncMetrics> { DummySyncMetrics() }
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.kelsos.mbrc.metrics
import timber.log.Timber

class DummySyncMetrics : SyncMetrics {

var start = 0L

override fun librarySyncComplete(metrics: SyncedData) {
Expand Down
Loading
Loading