feat(wfe-yaml): add YAML workflow definitions with shell executor
Concourse-CI-inspired YAML format for defining workflows. Compiles
to standard WorkflowDefinition + step factories.
Features:
- Schema parsing with serde_yaml (YamlWorkflow, YamlStep, StepConfig)
- ((var.path)) interpolation from config maps at load time
- YAML anchors (&anchor/*alias) fully supported
- Validation at load time (no runtime surprises)
- Shell executor: runs commands via tokio::process, captures stdout,
parses ##wfe[output name=value] annotations for structured outputs
- Compiler: sequential wiring, parallel blocks, on_failure/on_success/
ensure hooks, error behavior mapping
- Public API: load_workflow(), load_workflow_from_str()
- 23 tests (schema, interpolation, compiler, e2e)
2026-03-25 21:32:00 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct YamlWorkflow {
|
|
|
|
|
pub workflow: WorkflowSpec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct WorkflowSpec {
|
|
|
|
|
pub id: String,
|
|
|
|
|
pub version: u32,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub description: Option<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub error_behavior: Option<YamlErrorBehavior>,
|
|
|
|
|
pub steps: Vec<YamlStep>,
|
|
|
|
|
/// Allow unknown top-level keys (e.g. `_templates`) for YAML anchors.
|
|
|
|
|
#[serde(flatten)]
|
|
|
|
|
pub _extra: HashMap<String, serde_yaml::Value>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct YamlStep {
|
|
|
|
|
pub name: String,
|
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
|
pub step_type: Option<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub config: Option<StepConfig>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub inputs: Vec<DataRef>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub outputs: Vec<DataRef>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub parallel: Option<Vec<YamlStep>>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub error_behavior: Option<YamlErrorBehavior>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub on_success: Option<Box<YamlStep>>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub on_failure: Option<Box<YamlStep>>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub ensure: Option<Box<YamlStep>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
|
|
|
pub struct StepConfig {
|
|
|
|
|
pub run: Option<String>,
|
|
|
|
|
pub file: Option<String>,
|
|
|
|
|
pub script: Option<String>,
|
|
|
|
|
pub shell: Option<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub env: HashMap<String, String>,
|
|
|
|
|
pub timeout: Option<String>,
|
|
|
|
|
pub working_dir: Option<String>,
|
2026-03-25 22:32:07 +00:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub permissions: Option<DenoPermissionsYaml>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub modules: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// YAML-level permission configuration for Deno steps.
|
|
|
|
|
#[derive(Debug, Deserialize, Clone, Default)]
|
|
|
|
|
pub struct DenoPermissionsYaml {
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub net: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub read: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub write: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub env: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub run: bool,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub dynamic_import: bool,
|
feat(wfe-yaml): add YAML workflow definitions with shell executor
Concourse-CI-inspired YAML format for defining workflows. Compiles
to standard WorkflowDefinition + step factories.
Features:
- Schema parsing with serde_yaml (YamlWorkflow, YamlStep, StepConfig)
- ((var.path)) interpolation from config maps at load time
- YAML anchors (&anchor/*alias) fully supported
- Validation at load time (no runtime surprises)
- Shell executor: runs commands via tokio::process, captures stdout,
parses ##wfe[output name=value] annotations for structured outputs
- Compiler: sequential wiring, parallel blocks, on_failure/on_success/
ensure hooks, error behavior mapping
- Public API: load_workflow(), load_workflow_from_str()
- 23 tests (schema, interpolation, compiler, e2e)
2026-03-25 21:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct DataRef {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub path: Option<String>,
|
|
|
|
|
pub json_path: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
pub struct YamlErrorBehavior {
|
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
|
pub behavior_type: String,
|
|
|
|
|
pub interval: Option<String>,
|
|
|
|
|
pub max_retries: Option<u32>,
|
|
|
|
|
}
|