Skip to content

Complete migration from deprecated action pin functions to typed alternatives#12309

Merged
pelikhan merged 7 commits intomainfrom
copilot/complete-migration-to-typed-alternative
Jan 28, 2026
Merged

Complete migration from deprecated action pin functions to typed alternatives#12309
pelikhan merged 7 commits intomainfrom
copilot/complete-migration-to-typed-alternative

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Removes deprecated ApplyActionPinToStep() and ApplyActionPinsToSteps() functions that used map[string]any with type assertions. All call sites now use type-safe alternatives with *WorkflowStep structs.

Changes

  • Migrated 7 call sites to typed equivalents:
    • compiler_jobs.go, safe_jobs.go, custom_engine.goApplyActionPinToTypedStep()
    • compiler_orchestrator_workflow.go (4 locations) → ApplyActionPinsToTypedSteps()
  • Removed deprecated functions from action_pins.go (33 lines)
  • Updated test to use typed API with MapToStep() conversion
  • Added comprehensive test coverage (277 lines) with 4 new test functions:
    • TestMapToStepWithActionPinning - verifies MapToStep + ApplyActionPinToTypedStep integration
    • TestSliceToStepsWithActionPinning - verifies SliceToSteps + ApplyActionPinsToTypedSteps integration
    • TestMapToStepErrorHandling - tests error handling for invalid step maps
    • TestSliceToStepsErrorHandling - tests error handling for invalid step slices

Migration Pattern

Before:

stepMap := map[string]any{"uses": "actions/checkout@v5"}
result := ApplyActionPinToStep(stepMap, data)  // Runtime type assertions

After:

typedStep, _ := MapToStep(stepMap)
pinnedStep := ApplyActionPinToTypedStep(typedStep, data)  // Compile-time safety
result := pinnedStep.ToMap()

For step slices, SliceToSteps() and StepsToSlice() handle conversions.

Testing

  • ✅ All existing tests pass with typed alternatives
  • ✅ New tests verify migration patterns used in compiler_jobs.go, safe_jobs.go, custom_engine.go, and compiler_orchestrator_workflow.go
  • ✅ Error handling tests ensure graceful handling of invalid inputs
  • ✅ Code formatted with make fmt and workflows recompiled with make recompile
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Complete migration from deprecated ApplyActionPinToStep to typed alternative</issue_title>
<issue_description>### Description

Complete the migration from deprecated ApplyActionPinToStep() to the type-safe ApplyActionPinToTypedStep() alternative. The deprecated function is marked for removal and uses map[string]any with type assertions, while the typed alternative provides compile-time safety.

Current State

The codebase has deprecated functions still in use:

  • ApplyActionPinToStep() at pkg/workflow/action_pins.go:306
  • ApplyActionPinsToSteps() at pkg/workflow/action_pins.go:402-412

Both functions are marked deprecated but still have active call sites that need migration.

Suggested Changes

  1. Identify all call sites using deprecated functions
  2. Migrate to typed alternatives:
    • ApplyActionPinToStep()ApplyActionPinToTypedStep()
    • ApplyActionPinsToSteps()ApplyActionPinsToTypedSteps()
  3. Remove deprecated functions after migration is complete
  4. Update tests to use typed alternatives

Files Affected

  • Primary: pkg/workflow/action_pins.go (lines 306-412)
  • Call sites: Search codebase for usages with grep -r "ApplyActionPinToStep" pkg/

Success Criteria

  • ✅ Zero usages of deprecated ApplyActionPinToStep() function
  • ✅ Zero usages of deprecated ApplyActionPinsToSteps() function
  • ✅ Deprecated functions removed from codebase
  • ✅ All existing tests pass with typed alternatives
  • ✅ No new type assertion failures introduced

Benefits

  • Compile-time safety: Eliminates runtime type assertion failures
  • Code clarity: Typed function signatures are self-documenting
  • Reduced technical debt: Removes deprecated code path
  • Maintainability: Easier refactoring with strong types

Source

Extracted from Typist Analysis discussion githubnext/gh-aw#12238 - "Priority 1: Critical - Complete Typed Step Migration" section.

The discussion notes: "Code already exists with better types, function is marked deprecated, migration path is clear, will reduce type assertion failures."

Priority

High - Quick win (2-3 days effort), eliminates deprecated code, improves type safety

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 11, 2026, 1:22 PM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 28, 2026 17:14
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…d of return

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ctions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Complete migration from deprecated ApplyActionPinToStep Complete migration from deprecated action pin functions to typed alternatives Jan 28, 2026
Copilot AI requested a review from pelikhan January 28, 2026 17:25
@pelikhan pelikhan marked this pull request as ready for review January 28, 2026 17:26
@pelikhan
Copy link
Contributor

@copilot format, recompile, add tests

- Add TestMapToStepWithActionPinning to verify MapToStep + ApplyActionPinToTypedStep integration
- Add TestSliceToStepsWithActionPinning to verify SliceToSteps + ApplyActionPinsToTypedSteps integration
- Add TestMapToStepErrorHandling to test error cases for MapToStep
- Add TestSliceToStepsErrorHandling to test error cases for SliceToSteps
- All tests verify the migration pattern used in compiler_jobs.go, safe_jobs.go, custom_engine.go, and compiler_orchestrator_workflow.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot format, recompile, add tests

Completed:

  • Format: Ran make fmt - all files already properly formatted
  • Recompile: Ran make recompile - all 141 workflows recompiled successfully
  • Add tests: Added 4 comprehensive test functions (277 lines) covering:
    • TestMapToStepWithActionPinning - verifies MapToStep + ApplyActionPinToTypedStep integration (used in compiler_jobs.go, safe_jobs.go, custom_engine.go)
    • TestSliceToStepsWithActionPinning - verifies SliceToSteps + ApplyActionPinsToTypedSteps integration (used in compiler_orchestrator_workflow.go)
    • TestMapToStepErrorHandling - tests error handling for invalid step maps
    • TestSliceToStepsErrorHandling - tests error handling for invalid step slices

All tests pass successfully. Commit: 9743f00

@pelikhan pelikhan merged commit ff7e012 into main Jan 28, 2026
48 of 49 checks passed
@pelikhan pelikhan deleted the copilot/complete-migration-to-typed-alternative branch January 28, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Complete migration from deprecated ApplyActionPinToStep to typed alternative

2 participants

Comments