diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt index a8ac6b9641..9b3369d0b1 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt @@ -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(), @@ -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" @@ -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, @@ -151,8 +151,8 @@ internal fun ActionTypes.toTypesMap(): Map = 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) { diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt index d1d8346454..fb1bcd5a17 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt @@ -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, ) } @@ -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, ) } @@ -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, ) } @@ -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, ) }