Skip to content

Commit

Permalink
Init PR
Browse files Browse the repository at this point in the history
  • Loading branch information
8kt8 committed Feb 12, 2022
0 parents commit 9a6780f
Show file tree
Hide file tree
Showing 87 changed files with 2,480 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Unit test on pull request

on:
workflow_dispatch:
pull_request:
branches:
- 'develop'
- 'master'

jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Checkout
uses: actions/checkout@v2

- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Copy gradle properties file
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Unit tests
run: ./gradlew test --stacktrace

- name: Archive reports for failed build
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: reports
path: '*/build/reports'
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# UnrdApp
Protopyte project with intergration of API https://s3-eu-west-1.amazonaws.com

## Best practices

- Separation of concerns
- KISS
- DRY
- SOLID
- Commend Query
- Clean Architecture

## Architecture
Logic in application can be seen as segregated into four abstract layers:

**_User Interface layer:_**
* renders ui model (View - part of UiComponent)
* look&feel, animations, colors, styles, descriptions, layout
* captures user interactions with UI elements and only routes them (NOT handling) into the system

**_Application layer (aka "Glue layer"):_**
* controls user flow inside app e.g navigation
* passes ui model to UI layer
* handles user interaction with UI
* integrates standalone pieces of functionality from other layers

**_Domain layer:_**
* executes business domain flows aka "business logic

**_Infrastructure layer:_**
* provides general functionality not specific to business domain
* networking (Retrofit)
* reactive (RxJava)

#### Remarks
**UiModel** has only data to display, for a View. Colors, styles, descriptions etc. are View implementation details, they are not part of **UiModel**.

### Benefits :
Makes the code much more pleasant to work with!
* No need to look for things
* Readable and intuitive
* Easy to reason about and modify
* Productive and less stressful

### Example Unit tests :
* MainViewModelTest
* ResultRepositoryTest
* GetUiModelUseCaseTest

### Example Unit tests :
* MainViewModelTest
* ResultRepositoryTest
* GetUiModelUseCaseTest

### My ideal CI World for Unrd :
I will propose fastlane to sign and build application and GitHub action for run CI remote(cost $0.008 per minute)
For this kind of project monthly cost should be on acceptable level
Possible solution is set our own Linux machine and configure Jenkins/Bitrise or use CircleApp

What should be cover by CI:
* Run Unit test for each PR to develop and master
* Run nightly daily internal release build
* Internal release process(Firebase, Alpha, Beta)
* Production release process

Nice to have
* Translation process
* Run nightly UI test
* Run code formatter for each PR
* Security check for release file(MobSF)
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
141 changes: 141 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlinx-serialization'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'androidx.navigation.safeargs'
}

android {
compileSdk 31

defaultConfig {
applicationId "com.example.unrd"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "com.example.android.dagger.CustomTestRunner"
}

buildTypes {
release {
minifyEnabled = true
shrinkResources = true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled = true
shrinkResources = true
}
applicationVariants.all {
variant ->
variant.outputs.each {
output ->
def name = "GIPHY_DEMO.apk"
output.outputFileName = name
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
dataBinding true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.4.1"
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation 'androidx.activity:activity-ktx:1.4.0'

// ViewModel
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'

// LiveData
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1'

//Logger
api "com.orhanobut:logger:2.2.0"
implementation 'androidx.test.ext:junit-ktx:1.1.3'
implementation 'androidx.fragment:fragment-testing:1.4.1'
androidTestImplementation 'androidx.test:rules:1.4.0-alpha05'

//data binding
def data_binding_version = "7.1.1"
implementation "androidx.databinding:databinding-common:$data_binding_version"
implementation "androidx.databinding:databinding-runtime:$data_binding_version"

def nav_version = "2.4.1"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

// Hilt
implementation "com.google.dagger:hilt-android:2.37"
kapt 'com.google.dagger:hilt-android-compiler:2.37'
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0'
implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0'
kaptTest 'com.google.dagger:hilt-android-compiler:2.37'
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.37'
testImplementation 'com.google.dagger:hilt-android-testing:2.37'
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.37'
androidTestAnnotationProcessor 'com.google.dagger:hilt-android-compiler:2.37'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0"

//RxJava
def rxJava_version = "3.0.0"
implementation "io.reactivex.rxjava3:rxandroid:$rxJava_version"
implementation "io.reactivex.rxjava3:rxjava:$rxJava_version"

// SquareUp tools - retrofit, okhttp
def retrofit2_version = "2.9.0"
def okhttp3_version = "4.9.1"
api "com.squareup.retrofit2:retrofit:$retrofit2_version"
api "com.squareup.retrofit2:converter-moshi:$retrofit2_version"
api "com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version"
api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"

// moshi
def moshi_version = "1.13.0"
api "com.squareup.moshi:moshi-kotlin:$moshi_version"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"

// Glide
def glide_version = "4.12.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"

//mockk
testImplementation 'io.mockk:mockk:1.12.0'

testImplementation 'com.jraska.livedata:testing-ktx:1.2.0'
testImplementation "androidx.arch.core:core-testing:2.1.0"

testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0-alpha03'
}
39 changes: 39 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class <1> {
public static <1> INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.
# If you have any, uncomment and replace classes with those containing named companion objects.
#-keepattributes InnerClasses # Needed for `getDeclaredClasses`.
#-if @kotlinx.serialization.Serializable class
#com.example.myapplication.HasNamedCompanion, # <-- List serializable classes with named companions.
#com.example.myapplication.HasNamedCompanion2
#{
# static **$* *;
#}
#-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
# static <1>$$serializer INSTANCE;
#}
Loading

0 comments on commit 9a6780f

Please sign in to comment.