Skip to content

[plan] Define WorkflowStep and WorkflowJob types #7373

@github-actions

Description

@github-actions

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

  1. 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
    }
  2. 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
    }
  3. 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
  4. Keep map[string]any for extension/custom fields that are truly dynamic

  5. 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

  • WorkflowStep struct defined with common fields
  • WorkflowJob struct 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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions