feat(workflow): root description field in workflow TOML surfaced through registry
This commit is contained in:
+10
@@ -22,10 +22,13 @@ import kotlin.io.path.readText
|
||||
private data class WorkflowFile(
|
||||
val id: String = "",
|
||||
val start: String = "",
|
||||
val description: String = "",
|
||||
val stages: List<StageSection> = emptyList(),
|
||||
val transitions: List<TransitionSection> = emptyList(),
|
||||
)
|
||||
|
||||
data class WorkflowFileMeta(val id: String, val description: String)
|
||||
|
||||
private data class ProducesEntry(
|
||||
val name: String = "",
|
||||
val kind: String = "",
|
||||
@@ -74,6 +77,13 @@ class TomlWorkflowLoader(
|
||||
return file.toWorkflowGraph(path.parent)
|
||||
}
|
||||
|
||||
override fun loadMeta(path: Path): WorkflowFileMeta {
|
||||
val raw = path.readText()
|
||||
val file = runCatching { mapper.readValue<WorkflowFile>(raw) }
|
||||
.getOrElse { throw WorkflowValidationException("Failed to parse workflow TOML: ${it.message}") }
|
||||
return WorkflowFileMeta(id = file.id, description = file.description)
|
||||
}
|
||||
|
||||
private fun resolvePromptPath(raw: String, workflowDir: Path?): String {
|
||||
val p = Path.of(raw)
|
||||
if (p.isAbsolute) return raw
|
||||
|
||||
+1
@@ -5,4 +5,5 @@ import java.nio.file.Path
|
||||
|
||||
interface WorkflowLoader {
|
||||
fun load(path: Path): WorkflowGraph
|
||||
fun loadMeta(path: Path): WorkflowFileMeta = WorkflowFileMeta("", "")
|
||||
}
|
||||
|
||||
+18
@@ -117,4 +117,22 @@ class TomlWorkflowLoaderTest {
|
||||
val collectStage = graph.stages[graph.start]!!
|
||||
assertEquals(null, collectStage.metadata["injectArtifactKinds"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `description field is parsed and returned by loadMeta`() {
|
||||
val toml = validToml.replace(
|
||||
"start = \"collect\"",
|
||||
"start = \"collect\"\ndescription = \"Runs the health check pipeline\"",
|
||||
)
|
||||
val path = Files.createTempFile("workflow", ".toml").also { it.writeText(toml) }
|
||||
val meta = loader.loadMeta(path)
|
||||
assertEquals("Runs the health check pipeline", meta.description)
|
||||
assertEquals("healthcheck", meta.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `description absent in loadMeta returns empty string`() {
|
||||
val path = Files.createTempFile("workflow", ".toml").also { it.writeText(validToml) }
|
||||
assertEquals("", loader.loadMeta(path).description)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user