Objective
Create proper struct types for workflow steps and jobs to replace []any and improve type safety in workflow processing code.
Context
Several functions work with workflow steps and jobs using []any or []map[string]any, making the code harder to understand and maintain. Proper types will provide compile-time safety and clearer APIs.
Approach
-
Define WorkflowStep type in pkg/workflow/types.go or similar:
type WorkflowStep struct {
ID string `yaml:"id,omitempty"`
Name string `yaml:"name,omitempty"`
If string `yaml:"if,omitempty"`
Run string `yaml:"run,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]any `yaml:"with,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
ContinueOnError bool `yaml:"continue-on-error,omitempty"`
// Add other common fields as needed
}
-
Define WorkflowJob type:
type WorkflowJob struct {
Name string `yaml:"name,omitempty"`
RunsOn string `yaml:"runs-on,omitempty"`
Needs []string `yaml:"needs,omitempty"`
If string `yaml:"if,omitempty"`
Steps []WorkflowStep `yaml:"steps,omitempty"`
Permissions map[string]string `yaml:"permissions,omitempty"`
// Add other common fields as needed
}
-
Update step processing functions:
pkg/workflow/action_pins.go:293 - Update ApplyActionPinsToSteps() to use []WorkflowStep
pkg/workflow/runtime_setup.go:400 - Update detectFromEngineSteps() to use []WorkflowStep
-
Keep map[string]any for extension/custom fields that are truly dynamic
-
Update tests to use the new types
Files to Modify
- Create:
pkg/workflow/step_types.go (or add to existing types file)
- Update:
pkg/workflow/action_pins.go - Use WorkflowStep type
- Update:
pkg/workflow/runtime_setup.go - Use WorkflowStep type
- Update:
pkg/workflow/compiler_jobs.go - Use WorkflowJob type where applicable
- Update: Test files that create or manipulate steps/jobs
Acceptance Criteria
Estimated Effort
4-6 hours
Related to #7369
AI generated by Plan Command for discussion #7368
Objective
Create proper struct types for workflow steps and jobs to replace
[]anyand improve type safety in workflow processing code.Context
Several functions work with workflow steps and jobs using
[]anyor[]map[string]any, making the code harder to understand and maintain. Proper types will provide compile-time safety and clearer APIs.Approach
Define WorkflowStep type in
pkg/workflow/types.goor similar:Define WorkflowJob type:
Update step processing functions:
pkg/workflow/action_pins.go:293- UpdateApplyActionPinsToSteps()to use[]WorkflowSteppkg/workflow/runtime_setup.go:400- UpdatedetectFromEngineSteps()to use[]WorkflowStepKeep
map[string]anyfor extension/custom fields that are truly dynamicUpdate tests to use the new types
Files to Modify
pkg/workflow/step_types.go(or add to existing types file)pkg/workflow/action_pins.go- Use WorkflowStep typepkg/workflow/runtime_setup.go- Use WorkflowStep typepkg/workflow/compiler_jobs.go- Use WorkflowJob type where applicableAcceptance Criteria
WorkflowStepstruct defined with common fieldsWorkflowJobstruct defined with common fieldsmake test)Estimated Effort
4-6 hours
Related to #7369