8000 fix workflow by smilecs · Pull Request #57 · smilecs/ketro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix workflow #57

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

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
8000 Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/publish.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test on Pull Request

on:
pull_request:
branches:
- master # Specify the branches to run tests on PRs against

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

steps:
# Step 1: Check out the code
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Set up JDK for the Android project
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# Step 3: Cache Gradle dependencies to speed up builds
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

# Step 4: Build the project and run tests
- name: Run Unit Tests
run: ./gradlew test

# Step 5: Run Android Instrumentation Tests (Optional)
# Uncomment the following block to run instrumentation tests
# - name: Run Instrumentation Tests
# run: ./gradlew connectedAndroidTest
# env:
# ANDROID_SDK_ROOT: ${{ env.ANDROID_HOME }}

# Step 6: Upload Test Results (Optional)
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: test-results
path: app/build/reports/tests/testDebugUnitTest
5 changes: 3 additions & 2 deletions ketro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 30
targetSdkVersion 34
versionCode 4
versionName "1.4"
versionCode 5
versionName "2.1.1"

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand All @@ -36,6 +36,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
Expand Down
2 changes: 0 additions & 2 deletions ketro/src/main/java/com/past3/ketro/api/ApiCallback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import retrofit2.Call
import retrofit2.Callback

abstract class ApiCallback<T>(private val errorHandler: ApiErrorHandler) : Callback<T> {

override fun onResponse(call: Call<T>, response: retrofit2.Response<T>) {
val statusCode = StatusCode(response.code())
when (statusCode.code) {
Expand Down Expand Up @@ -34,5 +33,4 @@ abstract class ApiCallback<T>(private val errorHandler: ApiErrorHandler) : Callb
//do something else
}
}

}
6 changes: 1 addition & 5 deletions ketro/src/main/java/com/past3/ketro/api/ApiErrorHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import com.past3.ketro.api.model.StatusCode
*
**/
open class ApiErrorHandler {


/* Method should be overridden to return custom exception type which
* would be a sub-type of Exception or to have the response body,
* return a sub-type of kexception()
Expand All @@ -22,6 +20,4 @@ open class ApiErrorHandler {
StatusCode(response.code())
)
}


}
}
8 changes: 2 additions & 6 deletions ketro/src/main/java/com/past3/ketro/api/Request.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.past3.ketro.api

import androidx.annotation.VisibleForTesting
import com.past3.ketro.api.model.KResponse
import com.past3.ketro.api.model.StatusCode
import com.past3.ketro.api.model.Wrapper
Expand All @@ -9,7 +8,6 @@ import retrofit2.Response
abstract class Request<out T : Any>(
private val errorHandler: ApiErrorHandler = ApiErrorHandler()
) {

abstract suspend fun apiRequest(): Response<out T>

open suspend fun doRequest(): Wrapper<out T> {
Expand Down Expand Up @@ -40,13 +38,11 @@ abstract class Request<out T : Any>(
}
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
fun <T> handleResponseData(data: T?, statusCode: StatusCode): Wrapper<out T> {
private fun <T> handleResponseData(data: T?, statusCode: StatusCode): Wrapper<out T> {
return Wrapper(data = data, statusCode = statusCode)
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
fun <T> handleError(response: Response<T>, statusCode: StatusCode): Wrapper<out T> {
private fun <T> handleError(response: Response<T>, statusCode: StatusCode): Wrapper<out T> {
return Wrapper(errorHandler.getExceptionType(response), statusCode = statusCode)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.past3.ketro.api.model

import okhttp3.ResponseBody


open class KException(val errorBody: ResponseBody?,
message: String?,
cause: Throwable?,
Expand Down
1 change: 0 additions & 1 deletion ketro/src/main/java/com/past3/ketro/api/model/KResponse.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.past3.ketro.api.model

sealed class KResponse<out T>(val statusCode: StatusCode) {

class Success<T>(val data: T? = null, statusCode: StatusCode = StatusCode(-1)) :
KResponse<T>(statusCo E5D1 de)

Expand Down
2 changes: 0 additions & 2 deletions ketro/src/test/java/com/past3/ketro/api/MockObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.past3.ketro.api
import retrofit2.Response

object MockObject {

fun provideUnitResponse(): Response<Unit> {
return Response.success(200, Unit)
}

}
2 changes: 1 addition & 1 deletion ketro/src/test/java/com/past3/ketro/api/RequestUnitTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.past3.ketro.api

import com.past3.ketro.kcore.model.KResponse
import com.past3.ketro.api.model.KResponse
import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Loading
0