Skip to content

[code-simplifier] refactor: use ExtraWithFields merge in Go go-mod-file setup path#19884

Merged
pelikhan merged 2 commits intomainfrom
simplify/go-mod-file-extra-fields-43c67dc3f3a80fe2
Mar 7, 2026
Merged

[code-simplifier] refactor: use ExtraWithFields merge in Go go-mod-file setup path#19884
pelikhan merged 2 commits intomainfrom
simplify/go-mod-file-extra-fields-43c67dc3f3a80fe2

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 6, 2026

This PR simplifies recently modified code from #19865 to improve consistency and maintainability while preserving all functionality.

Files Simplified

  • pkg/workflow/runtime_step_generator.go — unified the Go go-mod-file code path to use ExtraWithFields merge, same as the standard version path

Improvements Made

Removed inconsistency introduced alongside #19865

PR #19865 added cache: false to runtime.ExtraWithFields for the Go runtime definition — the correct, data-driven way to configure this. However, generateSetupStep still had a separate code path for the GoModFile case that hardcoded cache: false as a literal string with an inline comment, while only merging req.ExtraFields (user fields), not runtime.ExtraWithFields (runtime-level defaults).

This created two inconsistencies:

  1. cache: false was produced by a hardcoded string in one path, and by ExtraWithFields in the other
  2. Any future addition to runtime.ExtraWithFields for Go would be silently skipped in the GoModFile path

Fix: removed the hardcoded cache: false line and replaced it with the same maps.Copy(allExtraFields, runtime.ExtraWithFields) merge pattern already used in the standard path.

Changes Based On

Recent changes from:

Testing

  • ✅ All targeted tests pass (go test -run "TestGenerateRuntime" ./pkg/workflow/)
  • ✅ Build succeeds (make build)
  • ✅ Code formatted (make fmt)
  • ✅ No functional changes — output is identical (cache: false still present via ExtraWithFields)

Review Focus

Please verify:

  • The GoModFile path still outputs cache: false (now sourced from runtime.ExtraWithFields instead of hardcoded)
  • Future additions to Go's ExtraWithFields will now be automatically applied in both code paths

Automated by Code Simplifier Agent — analyzing code from the last 24 hours

Generated by Code Simplifier ·

  • expires on Mar 7, 2026, 7:03 PM UTC

The GoModFile code path in generateSetupStep was hardcoding
'cache: false' independently, while the non-GoModFile path was
already using the runtime.ExtraWithFields merge to apply the
same setting (added in #19865).

Unify both paths to use the same ExtraWithFields merge logic,
so the GoModFile path consistently picks up all runtime-level
'with' fields rather than only user-specified ExtraFields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan merged commit e60df21 into main Mar 7, 2026
49 checks passed
@pelikhan pelikhan deleted the simplify/go-mod-file-extra-fields-43c67dc3f3a80fe2 branch March 7, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant