-
Notifications
You must be signed in to change notification settings - Fork 444
fix(compiler): auto-add pre_activation to safe_outputs/conclusion needs when messages reference its outputs
#43570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1d4760e
3935f27
18144ee
6742f3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package workflow | |
|
|
||
| import ( | ||
| "fmt" | ||
| "slices" | ||
| "strings" | ||
|
|
||
| "github.com/github/gh-aw/pkg/constants" | ||
|
|
@@ -61,6 +62,17 @@ func (c *Compiler) buildConclusionJob(data *WorkflowData, mainJobName string, sa | |
| steps = append(steps, c.generateScriptModeCleanupStep()) | ||
| } | ||
| needs := buildConclusionJobNeeds(data, mainJobName, safeOutputJobNames) | ||
| // If any message template references needs.pre_activation.outputs.*, add pre_activation | ||
| // as a dependency so that GitHub Actions can resolve the expression at runtime. | ||
| if data.SafeOutputs != nil && messagesContainPreActivationRef(data.SafeOutputs.Messages) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/codebase-design] The guard block here is structurally identical to the one in 💡 Suggested refactor directionA helper like: // appendPreActivationNeedIfRequired appends pre_activation to needs if:
// 1. any message template references needs.pre_activation.outputs.*
// 2. the pre_activation job actually exists in the job manager
// It is a no-op if pre_activation is already present.
func (c *Compiler) appendPreActivationNeedIfRequired(
data *WorkflowData, needs []string,
) []string {
if data.SafeOutputs == nil || !messagesContainPreActivationRef(data.SafeOutputs.Messages) {
return needs
}
name := string(constants.PreActivationJobName)
if _, exists := c.jobManager.GetJob(name); !exists {
return needs
}
if slices.Contains(needs, name) {
return needs
}
return append(needs, name)
}Both call sites collapse to a single line and the dedup primitive is consistent. @copilot please address this. |
||
| if _, exists := c.jobManager.GetJob(string(constants.PreActivationJobName)); exists { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same silent failure in conclusion job path: when 💡 Suggested fixMirror the fix from the if data.SafeOutputs != nil && messagesContainPreActivationRef(data.SafeOutputs.Messages) {
if _, exists := c.jobManager.GetJob(string(constants.PreActivationJobName)); !exists {
return nil, fmt.Errorf(
"safe-outputs messages reference %s outputs but no %s job exists",
constants.PreActivationJobName, constants.PreActivationJobName,
)
}
preActName := string(constants.PreActivationJobName)
if !slices.Contains(needs, preActName) {
needs = append(needs, preActName)
}
}Note: the conclusion job already returns |
||
| preActName := string(constants.PreActivationJobName) | ||
| if !slices.Contains(needs, preActName) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent deduplication strategy: the 💡 Suggested fixEither:
The map-based approach is also naturally extensible if the |
||
| needs = append(needs, preActName) | ||
| notifyCommentLog.Print("Added pre_activation dependency to conclusion job (messages reference pre_activation outputs)") | ||
| } | ||
| } | ||
| } | ||
|
pelikhan marked this conversation as resolved.
|
||
| notifyCommentLog.Printf("Job built successfully: dependencies_count=%d", len(needs)) | ||
| return &Job{ | ||
| Name: "conclusion", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.