Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal suspend fun ActionCoords.provideTypes(
): ActionTypings =
(
this.fetchTypingMetadata(metadataRevision, httpClient)
?: this.toMajorVersion().fetchFromTypingsFromCatalog(httpClient)
?: this.toMajorVersionForTypings().fetchFromTypingsFromCatalog(httpClient)
)?.let { (typings, typingActualSource) ->
ActionTypings(
inputTypings = typings.toTypesMap(),
Expand All @@ -49,7 +49,7 @@ private const val CATALOG_BASE_URL =
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/main/typings"

private fun ActionCoords.actionTypesFromCatalog() =
"$CATALOG_BASE_URL/${owner.lowercase()}/${name.lowercase()}/$version$subName/action-types.yml"
"$CATALOG_BASE_URL/${owner.lowercase()}/${name.lowercase()}/$versionForTypings$subName/action-types.yml"

private fun ActionCoords.catalogMetadata() = "$CATALOG_BASE_URL/${owner.lowercase()}/${name.lowercase()}/metadata.yml"

Expand Down Expand Up @@ -115,7 +115,7 @@ private suspend fun ActionCoords.fetchTypingsForOlderVersionFromCatalog(httpClie
return null
}
logger.info { " ... using fallback version: $fallbackVersion" }
val adjustedCoords = this.copy(version = fallbackVersion)
val adjustedCoords = this.copy(versionForTypings = fallbackVersion)
return fetchTypingsFromUrl(
url = adjustedCoords.actionTypesFromCatalog(),
httpClient = httpClient,
Expand Down Expand Up @@ -151,8 +151,8 @@ internal fun ActionTypes.toTypesMap(): Map<String, Typing> =
value.toTyping(key)
} ?: emptyMap()

private fun ActionCoords.toMajorVersion(): ActionCoords =
this.copy(version = this.versionForTypings.substringBefore("."))
private fun ActionCoords.toMajorVersionForTypings(): ActionCoords =
this.copy(versionForTypings = this.versionForTypings.substringBefore("."))

private fun ActionType.toTyping(fieldName: String): Typing =
when (this.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,10 @@ class TypesProvidingTest :

// Then
types shouldBe
// This assertion shows an undesired behavior - a result of a regression.
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
ActionTypings(
inputTypings = emptyMap(),
source = null,
fromFallbackVersion = false,
inputTypings = mapOf("stored-in-typing-catalog-for-older-version" to StringTyping),
source = TypingActualSource.TYPING_CATALOG,
fromFallbackVersion = true,
)
}

Expand Down Expand Up @@ -716,12 +714,10 @@ class TypesProvidingTest :

// Then
types shouldBe
// This assertion shows an undesired behavior - a result of a regression.
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
ActionTypings(
inputTypings = emptyMap(),
source = null,
fromFallbackVersion = false,
inputTypings = mapOf("stored-in-typing-catalog-for-older-version" to StringTyping),
source = TypingActualSource.TYPING_CATALOG,
fromFallbackVersion = true,
)
}

Expand Down Expand Up @@ -832,12 +828,10 @@ class TypesProvidingTest :

// Then
types shouldBe
// This assertion shows an undesired behavior - a result of a regression.
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
ActionTypings(
inputTypings = emptyMap(),
source = null,
fromFallbackVersion = false,
inputTypings = mapOf("stored-in-typing-catalog-for-older-version" to StringTyping),
source = TypingActualSource.TYPING_CATALOG,
fromFallbackVersion = true,
)
}

Expand Down Expand Up @@ -923,12 +917,10 @@ class TypesProvidingTest :

// Then
types shouldBe
// This assertion shows an undesired behavior - a result of a regression.
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
ActionTypings(
inputTypings = emptyMap(),
source = null,
fromFallbackVersion = false,
inputTypings = mapOf("stored-in-typing-catalog-for-older-version" to StringTyping),
source = TypingActualSource.TYPING_CATALOG,
fromFallbackVersion = true,
)
}

Expand Down
Loading