Skip to content

Commit

Permalink
Merge pull request #51 from blyscuit/feature/#8-set-up-network-layer
Browse files Browse the repository at this point in the history
[#8] [KMM] [Backend] Set Up Network layer Core with Ktor
  • Loading branch information
blyscuit authored Oct 27, 2022
2 parents c439204 + 82a5165 commit 2e3aee7
Show file tree
Hide file tree
Showing 34 changed files with 622 additions and 155 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/deploy_ios_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ defaults:
working-directory: iosApp

jobs:
Lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run SwiftLint
uses: norio-nomura/action-swiftlint@3.1.0
with:
args: --strict

build:
name: Build
runs-on: macOS-latest
Expand All @@ -49,6 +35,15 @@ jobs:
# Set fetch-depth (default: 1) to get whole tree
with:
fetch-depth: 0
submodules: recursive

- name: Setup Konfig Properties
env:
KMM_KONFIG_PROPERTIES: ${{ secrets.KMM_KONFIG_PROPERTIES }}
run: |
cd ../buildSrc/src/main/kotlin/myPackage
touch BuildKonfig.kt
echo $KMM_KONFIG_PROPERTIES | base64 --decode > BuildKonfig.kt
- name: Install SSH key
uses: webfactory/ssh-agent@v0.5.4
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/deploy_ios_release_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ defaults:
working-directory: iosApp

jobs:
Lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run SwiftLint
uses: norio-nomura/action-swiftlint@3.1.0
with:
args: --strict

build:
name: Build
runs-on: macOS-latest
Expand All @@ -49,6 +35,15 @@ jobs:
# Set fetch-depth (default: 1) to get whole tree
with:
fetch-depth: 0
submodules: recursive

- name: Setup Konfig Properties
env:
KMM_KONFIG_PROPERTIES: ${{ secrets.KMM_KONFIG_PROPERTIES }}
run: |
cd ../buildSrc/src/main/kotlin/appPackage
touch BuildKonfig.kt
echo $KMM_KONFIG_PROPERTIES | base64 --decode > BuildKonfig.kt
- name: Install SSH key
uses: webfactory/ssh-agent@v0.5.4
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ios_review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ jobs:

- name: Checkout source code
uses: actions/checkout@v2.3.2
with:
submodules: recursive

- name: Setup Konfig Properties
env:
KMM_KONFIG_PROPERTIES: ${{ secrets.KMM_KONFIG_PROPERTIES }}
run: |
cd ../buildSrc/src/main/kotlin/appPackage
touch BuildKonfig.kt
echo $KMM_KONFIG_PROPERTIES | base64 --decode > BuildKonfig.kt
- name: Cache gems
uses: actions/cache@v2
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/kmm_review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ jobs:

- name: Checkout source code
uses: actions/checkout@v2.3.2
with:
submodules: recursive

- name: Setup Konfig Properties
env:
KMM_KONFIG_PROPERTIES: ${{ secrets.KMM_KONFIG_PROPERTIES }}
run: |
cd buildSrc/src/main/kotlin/appPackage
touch BuildKonfig.kt
echo $KMM_KONFIG_PROPERTIES | base64 --decode > BuildKonfig.kt
- name: Run Detekt
run: ./gradlew shared:detekt
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ iosApp/DerivedData
# JetBrains IDEs

.idea
**/GoogleService-*.plist
GoogleService-*.plist
buildSrc/src/main/kotlin/appPackage/BuildKonfig.kt
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "nimble-jsonapi-kotlin"]
path = nimble-jsonapi-kotlin
url = git@github.com:blyscuit/nimble-jsonapi-kotlin.git
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Dir[detekt_dir].each do |file_name|
end

# Android Lint output check
lint_dir = "**/build/reports/lint-result-debug.xml"
lint_dir = "**/build/reports/lint-results-debug.xml"
Dir[lint_dir].each do |file_name|
android_lint.skip_gradle_task = true
android_lint.report_file = file_name
Expand Down
13 changes: 7 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0")
classpath("org.jetbrains.kotlinx:kover:0.6.0")
classpath(Dependency.KOTLIN_GRADLE_PLUGIN)
classpath(Dependency.GRADLE)
classpath(Dependency.DETEKT)
classpath(Dependency.KOVER)
classpath(Dependency.KOTLIN_SERIALIZATION)
classpath(Dependency.BUILD_KONFIG)
}
}

allprojects {
apply {
plugin("jacoco")
plugin("kover")
plugin(Plugin.KOVER)
}
repositories {
google()
Expand Down
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/appPackage/BuildKonfig.kt.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object BuildKonfig {
const val CLIENT_ID = ""
const val CLIENT_SECRET = ""
const val STAGING_BASE_URL = ""
const val PRODUCTION_BASE_URL = ""
const val CLIENT_ID_STAGING = ""
const val CLIENT_SECRET_STAGING = ""
const val UI_TEST_EMAIL = ""
const val UI_TEST_PASSWORD = ""
}
38 changes: 38 additions & 0 deletions buildSrc/src/main/kotlin/appPackage/Dependency.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
object Dependency {

// Kotlin
const val KOTLIN_GRADLE_PLUGIN = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Version.KOTLIN}"
const val GRADLE = "com.android.tools.build:gradle:${Version.GRADLE}"
const val KOTLIN_SERIALIZATION = "org.jetbrains.kotlin:kotlin-serialization:${Version.KOTLIN}"
const val KOTLIN_TEST = "org.jetbrains.kotlin:kotlin-test:${Version.KOTLIN}"

// Kotlinx
const val COROUTINES_CORE = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Version.COROUTINES_CORE}"
const val KOVER = "org.jetbrains.kotlinx:kover:${Version.KOVER}"
const val KOTLINX_SERIALIZATION = "org.jetbrains.kotlinx:kotlinx-serialization-core:${Version.KOTLINX_SERIALIZATION}"
const val COROUTINES_TEST = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Version.COROUTINES_CORE}"

// DETEKT
const val DETEKT = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${Version.DETEKT}"

// Ktor
const val KTOR_CORE = "io.ktor:ktor-client-core:${Version.KTOR}"
const val KTOR_SERIALIZATION = "io.ktor:ktor-client-serialization:${Version.KTOR}"
const val KTOR_LOGGING = "io.ktor:ktor-client-logging:${Version.KTOR}"
const val KTOR_CONTENT_NEGOTIATION = "io.ktor:ktor-client-content-negotiation:${Version.KTOR}"
const val KTOR_JSON = "io.ktor:ktor-serialization-kotlinx-json:${Version.KTOR}"
const val KTOR_ANDROID = "io.ktor:ktor-client-android:${Version.KTOR}"
const val KTOR_IOS = "io.ktor:ktor-client-ios:${Version.KTOR}"
const val KTOR_MOCK = "io.ktor:ktor-client-mock:${Version.KTOR}"

// BuildKonfig
const val BUILD_KONFIG = "com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:${Version.BUILD_KONFIG}"

// Native Coroutines
const val NATIVE_COROUTINES = "com.rickclephas.kmp.nativecoroutines:${Version.NATIVE_COROUTINES_KOTLIN}"

// Koin
const val KOIN = "io.insert-koin:koin-core:${Version.KOIN}"
const val KOIN_TEST = "io.insert-koin:koin-test:${Version.KOIN}"
const val KOIN_ANDROID = "io.insert-koin:koin-android:${Version.KOIN}"
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/appPackage/Module.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Module {
const val JSONAPI_CORE = ":nimble-jsonapi-kotlin:core"
}
16 changes: 16 additions & 0 deletions buildSrc/src/main/kotlin/appPackage/Plugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
object Plugin {
const val ANDROID_APPLICATION = "com.android.application"
const val GOOGLE_SERVICE = "com.google.gms.google-services"
const val ANDROID = "android"

const val MULTIPLATFORM = "multiplatform"
const val COCOAPODS = "native.cocoapods"
const val ANDROID_LIBRARY = "com.android.library"
const val KOTLIN_SERIALIZATION = "plugin.serialization"
const val KOTLINX_SERIALIZATION = "kotlinx-serialization"
const val NATIVE_COROUTINES = "com.rickclephas.kmp.nativecoroutines"
const val BUILD_KONFIG = "com.codingfeline.buildkonfig"

const val KOVER = "kover"
const val DETEKT = "io.gitlab.arturbosch.detekt"
}
18 changes: 18 additions & 0 deletions buildSrc/src/main/kotlin/appPackage/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
object Android {
const val COMPILE_SDK = 32
const val TARGET_SDK = 32
const val MIN_SDK = 26
}

object Version {
const val KOTLIN = "1.7.10"
const val GRADLE = "7.2.2"
const val COROUTINES_CORE = "1.6.4"
const val DETEKT = "1.21.0"
const val KTOR = "2.1.1"
const val KOVER = "0.6.0"
const val BUILD_KONFIG = "0.13.3"
const val KOTLINX_SERIALIZATION = "1.2.2"
const val NATIVE_COROUTINES_KOTLIN = "0.12.6-new-mm"
const val KOIN = "3.2.1"
}
5 changes: 0 additions & 5 deletions buildSrc/src/main/kotlin/myPackage/Versions.kt

This file was deleted.

10 changes: 9 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ android.useAndroidX=true
#MPP
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.enableCInteropCommonization=true

# Support new memory manager iOS https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#switch-to-the-new-mm
kotlin.native.cacheKind=none
kotlin.native.binary.memoryModel=experimental
kotlin.native.binary.freezing=disabled

# Default flavor
buildkonfig.flavor=staging
1 change: 1 addition & 0 deletions iosApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ target 'Survey' do
# KMM
platform :ios, '14.0'
pod 'Shared', :path => '../shared'
pod 'KMPNativeCoroutinesCombine', '0.12.6'

target 'SurveyTests' do
inherit! :search_paths
Expand Down
10 changes: 9 additions & 1 deletion iosApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ PODS:
- IQKeyboardManagerSwift (6.5.10)
- KeychainAccess (4.2.2)
- Kingfisher (7.3.2)
- KMPNativeCoroutinesCombine (0.12.6):
- KMPNativeCoroutinesCore (= 0.12.6)
- KMPNativeCoroutinesCore (0.12.6)
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
Expand Down Expand Up @@ -71,6 +74,7 @@ DEPENDENCIES:
- IQKeyboardManagerSwift
- KeychainAccess
- Kingfisher
- KMPNativeCoroutinesCombine (= 0.12.6)
- Nimble
- NimbleExtension (from `https://github.com/nimblehq/NimbleExtension`, branch `master`)
- Quick
Expand All @@ -97,6 +101,8 @@ SPEC REPOS:
- IQKeyboardManagerSwift
- KeychainAccess
- Kingfisher
- KMPNativeCoroutinesCombine
- KMPNativeCoroutinesCore
- nanopb
- Nimble
- PromisesObjC
Expand Down Expand Up @@ -135,6 +141,8 @@ SPEC CHECKSUMS:
IQKeyboardManagerSwift: 52962c76ab33532f15ad9f3ff4e5715eda5335bb
KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
Kingfisher: 0086ad83719761ba9b2cdaf6ef4d5b4878cbae23
KMPNativeCoroutinesCombine: 9c82dee7ba35c6acff4b35a9757bfecae8b335fd
KMPNativeCoroutinesCore: 35da0312355f0e911cbb16923aea3389894affca
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84
NimbleExtension: acad4290f27afd4241b1ea20f8597889085e2ce7
Expand All @@ -150,6 +158,6 @@ SPEC CHECKSUMS:
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
Wormholy: 3252bc3e55a1847ef9a0976c1377bd77bf3635fa

PODFILE CHECKSUM: 1b16a2203f7a7e5189b6a011d87018abda0e626b
PODFILE CHECKSUM: aa082789bfd369623586fbf76e18d6d90097562e

COCOAPODS: 1.11.3
Loading

0 comments on commit 2e3aee7

Please sign in to comment.