Repository navigation
Refactor: Extract duplicate step formatting code from Copilot and Codex engines - #1977
Merged
Merged
Conversation
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Consolidate duplicate code in GitHub Actions formatting
Refactor: Extract duplicate step formatting code from Copilot and Codex engines
Oct 19, 2025
pelikhan
marked this pull request as ready for review
October 19, 2025 16:03
Contributor
|
Agentic Changeset Generator triggered by this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes duplicate code issue by extracting shared step formatting logic from Copilot and Codex engine execution steps into a reusable helper function.
Problem
The Copilot and Codex engines contained nearly identical ~20 line blocks for formatting GitHub Actions execution steps. This duplication meant that any changes to step formatting (such as indentation adjustments or environment variable handling) had to be applied in multiple places, increasing maintenance burden and the risk of inconsistent behavior.
Duplicate code locations:
pkg/workflow/copilot_engine.golines 184-206pkg/workflow/codex_engine.golines 166-188Both engines performed identical operations:
Solution
Created a new shared helper function
FormatStepWithCommandAndEnv()inpkg/workflow/engine_shared_helpers.gothat consolidates this formatting logic. Both engines now call this single implementation.Before:
After:
Changes
pkg/workflow/engine_shared_helpers.go: AddedFormatStepWithCommandAndEnv()helper function with full documentationpkg/workflow/copilot_engine.go: Replaced 23 duplicate lines with shared helper call (91% reduction)pkg/workflow/codex_engine.go: Replaced 23 duplicate lines with shared helper call (91% reduction)pkg/workflow/engine_shared_helpers_test.go: Added comprehensive test coverage with 3 test functions covering various scenariosBenefits
Testing
make agent-finishcompletes successfullyCode Metrics
Original prompt
Fixes #1976
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.