feat: add step.statemachine_transition and step.statemachine_get pipeline steps#163
feat: add step.statemachine_transition and step.statemachine_get pipeline steps#163
Conversation
Implements step.build_from_config (Phase 5.1 roadmap) — a pipeline step that assembles a self-contained Docker image from a workflow config YAML file, a server binary, and optional plugin binaries. - Creates a temp build context, copies config + server + plugin binaries - Generates a Dockerfile with correct ENTRYPOINT/CMD for workflow server - Executes docker build (and optional docker push) via exec.Command - exec.Command is injectable for deterministic unit testing - 17 tests cover factory validation, Dockerfile generation, error paths, push flag, plugin inclusion, and build context file layout - Registers step.build_from_config in plugins/cicd manifest and factory map Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…line steps Implements two new pipeline steps for interacting with state machine workflow instances directly from pipeline execution: - step.statemachine_transition: triggers a named transition on a workflow instance, supports data templates, fail_on_error flag, and the TransitionTrigger interface for testability via mocks. - step.statemachine_get: reads the current state of a workflow instance. Both steps resolve entity_id and data fields from Go templates using the existing TemplateEngine, look up the named StateMachineEngine by service name from the app registry, and return structured output (transition_ok, new_state, current_state, entity_id). Steps are registered in plugins/statemachine with StepFactories() and declared in the manifest's StepTypes list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds new pipeline steps to interact with the state machine engine from within pipelines, and wires them into the statemachine plugin so they’re discoverable/usable via plugin loading. The PR also introduces and registers an additional CI/CD step (step.build_from_config) that is not currently reflected in the PR’s stated scope.
Changes:
- Add
step.statemachine_transitionandstep.statemachine_getpipeline steps (with template resolution) plus unit tests. - Register the new state machine steps in
plugins/statemachineand validate via plugin tests/manifest step type assertions. - Add/register
step.build_from_configin the CI/CD plugin and add its module implementation + tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| plugins/statemachine/plugin.go | Declares new step types in manifest and exposes StepFactories() for statemachine steps. |
| plugins/statemachine/plugin_test.go | Adds assertions for manifest step types and verifies step factories exist. |
| module/pipeline_step_statemachine_transition.go | Implements transition-triggering pipeline step with templated inputs + fail_on_error. |
| module/pipeline_step_statemachine_transition_test.go | Unit tests for transition step behavior and error modes. |
| module/pipeline_step_statemachine_get.go | Implements state lookup pipeline step returning current_state/entity_id. |
| module/pipeline_step_statemachine_get_test.go | Unit tests for get step behavior and error cases. |
| plugins/cicd/plugin.go | Adds step.build_from_config to the CI/CD plugin manifest and factories. |
| plugins/cicd/plugin_test.go | Updates expected step list and factory count after plugin load. |
| module/pipeline_step_build_from_config.go | Implements docker build/push step that assembles a build context from config + binaries. |
| module/pipeline_step_build_from_config_test.go | Adds unit tests for factory validation and build context behavior. |
Comments suppressed due to low confidence (3)
module/pipeline_step_build_from_config_test.go:451
- The error from
copyDirRecursive(...)is ignored, so this test can silently proceed with an incomplete copy and produce confusing follow-on failures. Please assertcopyDirRecursivesucceeds (e.g., fail the test immediately on error).
copyDir := t.TempDir()
_ = copyDirRecursive(capturedBuildDir, copyDir)
capturedBuildDir = copyDir
}
module/pipeline_step_build_from_config_test.go:126
- Test name has a typo (
NoPLugins). Renaming toNoPluginswill keep test naming consistent and easier to search/grep.
func TestBuildFromConfigStep_GenerateDockerfile_NoPLugins(t *testing.T) {
plugins/cicd/plugin.go:48
- This PR appears to introduce/register
step.build_from_configin the CI/CD plugin, but the PR title/description focus on statemachine steps and don’t mention this additional feature. Please update the PR description (and/or split into a separate PR) so reviewers can clearly track the scope and rationale of the CI/CD change.
StepTypes: []string{
"step.shell_exec",
"step.artifact_pull",
"step.artifact_push",
"step.docker_build",
"step.docker_push",
"step.docker_run",
"step.scan_sast",
"step.scan_container",
"step.scan_deps",
"step.deploy",
"step.gate",
"step.build_ui",
"step.build_from_config",
},
| } | ||
| defer in.Close() | ||
|
|
||
| out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) |
There was a problem hiding this comment.
copyFile() creates files with mode 0600. That means config.yaml in the Docker build context will be root-readable only, and the generated image can fail at runtime when using non-root base images (e.g., distroless:nonroot) because /app/config.yaml won’t be readable. Consider setting a less restrictive mode for the config (e.g., chmod config.yaml after copy, or make copyFile accept a mode) so the runtime user can read it.
| out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) | |
| out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) |
Summary
step.statemachine_transition— triggers a named state machine transition from within a pipeline, with template resolution forentity_id,event, anddatafields; configurablefail_on_error(default false)step.statemachine_get— reads the current state of a workflow instance, returningcurrent_stateandentity_idoutputsplugins/statemachineviaStepFactories()and declares them in the manifest'sStepTypesTest plan
TestStateMachineTransitionStep_*(13 cases): factory validation, successful transition, templated entity/event, invalid transition with fail_on_error=false and true, data pass-through, missing service, wrong service type, nil app, mock TransitionTrigger interfaceTestStateMachineGetStep_*(8 cases): factory validation, returns correct state, templated entity_id, state after transition, missing instance, missing service, wrong type, nil appTestStepFactoriesin statemachine plugin: both step types presentTestPluginManifest: manifest declares 2 step types🤖 Generated with Claude Code