diff --git a/.github/workflows/android-pull-request-ci.yml b/.github/workflows/android-pull-request-ci.yml new file mode 100644 index 00000000..83f6fe88 --- /dev/null +++ b/.github/workflows/android-pull-request-ci.yml @@ -0,0 +1,35 @@ +name: Android Pull Request CI + +on: + pull_request: + branches: [ "main", "develop", "dev" ] + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: Near + + steps: + - name: Checkout the code + uses: actions/checkout@v3 + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + + - name: set up Android SDK + uses: android-actions/setup-android@v2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run test + run: ./gradlew test --parallel + + - name: Run ktlint + run: ./gradlew ktlintCheck diff --git a/Near/.editorconfig b/Near/.editorconfig new file mode 100644 index 00000000..f8d647b3 --- /dev/null +++ b/Near/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true +ktlint_function_naming_ignore_when_annotated_with = Composable \ No newline at end of file diff --git a/Near/app/build.gradle.kts b/Near/app/build.gradle.kts index a103e537..50357e74 100644 --- a/Near/app/build.gradle.kts +++ b/Near/app/build.gradle.kts @@ -25,7 +25,7 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } @@ -73,4 +73,4 @@ dependencies { implementation(libs.room.ktx) kapt(libs.room.compiler) implementation(libs.room.paging) -} \ No newline at end of file +} diff --git a/Near/app/src/androidTest/java/com/alarmy/near/ExampleInstrumentedTest.kt b/Near/app/src/androidTest/java/com/alarmy/near/ExampleInstrumentedTest.kt index 30212ca2..0b5ccbb7 100644 --- a/Near/app/src/androidTest/java/com/alarmy/near/ExampleInstrumentedTest.kt +++ b/Near/app/src/androidTest/java/com/alarmy/near/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package com.alarmy.near -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -21,4 +19,4 @@ class ExampleInstrumentedTest { val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("com.alarmy.near", appContext.packageName) } -} \ No newline at end of file +} diff --git a/Near/app/src/main/java/com/alarmy/near/MainActivity.kt b/Near/app/src/main/java/com/alarmy/near/MainActivity.kt index 308764a5..738551df 100644 --- a/Near/app/src/main/java/com/alarmy/near/MainActivity.kt +++ b/Near/app/src/main/java/com/alarmy/near/MainActivity.kt @@ -22,7 +22,7 @@ class MainActivity : ComponentActivity() { Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> Greeting( name = "Android", - modifier = Modifier.padding(innerPadding) + modifier = Modifier.padding(innerPadding), ) } } @@ -31,10 +31,13 @@ class MainActivity : ComponentActivity() { } @Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { +fun Greeting( + name: String, + modifier: Modifier = Modifier, +) { Text( text = "Hello $name!", - modifier = modifier + modifier = modifier, ) } @@ -44,4 +47,4 @@ fun GreetingPreview() { NearTheme { Greeting("Android") } -} \ No newline at end of file +} diff --git a/Near/app/src/main/java/com/alarmy/near/NearApplication.kt b/Near/app/src/main/java/com/alarmy/near/NearApplication.kt index 0089622d..ddb3869b 100644 --- a/Near/app/src/main/java/com/alarmy/near/NearApplication.kt +++ b/Near/app/src/main/java/com/alarmy/near/NearApplication.kt @@ -4,4 +4,4 @@ import android.app.Application import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp -class NearApplication : Application() \ No newline at end of file +class NearApplication : Application() diff --git a/Near/app/src/main/java/com/alarmy/near/db/AppDatabase.kt b/Near/app/src/main/java/com/alarmy/near/db/AppDatabase.kt index 6eff7bf4..5ffa5434 100644 --- a/Near/app/src/main/java/com/alarmy/near/db/AppDatabase.kt +++ b/Near/app/src/main/java/com/alarmy/near/db/AppDatabase.kt @@ -1,10 +1,7 @@ package com.alarmy.near.db -import androidx.room.Database -import androidx.room.RoomDatabase - // TODO: 실제 Entity, Dao 추가 필요 -//@Database(entities = [], version = 1) -//abstract class AppDatabase : RoomDatabase() { +// @Database(entities = [], version = 1) +// abstract class AppDatabase : RoomDatabase() { // // abstract fun exampleDao(): ExampleDao -//} \ No newline at end of file +// } diff --git a/Near/app/src/main/java/com/alarmy/near/di/AppModule.kt b/Near/app/src/main/java/com/alarmy/near/di/AppModule.kt index 8bf99fe6..464b8cda 100644 --- a/Near/app/src/main/java/com/alarmy/near/di/AppModule.kt +++ b/Near/app/src/main/java/com/alarmy/near/di/AppModule.kt @@ -1,24 +1,8 @@ package com.alarmy.near.di -import android.content.Context -import androidx.room.Room -import com.alarmy.near.repository.ExampleRepository -import com.alarmy.near.repository.ExampleRepositoryImpl -import com.bumptech.glide.Glide -import com.bumptech.glide.RequestManager -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import dagger.Module -import dagger.Provides -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import javax.inject.Singleton - -//@Module -//@InstallIn(SingletonComponent::class) -//object AppModule { +// @Module +// @InstallIn(SingletonComponent::class) +// object AppModule { // @Provides // @Singleton // fun provideGson(): Gson = GsonBuilder().create() @@ -44,4 +28,4 @@ import javax.inject.Singleton // @Provides // @Singleton // fun provideExampleRepository(): ExampleRepository = ExampleRepositoryImpl() -//} \ No newline at end of file +// } diff --git a/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepository.kt b/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepository.kt index 8ddb0fba..d6ea4d99 100644 --- a/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepository.kt +++ b/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepository.kt @@ -2,4 +2,4 @@ package com.alarmy.near.repository interface ExampleRepository { fun getExampleData(): String -} \ No newline at end of file +} diff --git a/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepositoryImpl.kt b/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepositoryImpl.kt index 2ca9549f..4709a51f 100644 --- a/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepositoryImpl.kt +++ b/Near/app/src/main/java/com/alarmy/near/repository/ExampleRepositoryImpl.kt @@ -2,4 +2,4 @@ package com.alarmy.near.repository class ExampleRepositoryImpl : ExampleRepository { override fun getExampleData(): String = "Hello from Repository" -} \ No newline at end of file +} diff --git a/Near/app/src/test/java/com/alarmy/near/ExampleUnitTest.kt b/Near/app/src/test/java/com/alarmy/near/ExampleUnitTest.kt index 6559d3aa..1e2edc86 100644 --- a/Near/app/src/test/java/com/alarmy/near/ExampleUnitTest.kt +++ b/Near/app/src/test/java/com/alarmy/near/ExampleUnitTest.kt @@ -1,8 +1,7 @@ package com.alarmy.near -import org.junit.Test - import org.junit.Assert.* +import org.junit.Test /** * Example local unit test, which will execute on the development machine (host). @@ -14,4 +13,4 @@ class ExampleUnitTest { fun addition_isCorrect() { assertEquals(4, 2 + 2) } -} \ No newline at end of file +} diff --git a/Near/build.gradle.kts b/Near/build.gradle.kts index 889f8ca6..88493a07 100644 --- a/Near/build.gradle.kts +++ b/Near/build.gradle.kts @@ -5,4 +5,5 @@ plugins { alias(libs.plugins.kotlin.compose) apply false alias(libs.plugins.hilt.application) apply false alias(libs.plugins.kotlin.kapt) apply false -} \ No newline at end of file + alias(libs.plugins.ktlint) +} diff --git a/Near/gradle/libs.versions.toml b/Near/gradle/libs.versions.toml index af426b39..b5aa516e 100644 --- a/Near/gradle/libs.versions.toml +++ b/Near/gradle/libs.versions.toml @@ -17,6 +17,8 @@ retrofitVersion = "2.9.0" glideVersion = "4.16.0" # Room roomVersion = "2.6.1" +# Ktlint +ktlintVersion = "13.0.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -51,4 +53,5 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } hilt-application = { id = "com.google.dagger.hilt.android", version.ref = "hiltVersion" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintVersion" } diff --git a/Near/gradlew b/Near/gradlew old mode 100644 new mode 100755 diff --git a/Near/settings.gradle.kts b/Near/settings.gradle.kts index 157b6270..2d06f9e7 100644 --- a/Near/settings.gradle.kts +++ b/Near/settings.gradle.kts @@ -21,4 +21,3 @@ dependencyResolutionManagement { rootProject.name = "Near" include(":app") - \ No newline at end of file