diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index bc5691535..a234bf26a 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -42,11 +42,11 @@ jobs: - name: Run Gradle Tasks id: gradle_build - env: - FIREBASE_ANDROID_APP_ID: ${{ secrets.firebase_android_app_id }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }} - INTEGRATION_API_KEY: ${{ secrets.integration_api_key }} +# env: +# FIREBASE_ANDROID_APP_ID: ${{ secrets.firebase_android_app_id }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }} +# INTEGRATION_API_KEY: ${{ secrets.integration_api_key }} run: ./gradlew cloud-run:integrationTest --console=plain - name: Produce Test Summary diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index fef0add9e..d8e4412bc 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -64,26 +64,26 @@ jobs: - id: version-code run: echo "VERSION_CODE=$(( (GITHUB_RUN_NUMBER * 2) + 1000 ))" >> $GITHUB_OUTPUT - - env: - ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} - BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} - KEY_STORE_FILE: keystore.jks - KEY_STORE_PASSWORD: ${{ steps.op-secrets.outputs.KEYSTORE_PASSWORD }} - RELEASE_KEY_ALIAS: ${{ steps.op-secrets.outputs.KEY_ALIAS }} - RELEASE_KEY_PASSWORD: ${{ steps.op-secrets.outputs.KEY_PASSWORD }} - SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} - VERSION_CODE: ${{ steps.version-code.outputs.VERSION_CODE }} - run: | + - run: | ./gradlew \ :conferences-app:assemble \ :conferences-app:bundle \ --console=plain - - - env: - ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} - BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} - SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} - run: ./gradlew validateScreenshotTest --console=plain +# env: +# ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} +# BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} +# KEY_STORE_FILE: keystore.jks +# KEY_STORE_PASSWORD: ${{ steps.op-secrets.outputs.KEYSTORE_PASSWORD }} +# RELEASE_KEY_ALIAS: ${{ steps.op-secrets.outputs.KEY_ALIAS }} +# RELEASE_KEY_PASSWORD: ${{ steps.op-secrets.outputs.KEY_PASSWORD }} +# SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} +# VERSION_CODE: ${{ steps.version-code.outputs.VERSION_CODE }} + + - run: ./gradlew validateScreenshotTest --console=plain +# env: +# ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} +# BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} +# SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} - uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2d7f1aefe..b6e204872 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -58,18 +58,18 @@ jobs: - id: gradle run: ./gradlew build --console=plain - env: - ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} - BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} +# env: +# ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} +# BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} - id: screenshot-validation run: ./gradlew validateScreenshotTest --console=plain - env: - ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} - BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} - SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} +# env: +# ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} +# BROWSER_API_KEY: ${{ secrets.BROWSER_API_KEY }} +# SERVER_CLIENT_ID: ${{ secrets.SERVER_CLIENT_ID }} - uses: actions/upload-artifact@v4 if: failure() && steps.screenshot-validation.outcome == 'failure' diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 0f79d7c67..b6620267e 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -49,15 +49,15 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} - if: ${{ github.ref == 'refs/heads/main' }} - env: - FIREBASE_ANDROID_APP_ID: ${{ secrets.firebase_android_app_id }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }} run: > ./gradlew cloud-run:jib --image=europe-west1-docker.pkg.dev/${{ steps.setup-cloud.outputs.project_id }}/cloud-run-source-deploy/api.ashdavies.dev --no-configuration-cache --console=plain +# env: +# FIREBASE_ANDROID_APP_ID: ${{ secrets.firebase_android_app_id }} +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }} - id: token uses: tibdex/github-app-token@v2 diff --git a/identity-manager/build.gradle.kts b/identity-manager/build.gradle.kts index 8ca0e1004..8e1e1d7b3 100644 --- a/identity-manager/build.gradle.kts +++ b/identity-manager/build.gradle.kts @@ -19,6 +19,7 @@ buildConfig { kotlin { sourceSets { commonMain.dependencies { + implementation(projects.kotlinDelegates) implementation(projects.platformSupport) implementation(projects.sqlCommon) diff --git a/identity-manager/src/commonMain/kotlin/io/ashdavies/identity/IdentityManager.kt b/identity-manager/src/commonMain/kotlin/io/ashdavies/identity/IdentityManager.kt index f747ca430..2f4bf61c6 100644 --- a/identity-manager/src/commonMain/kotlin/io/ashdavies/identity/IdentityManager.kt +++ b/identity-manager/src/commonMain/kotlin/io/ashdavies/identity/IdentityManager.kt @@ -1,6 +1,7 @@ package io.ashdavies.identity import io.ashdavies.content.PlatformContext +import io.ashdavies.delegates.notNull import io.ashdavies.sql.mapToOneOrNull import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -35,7 +36,8 @@ internal fun IdentityManager( override val state: Flow = merge(states, queries) override suspend fun signIn() { - val identityRequest = GoogleIdIdentityRequest(BuildConfig.SERVER_CLIENT_ID) + val serverClientId by notNull { BuildConfig.SERVER_CLIENT_ID } + val identityRequest = GoogleIdIdentityRequest(serverClientId) val identityResponse = try { identityService.request(identityRequest) } catch (exception: UnsupportedOperationException) { diff --git a/kotlin-delegates/build.gradle.kts b/kotlin-delegates/build.gradle.kts new file mode 100644 index 000000000..533bbc980 --- /dev/null +++ b/kotlin-delegates/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("io.ashdavies.kotlin") +} diff --git a/kotlin-delegates/src/commonMain/kotlin/io/ashdavies/delegates/NotNull.kt b/kotlin-delegates/src/commonMain/kotlin/io/ashdavies/delegates/NotNull.kt new file mode 100644 index 000000000..6ee4a2dbf --- /dev/null +++ b/kotlin-delegates/src/commonMain/kotlin/io/ashdavies/delegates/NotNull.kt @@ -0,0 +1,9 @@ +package io.ashdavies.delegates + +import kotlin.properties.ReadOnlyProperty + +public fun notNull(block: () -> T?): ReadOnlyProperty { + return ReadOnlyProperty { _, property -> + requireNotNull(block()) { "Missing property ${property.name}" } + } +} diff --git a/map-routes/build.gradle.kts b/map-routes/build.gradle.kts index 6ea667106..8485e9bb0 100644 --- a/map-routes/build.gradle.kts +++ b/map-routes/build.gradle.kts @@ -28,6 +28,7 @@ kotlin { commonMain.dependencies { implementation(projects.httpClient) implementation(projects.httpCommon) + implementation(projects.kotlinDelegates) implementation(projects.mapsRouting) implementation(projects.platformSupport) diff --git a/map-routes/src/commonMain/kotlin/io/ashdavies/routes/RoutePresenter.kt b/map-routes/src/commonMain/kotlin/io/ashdavies/routes/RoutePresenter.kt index 91637ec47..620d93b48 100644 --- a/map-routes/src/commonMain/kotlin/io/ashdavies/routes/RoutePresenter.kt +++ b/map-routes/src/commonMain/kotlin/io/ashdavies/routes/RoutePresenter.kt @@ -6,6 +6,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.slack.circuit.retained.rememberRetained +import io.ashdavies.delegates.notNull import io.ashdavies.http.LocalHttpClient import io.ashdavies.routing.ComputeRoutesCallable import io.ashdavies.routing.ComputeRoutesError @@ -29,11 +30,13 @@ internal fun RoutePresenter( } } + val androidApiKey by notNull { BuildConfig.ANDROID_API_KEY } + val computeRoutes = rememberRetained { ComputeRoutesCallable( httpClient = httpClient, baseUrl = ROUTES_BASE_URL, - apiKey = BuildConfig.ANDROID_API_KEY, + apiKey = androidApiKey, ) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 3acca0bf7..7167bbd4d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -63,6 +63,7 @@ include( ":http-common", ":identity-manager", ":key-navigation", + ":kotlin-delegates", ":kotlin-gb", ":map-routes", ":maps-routing",