Skip to content

Commit

Permalink
Merge pull request #29 from PeriodPals/setup/ci-android-env
Browse files Browse the repository at this point in the history
CI: Correct issues with CI Android Emulator
  • Loading branch information
coaguila authored Oct 12, 2024
2 parents deefe12 + ea3417d commit 2b6183b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 40 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- main
- 'setup/**'
- 'feat/**'

pull_request:
types:
Expand Down Expand Up @@ -40,6 +42,16 @@ jobs:
distribution: "temurin"
java-version: "17"

# Hello Hello, Alonso here ^_~
# For whatever reason Android SDK is weird and I can't get the emulator to work
# vvv this new plugin should install v12.0 that was published Sep 2024 to be updated
- name: Setup Android SDK
uses: Swisyn/setup-android-sdk@v1
with:
cmdline-tools-version: 11076708
##TODO: Check if I need to install adb and avdmanager manually with cli cmds


# Caching is a very useful part of a CI, as a workflow is executed in a clean environment every time,
# this means that one would need to re-download and re-process gradle files for every run. Which is very time consuming.
#
Expand All @@ -66,7 +78,7 @@ jobs:
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
disable-animations: true
script: echo "Generated AVD snapshot for caching."

- name: Grant execute permission for gradlew
Expand Down Expand Up @@ -97,8 +109,9 @@ jobs:
api-level: 34
target: google_apis
arch: x86_64
avd-name: github
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -skin 1080x1920
disable-animations: true
script: ./gradlew connectedCheck --parallel --build-cache

Expand Down
47 changes: 25 additions & 22 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,26 @@ android {

sonar {
properties {
property("sonar.projectKey", "PeriodPals_periodpals")
property("sonar.projectKey", "periodpals_periodpals")
property("sonar.organization", "periodpals")
property("sonar.host.url", "https://sonarcloud.io")
// Comma-separated paths to the various directories containing the *.xml JUnit report files.
// Each path may be absolute or relative to the project base directory.
property(
"sonar.junit.reportPaths",
"${project.layout.buildDirectory.get()}/test-results/testDebugunitTest/")
"sonar.junit.reportPaths",
"${project.layout.buildDirectory.get()}/test-results/testDebugunitTest/"
)
// Paths to xml files with Android Lint issues. If the main flavor is changed, this file will
// have to be changed too.
property(
"sonar.androidLint.reportPaths",
"${project.layout.buildDirectory.get()}/reports/lint-results-debug.xml")
"sonar.androidLint.reportPaths",
"${project.layout.buildDirectory.get()}/reports/lint-results-debug.xml"
)
// Paths to JaCoCo XML coverage report files.
property(
"sonar.coverage.jacoco.xmlReportPaths",
"${project.layout.buildDirectory.get()}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml")
"sonar.coverage.jacoco.xmlReportPaths",
"${project.layout.buildDirectory.get()}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
)
}
}

Expand Down Expand Up @@ -199,26 +202,26 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
}

val fileFilter =
listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
)
listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
)

val debugTree =
fileTree("${project.layout.buildDirectory.get()}/tmp/kotlin-classes/debug") {
exclude(fileFilter)
}
fileTree("${project.layout.buildDirectory.get()}/tmp/kotlin-classes/debug") {
exclude(fileFilter)
}

val mainSrc = "${project.layout.projectDirectory}/src/main/java"
sourceDirectories.setFrom(files(mainSrc))
classDirectories.setFrom(files(debugTree))
executionData.setFrom(
fileTree(project.layout.buildDirectory.get()) {
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})
fileTree(project.layout.buildDirectory.get()) {
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})
}
17 changes: 1 addition & 16 deletions app/src/main/java/com/android/periodpals/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.periodpals.ui.theme.PeriodPalsAppTheme
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.postgrest.Postgrest
import io.github.jan.supabase.postgrest.from
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
Expand All @@ -43,11 +40,7 @@ class MainActivity : ComponentActivity() {
@Composable
fun CountriesList(dispatcher: CoroutineDispatcher = Dispatchers.IO) {
var countries by remember { mutableStateOf<List<Country>>(listOf()) }
LaunchedEffect(Unit) {
withContext(dispatcher) {
countries = supabase.from("countries").select().decodeList<Country>()
}
}
LaunchedEffect(Unit) { withContext(dispatcher) { countries = listOf(Country(1, "eyyo pogger")) } }
LazyColumn {
items(
countries.size,
Expand All @@ -60,14 +53,6 @@ fun CountriesList(dispatcher: CoroutineDispatcher = Dispatchers.IO) {
}
}

val supabase =
createSupabaseClient(
supabaseUrl = "https://bhhjdcvdcfrxczbudraf.supabase.co",
supabaseKey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJoaGpkY3ZkY2ZyeGN6YnVkcmFmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mjc4ODA4MjMsImV4cCI6MjA0MzQ1NjgyM30.teiPmTsMGNbXBx808uX7enVVLdgxqn4ftvSKjIgfCyQ") {
install(Postgrest)
}

@Serializable
data class Country(
val id: Int,
Expand Down

0 comments on commit 2b6183b

Please sign in to comment.