Skip to content

Commit

Permalink
feat(abg): stop fetching typings hosted with library (#1134)
Browse files Browse the repository at this point in the history
Part of #1072.

The typings hosted in this repo will soon be removed.
  • Loading branch information
krzema12 committed Nov 24, 2023
1 parent 8aa899c commit d04c5ef
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ internal fun ActionCoords.provideTypes(
): Map<String, Typing> =
this.fetchTypingMetadata(metadataRevision, fetchUri, useCache = useCache)?.toTypesMap()
?: this.fetchFromTypingsFromCatalog(fetchUri)?.toTypesMap()
?: this.fetchFromTypingsMaintainedWithLibrary(fetchUri)?.toTypesMap()
?: emptyMap()

private val actionTypesYamlDir: File = File("build/action-types-yaml")
Expand All @@ -39,9 +38,6 @@ private fun ActionCoords.actionTypesFromCatalog() =
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
"main/typings/$owner/$repoName/$version/$subName/action-types.yml"

private fun ActionCoords.actionTypesMaintainedWithLibraryUrl() =
"https://raw.githubusercontent.com/typesafegithub/github-workflows-kt/main/actions/$owner/$repoName/$version/$subName/action-types.yml"

private fun ActionCoords.actionTypesYamlUrl(gitRef: String) =
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef/$subName/action-types.yaml"

Expand Down Expand Up @@ -86,9 +82,6 @@ private fun ActionCoords.fetchTypingMetadata(
private fun ActionCoords.fetchFromTypingsFromCatalog(fetchUri: (URI) -> String = ::fetchUri): ActionTypes? =
fetchTypingsFromUrl(url = actionTypesFromCatalog(), fetchUri = fetchUri)

private fun ActionCoords.fetchFromTypingsMaintainedWithLibrary(fetchUri: (URI) -> String = ::fetchUri): ActionTypes? =
fetchTypingsFromUrl(url = actionTypesMaintainedWithLibraryUrl(), fetchUri = fetchUri)

private fun fetchTypingsFromUrl(
url: String,
fetchUri: (URI) -> String,
Expand All @@ -109,20 +102,6 @@ internal fun getCommitHash(actionCoords: ActionCoords): String? =
if (it.exists()) it.readText().trim() else null
}

internal fun getLocalTypings(actionCoords: ActionCoords): String? {
val pathBeforeVersion = Path.of("actions", actionCoords.owner, actionCoords.name.split("/").first(), actionCoords.version)
val subnames = actionCoords.name.split("/").drop(1).joinToString("/")
val fullPath =
if (subnames.isNotEmpty()) {
pathBeforeVersion.resolve(subnames).resolve("action-types.yml")
} else {
pathBeforeVersion.resolve("action-types.yml")
}
return fullPath.toFile().let {
if (it.exists()) it.readText() else null
}
}

internal fun ActionTypes.toTypesMap(): Map<String, Typing> {
return inputs.mapValues { (key, value) ->
value.toTyping(key)
Expand Down

0 comments on commit d04c5ef

Please sign in to comment.