Repository navigation
[WIP] Consolidate safe output job builders to reduce code duplication - #5270
Merged
Merged
Conversation
- Create SafeOutputTargetConfig, SafeOutputFilterConfig, SafeOutputDiscussionFilterConfig for common field patterns - Add ParseTargetConfig, ParseFilterConfig, ParseDiscussionFilterConfig for config parsing - Add BuildCloseJobEnvVars, BuildListJobEnvVars for common env var building - Refactor close_issue.go, close_discussion.go, close_pull_request.go to use shared types - Refactor add_labels.go, add_reviewer.go, assign_milestone.go to use shared types - Refactor assign_to_agent.go, update_release.go to use shared types - Update safe_outputs.go parsing to use new shared helpers - Update test files to work with embedded BaseSafeOutputConfig Co-authored-by: mnkiefer <[email protected]>
- Add ParseStringFromConfig and ParseStringArrayFromConfig generic helpers - Refactor link_sub_issue.go to use shared target config and env var builders - Refactor update_issue.go to use SafeOutputTargetConfig - Refactor update_pull_request.go to use SafeOutputTargetConfig - All files now use BuildTargetEnvVar, BuildMaxCountEnvVar for consistency Co-authored-by: mnkiefer <[email protected]>
- Add validation error handling for ParseTargetConfig in update_issue.go - Add validation error handling for ParseTargetConfig in update_pull_request.go - Add validation error handling for ParseTargetConfig in update_release.go - Add validation error handling for ParseTargetConfig in link_sub_issue.go - Add comment explaining validation handling in safe_outputs.go for assign-to-agent Co-authored-by: mnkiefer <[email protected]>
Collaborator
|
@copilot update add-safe-output-type instructions file |
- Document SafeOutputTargetConfig, SafeOutputFilterConfig, SafeOutputDiscussionFilterConfig structs - Document CloseJobConfig and ListJobConfig composite configs - Add documentation for parsing helpers: ParseTargetConfig, ParseFilterConfig, etc. - Add documentation for env var builders: BuildTargetEnvVar, BuildCloseJobEnvVars, etc. - Update example code to use shared config types and helpers - Add examples for close operations and list operations patterns Co-authored-by: pelikhan <[email protected]>
Contributor
Author
Updated the add-safe-output-type instructions file in commit 5dc74f7 to document:
|
pelikhan
approved these changes
Dec 2, 2025
pelikhan
marked this pull request as ready for review
December 2, 2025 08:47
Collaborator
|
@copilot format, lint, run tests |
- Remove unused safeOutputBuilderLog variable from safe_output_builder.go - All format, lint, and test checks now pass Co-authored-by: pelikhan <[email protected]>
Contributor
Author
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
This PR eliminates significant code duplication across safe output files by extracting common job building patterns to reusable base types, reducing ~335 lines of duplicated code.
Changes
New Shared Types (safe_output_builder.go)
SafeOutputTargetConfig- Common target-related fields (target, target-repo)SafeOutputFilterConfig- Common filtering fields (required-labels, required-title-prefix)SafeOutputDiscussionFilterConfig- Discussion-specific filteringCloseJobConfig- Combined config for close operationsListJobConfig- Combined config for list operationsNew Helper Functions
ParseTargetConfig,ParseFilterConfig,ParseDiscussionFilterConfigParseStringFromConfig,ParseStringArrayFromConfig- Generic parsersBuildTargetEnvVar,BuildRequiredLabelsEnvVar,BuildRequiredTitlePrefixEnvVarBuildRequiredCategoryEnvVar,BuildMaxCountEnvVar,BuildAllowedListEnvVarBuildCloseJobEnvVars,BuildListJobEnvVars- Composite buildersRefactored Files (11 files)
Updated Documentation
.github/agents/add-safe-output-type.mdto document new shared types and helpersTesting
make test-unit)make build)make lint)make fmt)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.