-
Notifications
You must be signed in to change notification settings - Fork 198
Closed as not planned
Labels
Description
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.goor 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- UpdateApplyActionPinsToSteps()to use[]WorkflowSteppkg/workflow/runtime_setup.go:400- UpdatedetectFromEngineSteps()to use[]WorkflowStep
-
Keep
map[string]anyfor 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
-
WorkflowStepstruct defined with common fields -
WorkflowJobstruct defined with common fields - At least 3 functions updated to use the new types
- All tests pass (
make test) - Documentation updated with type definitions
Estimated Effort
4-6 hours
Related to #7369
AI generated by Plan Command for discussion #7368
Reactions are currently unavailable