Skip to content

Commit f69f334

Browse files
committed
Adapt to upstream changes
1 parent f5e592a commit f69f334

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ private fun Route.getArtifact(
119119
}
120120
}
121121

122-
internal fun prefetchBindingArtifacts(coords: Collection<ActionCoords>) {
122+
internal fun prefetchBindingArtifacts(
123+
coords: Collection<ActionCoords>,
124+
bindingVersion: BindingVersion = V1,
125+
) {
123126
prefetchScope.launch {
124-
bindingsCache.getAll(coords)
127+
bindingsCache.getAll(coords.map { CacheKey(it, bindingVersion) })
125128
}
126129
}
127130

@@ -181,7 +184,7 @@ private fun incrementArtifactCounter(
181184
counter.increment()
182185
}
183186

184-
private data class CacheKey(
187+
internal data class CacheKey(
185188
val actionCoords: ActionCoords,
186189
val bindingVersion: BindingVersion,
187190
)

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutes.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import com.github.benmanes.caffeine.cache.Caffeine
44
import com.sksamuel.aedile.core.asLoadingCache
55
import com.sksamuel.aedile.core.refreshAfterWrite
66
import io.github.oshai.kotlinlogging.KotlinLogging.logger
7-
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords
87
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.prettyPrintWithoutVersion
98
import io.github.typesafegithub.workflows.mavenbinding.buildPackageArtifacts
109
import io.github.typesafegithub.workflows.shared.internal.getGithubAuthToken
@@ -26,9 +25,13 @@ private val metadataCache =
2625
.newBuilder()
2726
.refreshAfterWrite(1.hours)
2827
.recordStats()
29-
.asLoadingCache<ActionCoords, MetadataResult> {
28+
.asLoadingCache<CacheKey, MetadataResult> {
3029
runCatching {
31-
it.buildPackageArtifacts(githubAuthToken = getGithubAuthToken(), ::prefetchBindingArtifacts)
30+
it.actionCoords.buildPackageArtifacts(
31+
githubAuthToken = getGithubAuthToken(),
32+
prefetchBindingArtifacts = ::prefetchBindingArtifacts,
33+
bindingVersion = it.bindingVersion,
34+
)
3235
}
3336
}
3437

@@ -62,10 +65,11 @@ private fun Route.metadata(refresh: Boolean = false) {
6265
logger.info {
6366
"➡️ Requesting metadata for ${actionCoords.prettyPrintWithoutVersion} binding version $bindingVersion"
6467
}
68+
val cacheKey = CacheKey(actionCoords, bindingVersion)
6569
if (refresh) {
66-
metadataCache.invalidate(actionCoords)
70+
metadataCache.invalidate(cacheKey)
6771
}
68-
val metadataArtifacts = metadataCache.get(actionCoords).getOrThrow()
72+
val metadataArtifacts = metadataCache.get(cacheKey).getOrThrow()
6973

7074
if (refresh && !deliverOnRefreshRoute) return@get call.respondText(text = "OK")
7175

maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import arrow.core.getOrElse
55
import io.github.oshai.kotlinlogging.KotlinLogging.logger
66
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords
77
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL
8+
import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion
9+
import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V1
810
import io.github.typesafegithub.workflows.shared.internal.fetchAvailableVersions
911
import io.github.typesafegithub.workflows.shared.internal.model.Version
1012
import java.time.format.DateTimeFormatter
@@ -18,15 +20,16 @@ internal suspend fun ActionCoords.buildMavenMetadataFile(
1820
name: String,
1921
githubAuthToken: String?,
2022
) -> Either<String, List<Version>> = ::fetchAvailableVersions,
21-
prefetchBindingArtifacts: (Collection<ActionCoords>) -> Unit = {},
23+
prefetchBindingArtifacts: (Collection<ActionCoords>, BindingVersion) -> Unit = { _, _ -> },
24+
bindingVersion: BindingVersion = V1,
2225
): String? {
2326
val availableVersions =
2427
fetchAvailableVersions(owner, name, githubAuthToken)
2528
.getOrElse {
2629
logger.error { it }
2730
emptyList()
2831
}.filter { it.isMajorVersion() || (significantVersion < FULL) }
29-
prefetchBindingArtifacts(availableVersions.map { copy(version = "$it") })
32+
prefetchBindingArtifacts(availableVersions.map { copy(version = "$it") }, bindingVersion)
3033
val newest = availableVersions.maxOrNull() ?: return null
3134
val lastUpdated =
3235
DateTimeFormatter

maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PackageArtifactsBuilding.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package io.github.typesafegithub.workflows.mavenbinding
22

33
import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords
4+
import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion
5+
import io.github.typesafegithub.workflows.actionbindinggenerator.versioning.BindingVersion.V1
46

57
suspend fun ActionCoords.buildPackageArtifacts(
68
githubAuthToken: String,
7-
prefetchBindingArtifacts: (Collection<ActionCoords>) -> Unit,
9+
prefetchBindingArtifacts: (Collection<ActionCoords>, BindingVersion) -> Unit,
10+
bindingVersion: BindingVersion = V1,
811
): Map<String, String> {
912
val mavenMetadata =
1013
buildMavenMetadataFile(

0 commit comments

Comments
 (0)