Skip to content

Commit fbcf8e5

Browse files
committed
Update CI, only build api once in tests
1 parent cb54148 commit fbcf8e5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ jobs:
2929
java-version: '11'
3030
- name: Install curl
3131
run: sudo apt-get install -y curl libcurl4-openssl-dev
32-
- name: Test secret
33-
run: echo "client id secret is $SPOTIFY_CLIENT_ID"
3432
- name: Test android
3533
run: ./gradlew testDebugUnitTest
3634
- name: Test jvm
3735
run: ./gradlew jvmTest
3836
- name: Archive test results
3937
uses: actions/upload-artifact@v2
38+
if: always()
4039
with:
4140
name: code-coverage-report
4241
path: build/reports
@@ -63,14 +62,13 @@ jobs:
6362
java-version: '11'
6463
- name: Install curl
6564
run: sudo apt-get install -y curl libcurl4-openssl-dev
66-
- name: Test secret
67-
run: echo "client id secret is $SPOTIFY_CLIENT_ID"
6865
- name: Test android
6966
run: ./gradlew testDebugUnitTest
7067
- name: Test jvm
7168
run: ./gradlew jvmTest
7269
- name: Archive test results
7370
uses: actions/upload-artifact@v2
71+
if: always()
7472
with:
7573
name: code-coverage-report
7674
path: build/reports

src/commonJvmLikeTest/kotlin/com/adamratzman/spotify/CommonImpl.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ actual fun isHttpLoggingEnabled(): Boolean = System.getenv("SPOTIFY_LOG_HTTP") =
1818
actual fun arePlayerTestsEnabled(): Boolean = System.getenv("SPOTIFY_ENABLE_PLAYER_TESTS")?.toBoolean() == true
1919
actual fun areLivePkceTestsEnabled(): Boolean = System.getenv("VERBOSE_TEST_ENABLED")?.toBoolean() ?: false
2020

21+
var hasInstantiatedApi: Boolean = false
22+
var backingApi: GenericSpotifyApi? = null
23+
2124
actual suspend fun buildSpotifyApi(testClassQualifiedName: String, testName: String): GenericSpotifyApi? {
25+
if (!hasInstantiatedApi) {
26+
backingApi = buildSpotifyApiInternal()
27+
hasInstantiatedApi = true
28+
}
29+
30+
return backingApi;
31+
}
32+
33+
private suspend fun buildSpotifyApiInternal(): GenericSpotifyApi? {
2234
val clientId = getTestClientId()
2335
val clientSecret = getTestClientSecret()
2436
val tokenString = getTestTokenString()

0 commit comments

Comments
 (0)