Skip to content

Commit b8c09e5

Browse files
committed
[#22] fix: allow empty types YAML
Ideally we'd like to support also something like: ```yaml types: ``` but there's a problem with the YAML parser that I'm going to clarify as a follow-up.
1 parent fa29dd5 commit b8c09e5

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/main/kotlin/it/krzeminski/githubactionstyping/ManifestsToReport.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
package it.krzeminski.githubactionstyping
22

33
import it.krzeminski.githubactionstyping.github.getBooleanInput
4+
import it.krzeminski.githubactionstyping.parsing.TypesManifest
45
import it.krzeminski.githubactionstyping.parsing.parseManifest
56
import it.krzeminski.githubactionstyping.parsing.parseTypesManifest
67
import it.krzeminski.githubactionstyping.reporting.toPlaintextReport
78
import it.krzeminski.githubactionstyping.validation.ItemValidationResult
89
import it.krzeminski.githubactionstyping.validation.validate
910

1011
fun manifestsToReport(manifest: String, typesManifest: String): Pair<Boolean, String> {
11-
val parsedTypesManifest = parseTypesManifest(typesManifest)
12+
val parsedTypesManifest = if (typesManifest.isNotBlank()) {
13+
parseTypesManifest(typesManifest)
14+
} else {
15+
TypesManifest()
16+
}
1217
val parsedManifest = parseManifest(manifest)
1318

1419
val inputsInTypesManifest = parsedTypesManifest.inputs.keys

src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestsToReportTest.kt

+33
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,39 @@ class ManifestsToReportTest : FunSpec({
120120
}
121121
}
122122

123+
test("blank types YAML") {
124+
// when
125+
val manifest = """
126+
name: GitHub Actions Typing
127+
description: Bring type-safety to your GitHub actions' API!
128+
author: Piotr Krzemiński
129+
runs:
130+
using: 'docker'
131+
image: 'Dockerfile'
132+
""".trimIndent()
133+
val typesManifest = " "
134+
135+
// when
136+
val (isValid, report) = manifestsToReport(manifest, typesManifest)
137+
138+
// then
139+
assertSoftly {
140+
isValid shouldBe true
141+
report shouldBe """
142+
Overall result:
143+
${'\u001b'}[32m✔ VALID${'\u001b'}[0m
144+
145+
Inputs:
146+
None.
147+
148+
Outputs:
149+
None.
150+
151+
152+
""".trimIndent()
153+
}
154+
}
155+
123156
test("enum: missing allowed values") {
124157
// when
125158
val manifest = """

0 commit comments

Comments
 (0)