github-workflows-kt icon indicating copy to clipboard operation
github-workflows-kt copied to clipboard

[Bug] No anchor support in typing

Open Vampire opened this issue 1 year ago • 5 comments

https://github.com/typesafegithub/github-actions-typing explicitly specifies that anchors are supported, but the abg says "com.charleskorn.kaml.ForbiddenAnchorOrAliasException: Parsing anchors and aliases is disabled."

Vampire avatar Aug 25 '24 03:08 Vampire

@Vampire is there any concrete action affected by it, or you discovered it on some synthetic example?

TODO: check if the aliases still work in github-actions-typing.

krzema12 avatar Aug 25 '24 07:08 krzema12

It works in github-actions-typing: https://github.com/typesafegithub/github-actions-typing/blob/9e176223fe1173e6a7350159bf3dc482243bf0ca/src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestsToReportTest.kt#L62

because we allow anchors and aliases: https://github.com/typesafegithub/github-actions-typing/blob/9e176223fe1173e6a7350159bf3dc482243bf0ca/src/main/kotlin/it/krzeminski/githubactionstyping/parsing/TypesManifestParsing.kt#L30

krzema12 avatar Aug 25 '24 07:08 krzema12

Test to be added in https://github.com/typesafegithub/github-workflows-kt/blob/060e80bd5ec02403f5ede2f031124b230cbc0fcf/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt#L11

Fix to be made in https://github.com/typesafegithub/github-workflows-kt/blob/060e80bd5ec02403f5ede2f031124b230cbc0fcf/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/utils/YamlParsingConfig.kt#L8

krzema12 avatar Aug 25 '24 10:08 krzema12

I started to look at the output typings and this broke it:

diff --git a/typings/actions/setup-java/v4/action-types.yml b/typings/actions/setup-java/v4/action-types.yml
index 92da38a..b989e20 100644
--- a/typings/actions/setup-java/v4/action-types.yml
+++ b/typings/actions/setup-java/v4/action-types.yml
@@ -2,7 +2,7 @@
 inputs:
   java-version:
     type: string
-  distribution:
+  distribution: &distribution
     type: enum
     allowed-values:
     - adopt
@@ -57,13 +57,11 @@ inputs:
     type: string
   cache-dependency-path:
     type: string
-# Please check those outputs's description and set a proper type. 'string' is just set by default
 outputs:
-  distribution:
-    type: string
+  distribution: *distribution
   version:
     type: string
   path:
     type: string
   cache-hit:
-    type: string
+    type: boolean

Adding the allowAnchorsAndAliases = true in YamlParsingConfig indeed makes it work. But I guess different configs should be used for typing parsing and other parsing, as the anchors are still non-standard iirc, ond not every YAML supports them, like for example GHA files.

Vampire avatar Aug 25 '24 11:08 Vampire

Yes, I thought about having separate configs as well.

krzema12 avatar Aug 25 '24 12:08 krzema12