Skip to content

Commit 1614631

Browse files
committed
fix workflow
migrate to new github actions
1 parent 5623514 commit 1614631

File tree

10 files changed

+78
-41
lines changed

10 files changed

+78
-41
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
name: Publish Package
2-
on:
3-
release:
4-
types: [published]
5-
6-
jobs:
7-
publish:
8-
runs-on: ubuntu-latest
9-
10-
steps:
11-
- uses: actions/checkout@v1
12-
- name: Set up JDK 1.8
13-
uses: actions/setup-java@v1
14-
with:
15-
java-version: 1.8
16-
- name: Grant Permission to Execute
17-
run: chmod +x gradlew
18-
- name: Build Library
19-
run: ./gradlew ketro:assemble
20-
- name: Publish Library
21-
run: ./gradlew ketro:publish
1+
#name: Publish Package
2+
#on:
3+
# release:
4+
# types: [published]
5+
#
6+
#jobs:
7+
# publish:
8+
# runs-on: ubuntu-latest
9+
#
10+
# steps:
11+
# - uses: actions/checkout@v1
12+
# - name: Set up JDK 1.8
13+
# uses: actions/setup-java@v1
14+
# with:
15+
# java-version: 1.8
16+
# - name: Grant Permission to Execute
17+
# run: chmod +x gradlew
18+
# - name: Build Library
19+
# run: ./gradlew ketro:assemble
20+
# - name: Publish Library
21+
# run: ./gradlew ketro:publish

.github/workflows/pull.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test on Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master # Specify the branches to run tests on PRs against
7+
8+
jobs:
9+
test:
10+
name: Run Tests
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Check out the code
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
# Step 2: Set up JDK for the Android project
19+
- name: Set up JDK
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
25+
# Step 3: Cache Gradle dependencies to speed up builds
26+
- name: Cache Gradle dependencies
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.gradle/caches
30+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
31+
restore-keys: |
32+
${{ runner.os }}-gradle-
33+
34+
# Step 4: Build the project and run tests
35+
- name: Run Unit Tests
36+
run: ./gradlew test
37+
38+
# Step 5: Run Android Instrumentation Tests (Optional)
39+
# Uncomment the following block to run instrumentation tests
40+
# - name: Run Instrumentation Tests
41+
# run: ./gradlew connectedAndroidTest
42+
# env:
43+
# ANDROID_SDK_ROOT: ${{ env.ANDROID_HOME }}
44+
45+
# Step 6: Upload Test Results (Optional)
46+
- name: Upload Test Results
47+
uses: actions/upload-artifact@v3
48+
with:
49+
name: test-results
50+
path: app/build/reports/tests/testDebugUnitTest

ketro/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
defaultConfig {
1010
minSdkVersion 30
1111
targetSdkVersion 34
12-
versionCode 4
13-
versionName "1.4"
12+
versionCode 5
13+
versionName "2.1.1"
1414

1515
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1616

@@ -36,6 +36,7 @@ android {
3636
dependencies {
3737
implementation fileTree(dir: 'libs', include: ['*.jar'])
3838
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
3940
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
4041
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
4142
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

ketro/src/main/java/com/past3/ketro/api/ApiCallback.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import retrofit2.Call
55
import retrofit2.Callback
66

77
abstract class ApiCallback<T>(private val errorHandler: ApiErrorHandler) : Callback<T> {
8-
98
override fun onResponse(call: Call<T>, response: retrofit2.Response<T>) {
109
val statusCode = StatusCode(response.code())
1110
when (statusCode.code) {
@@ -34,5 +33,4 @@ abstract class ApiCallback<T>(private val errorHandler: ApiErrorHandler) : Callb
3433
//do something else
3534
}
3635
}
37-
3836
}

ketro/src/main/java/com/past3/ketro/api/ApiErrorHandler.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import com.past3.ketro.api.model.StatusCode
88
*
99
**/
1010
open class ApiErrorHandler {
11-
12-
1311
/* Method should be overridden to return custom exception type which
1412
* would be a sub-type of Exception or to have the response body,
1513
* return a sub-type of kexception()
@@ -22,6 +20,4 @@ open class ApiErrorHandler {
2220
StatusCode(response.code())
2321
)
2422
}
25-
26-
27-
}
23+
}

ketro/src/main/java/com/past3/ketro/api/Request.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.past3.ketro.api
22

3-
import androidx.annotation.VisibleForTesting
43
import com.past3.ketro.api.model.KResponse
54
import com.past3.ketro.api.model.StatusCode
65
import com.past3.ketro.api.model.Wrapper
@@ -9,7 +8,6 @@ import retrofit2.Response
98
abstract class Request<out T : Any>(
109
private val errorHandler: ApiErrorHandler = ApiErrorHandler()
1110
) {
12-
1311
abstract suspend fun apiRequest(): Response<out T>
1412

1513
open suspend fun doRequest(): Wrapper<out T> {
@@ -40,13 +38,11 @@ abstract class Request<out T : Any>(
4038
}
4139
}
4240

43-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
44-
fun <T> handleResponseData(data: T?, statusCode: StatusCode): Wrapper<out T> {
41+
private fun <T> handleResponseData(data: T?, statusCode: StatusCode): Wrapper<out T> {
4542
return Wrapper(data = data, statusCode = statusCode)
4643
}
4744

48-
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
49-
fun <T> handleError(response: Response<T>, statusCode: StatusCode): Wrapper<out T> {
45+
private fun <T> handleError(response: Response<T>, statusCode: StatusCode): Wrapper<out T> {
5046
return Wrapper(errorHandler.getExceptionType(response), statusCode = statusCode)
5147
}
5248
}

ketro/src/main/java/com/past3/ketro/api/model/KException.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.past3.ketro.api.model
22

33
import okhttp3.ResponseBody
44

5-
65
open class KException(val errorBody: ResponseBody?,
76
message: String?,
87
cause: Throwable?,

ketro/src/main/java/com/past3/ketro/api/model/KResponse.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.past3.ketro.api.model
22

33
sealed class KResponse<out T>(val statusCode: StatusCode) {
4-
54
class Success<T>(val data: T? = null, statusCode: StatusCode = StatusCode(-1)) :
65
KResponse<T>(statusCode)
76

ketro/src/test/java/com/past3/ketro/api/MockObject.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package com.past3.ketro.api
33
import retrofit2.Response
44

55
object MockObject {
6-
76
fun provideUnitResponse(): Response<Unit> {
87
return Response.success(200, Unit)
98
}
10-
119
}

ketro/src/test/java/com/past3/ketro/api/RequestUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.past3.ketro.api
22

3-
import com.past3.ketro.kcore.model.KResponse
3+
import com.past3.ketro.api.model.KResponse
44
import kotlinx.coroutines.runBlocking
55
import org.junit.Test
66
import org.junit.runner.RunWith

0 commit comments

Comments
 (0)