-
Notifications
You must be signed in to change notification settings - Fork 49
Add GitHub Actions workflow for Android build #54
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
base: main
Are you sure you want to change the base?
Changes from all commits
529a854
476f3a8
c0923b8
0bf251f
4ad1250
2642775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||
| name: Android CI | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ main ] | ||||||
| pull_request: | ||||||
| branches: [ main ] | ||||||
|
|
||||||
| jobs: | ||||||
| build: | ||||||
| name: Build Android Project | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v3 | ||||||
|
|
||||||
| - name: Set up JDK | ||||||
| uses: actions/setup-java@v3 | ||||||
|
||||||
| uses: actions/setup-java@v3 | |
| uses: actions/setup-java@v4 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||
| name: Android CI | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ main, ci-cd-pipeline ] | ||||||
|
||||||
| branches: [ main, ci-cd-pipeline ] | |
| branches: [ main ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,9 @@ import java.util.Properties | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| plugins { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id("com.android.application") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kotlin("android") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id("com.google.devtools.ksp") version "1.9.0-1.0.13" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id("org.jetbrains.kotlin.android") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id("jacoco") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id("com.google.devtools.ksp") version "1.9.10-1.0.13" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Load secrets from secrets.properties file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -18,7 +19,6 @@ if (secretsFile.exists()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Function to safely get properties with defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fun getSecretProperty(key: String, defaultValue: String): String { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val value = secretsProperties.getProperty(key, defaultValue) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure the value is not empty, use default if it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return if (value.isBlank()) defaultValue else value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,11 +32,11 @@ android { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| targetSdk = 34 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| versionCode = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| versionName = "1.0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Add secrets as BuildConfig fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Inject secrets as BuildConfig fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildConfigField("String", "OLLAMA_BASE_URL", "\"${getSecretProperty("OLLAMA_BASE_URL", "http://localhost:11434")}\"") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildConfigField("String", "LLAMA_MODEL_NAME", "\"${getSecretProperty("LLAMA_MODEL_NAME", "llama3:8b")}\"") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -67,11 +67,11 @@ android { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| excludes += "/META-INF/notice.txt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildFeatures { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buildConfig = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testOptions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unitTests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isIncludeAndroidResources = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -90,28 +90,64 @@ dependencies { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Room | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.room:room-runtime:2.5.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.room:room-ktx:2.5.2") // Add KTX for Coroutines support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.room:room-ktx:2.5.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ksp("androidx.room:room-compiler:2.5.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("com.squareup.retrofit2:retrofit:2.9.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("com.squareup.retrofit2:converter-gson:2.9.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("com.github.bumptech.glide:glide:4.15.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.navigation:navigation-fragment-ktx:2.7.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| implementation("androidx.navigation:navigation-ui-ktx:2.7.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("junit:junit:4.13.2") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("org.mockito:mockito-core:5.3.1") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("androidx.test.ext:junit:1.1.5") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testImplementation("org.robolectric:robolectric:4.10.3") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Android Testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Android Instrumentation Tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // JaCoCo configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jacoco { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toolVersion = "0.8.10" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks.register<JacocoReport>("jacocoTestReport") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dependsOn("testDebugUnitTest") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reports { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xml.required.set(true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| html.required.set(true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val fileFilter = listOf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/R.class", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/R$*.class", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/BuildConfig.*", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/Manifest*.*", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/*Test*.*" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val debugTree = fileTree("${buildDir}/intermediates/javac/debug/classes") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exclude(fileFilter) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val kotlinDebugTree = fileTree("${buildDir}/tmp/kotlin-classes/debug") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exclude(fileFilter) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| classDirectories.setFrom(files(debugTree, kotlinDebugTree)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sourceDirectories.setFrom(files("src/main/java", "src/main/kotlin")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| executionData.setFrom(fileTree(buildDir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| executionData.setFrom(fileTree(buildDir) { | |
| val debugTree = fileTree(layout.buildDirectory.dir("intermediates/javac/debug/classes").get().asFile) { | |
| exclude(fileFilter) | |
| } | |
| val kotlinDebugTree = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug").get().asFile) { | |
| exclude(fileFilter) | |
| } | |
| classDirectories.setFrom(files(debugTree, kotlinDebugTree)) | |
| sourceDirectories.setFrom(files("src/main/java", "src/main/kotlin")) | |
| executionData.setFrom(fileTree(layout.buildDirectory.get().asFile) { |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using deprecated 'buildDir' property. Consider replacing with 'layout.buildDirectory.get().asFile' for Gradle 8+ compatibility.
| executionData.setFrom(fileTree(buildDir) { | |
| val debugTree = fileTree("${layout.buildDirectory.get().asFile}/intermediates/javac/debug/classes") { | |
| exclude(fileFilter) | |
| } | |
| val kotlinDebugTree = fileTree("${layout.buildDirectory.get().asFile}/tmp/kotlin-classes/debug") { | |
| exclude(fileFilter) | |
| } | |
| classDirectories.setFrom(files(debugTree, kotlinDebugTree)) | |
| sourceDirectories.setFrom(files("src/main/java", "src/main/kotlin")) | |
| executionData.setFrom(fileTree(layout.buildDirectory.get().asFile) { |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using deprecated 'buildDir' property. Consider replacing with 'layout.buildDirectory.get().asFile' for Gradle 8+ compatibility.
| executionData.setFrom(fileTree(buildDir) { | |
| val debugTree = fileTree("${layout.buildDirectory.get().asFile}/intermediates/javac/debug/classes") { | |
| exclude(fileFilter) | |
| } | |
| val kotlinDebugTree = fileTree("${layout.buildDirectory.get().asFile}/tmp/kotlin-classes/debug") { | |
| exclude(fileFilter) | |
| } | |
| classDirectories.setFrom(files(debugTree, kotlinDebugTree)) | |
| sourceDirectories.setFrom(files("src/main/java", "src/main/kotlin")) | |
| executionData.setFrom(fileTree(layout.buildDirectory.get().asFile) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,56 @@ | ||
| // Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
| buildscript { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
| dependencies { | ||
| classpath("com.android.tools.build:gradle:8.1.0") | ||
| classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") | ||
| } | ||
| } | ||
| import com.google.devtools.ksp.gradle.KspExtension | ||
|
|
||
| plugins { | ||
| id("com.android.application") version "8.1.0" apply false | ||
| id("com.android.library") version "8.1.0" apply false | ||
| id("org.jetbrains.kotlin.android") version "1.9.0" apply false | ||
| id("org.jetbrains.kotlin.kapt") version "1.9.0" apply false | ||
| id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false | ||
| id("com.android.application") version "8.1.0" | ||
| id("org.jetbrains.kotlin.android") version "1.9.21" | ||
| id("com.google.devtools.ksp") version "1.9.21-1.0.15" | ||
| } | ||
|
|
||
| tasks.register("clean", Delete::class) { | ||
| delete(rootProject.buildDir) | ||
| } | ||
|
|
||
| allprojects { | ||
| tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { | ||
| kotlinOptions { | ||
| jvmTarget = "17" | ||
| android { | ||
| namespace = "com.example.astraai" | ||
| compileSdk = 34 | ||
|
|
||
| defaultConfig { | ||
| applicationId = "com.example.astraai" | ||
| minSdk = 24 | ||
| targetSdk = 34 | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
|
|
||
| kotlinOptions { | ||
| jvmTarget = "17" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation("androidx.core:core-ktx:1.12.0") | ||
| implementation("androidx.appcompat:appcompat:1.6.1") | ||
| implementation("com.google.android.material:material:1.9.0") | ||
| implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
|
|
||
| implementation("androidx.room:room-runtime:2.5.2") | ||
| implementation("androidx.room:room-ktx:2.5.2") | ||
| ksp("androidx.room:room-compiler:2.5.2") | ||
|
|
||
| testImplementation("junit:junit:4.13.2") | ||
| androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
| androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| pluginManagement { | ||
| repositories { | ||
| gradlePluginPortal() | ||
| google() | ||
| mavenCentral() | ||
| gradlePluginPortal() | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an outdated version of actions/checkout. Consider updating to @v4 for better performance and security improvements.