Skip to content

Commit 8a008b7

Browse files
authored
Merge pull request #8 from SwEnt-Group13/chore/setup-project
Chore/setup project
2 parents b6eb37a + 2eefd36 commit 8a008b7

File tree

21 files changed

+313
-107
lines changed

21 files changed

+313
-107
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
submodules: recursive
2727
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis (if we use Sonar Later)
2828

29+
# This step removes the current gradle cache to avoid any caching issues
30+
- name: Remove current gradle cache
31+
run: rm -rf ~/.gradle
2932

3033
# Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux. Enabling it allows the Android emulator to run faster.
3134
- name: Enable KVM group perms
@@ -40,7 +43,8 @@ jobs:
4043
distribution: "temurin"
4144
java-version: "17"
4245

43-
# Caching is a very useful part of a CI, as a workflow is executed in a clean environment every time,
46+
47+
# Caching is a very useful part of a CI, as a workflow is executed in a clean environement every time,
4448
# this means that one would need to re-download and re-process gradle files for every run. Which is very time consuming.
4549
#
4650
# To avoid that, we cache the the gradle folder to reuse it later.
@@ -69,6 +73,16 @@ jobs:
6973
disable-animations: false
7074
script: echo "Generated AVD snapshot for caching."
7175

76+
77+
# Load google-services.json and local.properties from the secrets
78+
- name: Decode secrets
79+
env:
80+
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
81+
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
82+
run: |
83+
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json
84+
echo "$LOCAL_PROPERTIES" | base64 --decode > ./local.properties
85+
7286
- name: Grant execute permission for gradlew
7387
run: |
7488
chmod +x ./gradlew
@@ -91,7 +105,7 @@ jobs:
91105
./gradlew check --parallel --build-cache
92106
93107
# Run connected tests on the emulator
94-
- name: run tests
108+
- name: Run connected tests
95109
uses: reactivecircus/android-emulator-runner@v2
96110
with:
97111
api-level: 34

app/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
/build
44
/app/build
5-
local.properties
5+
local.properties
6+
google-services.json

app/build.gradle.kts

Lines changed: 136 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1+
2+
import java.io.FileInputStream
3+
import java.util.Properties
4+
15
plugins {
6+
jacoco
27
alias(libs.plugins.androidApplication)
38
alias(libs.plugins.jetbrainsKotlinAndroid)
49
alias(libs.plugins.ktfmt)
10+
alias(libs.plugins.gms)
511
alias(libs.plugins.sonar)
612
id("jacoco")
713
}
814

915
android {
10-
namespace = "com.android.sample"
16+
namespace = "com.android.unio"
1117
compileSdk = 34
1218

19+
// Load the API key from local.properties
20+
val localProperties = Properties()
21+
val localPropertiesFile = rootProject.file("local.properties")
22+
if (localPropertiesFile.exists()) {
23+
localProperties.load(FileInputStream(localPropertiesFile))
24+
}
25+
26+
val mapsApiKey: String = localProperties.getProperty("MAPS_API_KEY") ?: ""
27+
28+
1329
defaultConfig {
14-
applicationId = "com.android.sample"
15-
minSdk = 28
30+
applicationId = "com.android.unio"
31+
minSdk = 29
1632
targetSdk = 34
1733
versionCode = 1
1834
versionName = "1.0"
@@ -21,55 +37,69 @@ android {
2137
vectorDrawables {
2238
useSupportLibrary = true
2339
}
40+
manifestPlaceholders["MAPS_API_KEY"] = mapsApiKey
2441
}
2542

2643
buildTypes {
2744
release {
2845
isMinifyEnabled = false
2946
proguardFiles(
30-
getDefaultProguardFile("proguard-android-optimize.txt"),
31-
"proguard-rules.pro"
47+
getDefaultProguardFile("proguard-android-optimize.txt"),"proguard-rules.pro"
3248
)
3349
}
34-
3550
debug {
3651
enableUnitTestCoverage = true
3752
enableAndroidTestCoverage = true
3853
}
3954
}
40-
41-
testCoverage {
42-
jacocoVersion = "0.8.8"
55+
compileOptions {
56+
sourceCompatibility = JavaVersion.VERSION_11
57+
targetCompatibility = JavaVersion.VERSION_11
58+
}
59+
kotlinOptions {
60+
jvmTarget = "11"
4361
}
44-
4562
buildFeatures {
4663
compose = true
4764
}
48-
4965
composeOptions {
50-
kotlinCompilerExtensionVersion = "1.4.2"
66+
kotlinCompilerExtensionVersion = "1.5.1"
5167
}
52-
53-
compileOptions {
54-
sourceCompatibility = JavaVersion.VERSION_1_8
55-
targetCompatibility = JavaVersion.VERSION_1_8
56-
}
57-
58-
kotlinOptions {
59-
jvmTarget = "1.8"
60-
}
61-
6268
packaging {
6369
resources {
6470
excludes += "/META-INF/{AL2.0,LGPL2.1}"
71+
merges += "META-INF/LICENSE.md"
72+
merges += "META-INF/LICENSE-notice.md"
73+
excludes += "META-INF/LICENSE-notice.md"
74+
excludes += "META-INF/LICENSE.md"
75+
excludes += "META-INF/LICENSE"
76+
excludes += "META-INF/LICENSE.txt"
77+
excludes += "META-INF/NOTICE"
78+
excludes += "META-INF/NOTICE.txt"
6579
}
6680
}
6781

6882
testOptions {
6983
unitTests {
7084
isIncludeAndroidResources = true
85+
7186
isReturnDefaultValues = true
7287
}
88+
packagingOptions {
89+
jniLibs {
90+
useLegacyPackaging = true
91+
}
92+
}
93+
}
94+
95+
96+
buildFeatures {
97+
compose = true
98+
buildConfig = true
99+
}
100+
101+
kotlinOptions {
102+
jvmTarget = "11"
73103
}
74104

75105
// Robolectric needs to be run only in debug. But its tests are placed in the shared source set (test)
@@ -113,12 +143,42 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {
113143
}
114144

115145
dependencies {
146+
147+
implementation(platform(libs.firebase.bom))
148+
implementation(libs.google.firebase.auth.ktx)
149+
150+
implementation(libs.androidx.lifecycle.viewmodel.ktx)
151+
implementation(libs.androidx.lifecycle.livedata.ktx)
152+
153+
implementation(libs.kotlinx.coroutines.core)
154+
implementation(libs.kotlinx.coroutines.android)
155+
156+
// Core
157+
implementation(libs.core.ktx)
116158
implementation(libs.androidx.core.ktx)
159+
implementation(libs.androidx.lifecycle.runtime.ktx)
160+
implementation(libs.androidx.activity.compose)
117161
implementation(libs.androidx.appcompat)
162+
implementation(libs.androidx.constraintlayout)
163+
implementation(libs.androidx.fragment.ktx)
164+
implementation(libs.kotlinx.serialization.json)
165+
166+
// Jetpack Compose UI
167+
implementation(libs.androidx.ui)
168+
implementation(libs.androidx.ui.tooling.preview)
169+
implementation(libs.androidx.ui.graphics)
170+
implementation(libs.androidx.material)
171+
implementation(libs.androidx.material3)
172+
implementation(libs.androidx.navigation.compose)
173+
implementation(platform(libs.androidx.compose.bom))
174+
testImplementation(libs.test.core.ktx)
175+
debugImplementation(libs.androidx.ui.tooling)
176+
debugImplementation(libs.androidx.ui.test.manifest)
118177
implementation(libs.material)
178+
119179
implementation(libs.androidx.lifecycle.runtime.ktx)
120180
implementation(platform(libs.compose.bom))
121-
testImplementation(libs.junit)
181+
122182
globalTestImplementation(libs.androidx.junit)
123183
globalTestImplementation(libs.androidx.espresso.core)
124184

@@ -147,9 +207,56 @@ dependencies {
147207
globalTestImplementation(libs.kaspresso.compose)
148208

149209
// ---------- Robolectric ------------
210+
211+
// Navigation
212+
implementation(libs.androidx.navigation.compose)
213+
implementation(libs.androidx.navigation.fragment.ktx)
214+
implementation(libs.androidx.navigation.ui.ktx)
215+
216+
// Google Service and Maps
217+
implementation(libs.play.services.maps)
218+
implementation(libs.maps.compose)
219+
implementation(libs.maps.compose.utils)
220+
implementation(libs.play.services.auth)
221+
222+
// Firebase
223+
implementation(libs.firebase.database.ktx)
224+
implementation(libs.firebase.firestore)
225+
implementation(libs.firebase.ui.auth)
226+
implementation(libs.firebase.auth.ktx)
227+
implementation(libs.firebase.auth)
228+
229+
// Networking with OkHttp
230+
implementation(libs.okhttp)
231+
232+
// Testing Unit
233+
testImplementation(libs.junit)
234+
androidTestImplementation(libs.mockk)
235+
androidTestImplementation(libs.mockk.android)
236+
androidTestImplementation(libs.mockk.agent)
237+
testImplementation(libs.json)
238+
239+
// Test UI
240+
androidTestImplementation(libs.androidx.junit)
241+
androidTestImplementation(libs.androidx.espresso.core)
242+
androidTestImplementation(libs.androidx.espresso.intents)
243+
androidTestImplementation(libs.androidx.ui.test.junit4)
244+
androidTestImplementation(platform(libs.androidx.compose.bom))
245+
testImplementation(libs.mockito.core)
246+
testImplementation(libs.mockito.inline)
247+
testImplementation(libs.mockito.kotlin)
248+
androidTestImplementation(libs.mockito.android)
249+
androidTestImplementation(libs.mockito.kotlin)
150250
testImplementation(libs.robolectric)
251+
androidTestImplementation(libs.kaspresso)
252+
androidTestImplementation(libs.kaspresso.allure.support)
253+
androidTestImplementation(libs.kaspresso.compose.support)
254+
255+
testImplementation(libs.kotlinx.coroutines.test)
256+
151257
}
152258

259+
153260
tasks.withType<Test> {
154261
// Configure Jacoco for each tests
155262
configure<JacocoTaskExtension> {
@@ -158,8 +265,8 @@ tasks.withType<Test> {
158265
}
159266
}
160267

161-
tasks.register("jacocoTestReport", JacocoReport::class) {
162-
mustRunAfter("testDebugUnitTest", "connectedDebugAndroidTest")
268+
tasks.register("jacocoTestReport",JacocoReport::class) {
269+
mustRunAfter("testDebugUnitTest","connectedDebugAndroidTest")
163270

164271
reports {
165272
xml.required = true
@@ -174,16 +281,15 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
174281
"**/*Test*.*",
175282
"android/**/*.*",
176283
)
177-
178-
val debugTree = fileTree("${project.layout.buildDirectory.get()}/tmp/kotlin-classes/debug") {
284+
val debugTree = fileTree("${project.buildDir}/tmp/kotlin-classes/debug") {
179285
exclude(fileFilter)
180286
}
287+
val mainSrc = "${project.projectDir}/src/main/java"
181288

182-
val mainSrc = "${project.layout.projectDirectory}/src/main/java"
183289
sourceDirectories.setFrom(files(mainSrc))
184290
classDirectories.setFrom(files(debugTree))
185-
executionData.setFrom(fileTree(project.layout.buildDirectory.get()) {
291+
executionData.setFrom(fileTree(project.buildDir) {
186292
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
187293
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
188294
})
189-
}
295+
}

app/src/androidTest/java/com/android/sample/ExampleInstrumentedTest.kt renamed to app/src/androidTest/java/com/android/unio/ExampleInstrumentedTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package com.android.sample
1+
package com.android.unio
22

33
import androidx.compose.ui.test.junit4.createAndroidComposeRule
44
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
import com.android.sample.screen.MainScreen
5+
import com.android.unio.screen.MainScreen
66
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
77
import io.github.kakaocup.compose.node.element.ComposeScreen
8-
import org.junit.Assert.*
98
import org.junit.Rule
109
import org.junit.Test
1110
import org.junit.runner.RunWith

app/src/androidTest/java/com/android/sample/screen/MainScreen.kt renamed to app/src/androidTest/java/com/android/unio/screen/MainScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.android.sample.screen
1+
package com.android.unio.screen
22

33
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
4-
import com.android.sample.resources.C
4+
import com.android.unio.resources.C
55
import io.github.kakaocup.compose.node.element.ComposeScreen
66
import io.github.kakaocup.compose.node.element.KNode
77

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.android.sample
1+
package com.android.unio
22

33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
@@ -7,13 +7,11 @@ import androidx.compose.foundation.layout.fillMaxSize
77
import androidx.compose.material3.MaterialTheme
88
import androidx.compose.material3.Surface
99
import androidx.compose.material3.Text
10-
import androidx.compose.runtime.Composable
1110
import androidx.compose.ui.Modifier
1211
import androidx.compose.ui.semantics.semantics
1312
import androidx.compose.ui.semantics.testTag
14-
import androidx.compose.ui.tooling.preview.Preview
15-
import com.android.sample.resources.C
16-
import com.android.sample.ui.theme.SampleAppTheme
13+
import com.android.unio.resources.C
14+
import com.android.unio.ui.theme.SampleAppTheme
1715

1816
class MainActivity : ComponentActivity() {
1917
override fun onCreate(savedInstanceState: Bundle?) {
@@ -24,20 +22,9 @@ class MainActivity : ComponentActivity() {
2422
Surface(
2523
modifier = Modifier.fillMaxSize().semantics { testTag = C.Tag.main_screen_container },
2624
color = MaterialTheme.colorScheme.background) {
27-
Greeting("Android")
25+
Text("Hello Android!", modifier = Modifier.semantics { testTag = C.Tag.greeting })
2826
}
2927
}
3028
}
3129
}
3230
}
33-
34-
@Composable
35-
fun Greeting(name: String, modifier: Modifier = Modifier) {
36-
Text(text = "Hello $name!", modifier = modifier.semantics { testTag = C.Tag.greeting })
37-
}
38-
39-
@Preview(showBackground = true)
40-
@Composable
41-
fun GreetingPreview() {
42-
SampleAppTheme { Greeting("Android") }
43-
}

0 commit comments

Comments
 (0)