-
Notifications
You must be signed in to change notification settings - Fork 300
fix: label trigger shorthand missing label filter condition in compiled workflow #19824
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
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -379,9 +379,16 @@ func TestExpandLabelTriggerShorthand(t *testing.T) { | |||||||||||||||||||||||||||||||
| // Check names field: | ||||||||||||||||||||||||||||||||
| // All entity types use 'names' field for job condition filtering | ||||||||||||||||||||||||||||||||
| // (GitHub Actions doesn't support native label filtering) | ||||||||||||||||||||||||||||||||
| names, ok := triggerConfig["names"].([]string) | ||||||||||||||||||||||||||||||||
| // names is stored as []any so applyLabelFilter can type-assert correctly | ||||||||||||||||||||||||||||||||
| namesRaw, ok := triggerConfig["names"].([]any) | ||||||||||||||||||||||||||||||||
| if !ok { | ||||||||||||||||||||||||||||||||
| t.Fatalf("expandLabelTriggerShorthand() names is not a string array for %s", tt.entityType) | ||||||||||||||||||||||||||||||||
| t.Fatalf("expandLabelTriggerShorthand() names is not a []any for %s", tt.entityType) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| var names []string | ||||||||||||||||||||||||||||||||
| for _, n := range namesRaw { | ||||||||||||||||||||||||||||||||
| if s, isStr := n.(string); isStr { | ||||||||||||||||||||||||||||||||
| names = append(names, s) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+387
to
+391
|
||||||||||||||||||||||||||||||||
| var names []string | |
| for _, n := range namesRaw { | |
| if s, isStr := n.(string); isStr { | |
| names = append(names, s) | |
| } | |
| if len(namesRaw) != len(tt.labelNames) { | |
| t.Fatalf("expandLabelTriggerShorthand() names length = %d, want %d for %s", len(namesRaw), len(tt.labelNames), tt.entityType) | |
| } | |
| names := make([]string, len(namesRaw)) | |
| for i, n := range namesRaw { | |
| s, isStr := n.(string) | |
| if !isStr { | |
| t.Fatalf("expandLabelTriggerShorthand() names[%d] is %T, want string for %s", i, n, tt.entityType) | |
| } | |
| names[i] = s |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1646,7 +1646,13 @@ func TestLabelTriggerShorthandPreprocessing(t *testing.T) { | |
| t.Errorf("expected types=[labeled], got %v", types) | ||
| } | ||
| // names must match the expected labels | ||
| names, _ := triggerMap["names"].([]string) | ||
| namesRaw, _ := triggerMap["names"].([]any) | ||
| var names []string | ||
| for _, n := range namesRaw { | ||
| if s, isStr := n.(string); isStr { | ||
| names = append(names, s) | ||
| } | ||
| } | ||
|
Comment on lines
+1649
to
+1655
|
||
| if !slicesEqual(names, tt.wantLabelNames) { | ||
| t.Errorf("expected names %v, got %v", tt.wantLabelNames, names) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conversion to
[]anyworks aroundapplyLabelFilteronly handlingstringand[]any. However, it also makes the internal representation inconsistent with other Go code that might naturally use[]string(and theapplyLabelFiltercomment in filters.go still claims it supportsnames: []string). Consider instead (or additionally) updatingapplyLabelFilterto accept[]stringtoo and/or update the documentation/comments to reflect the actual supported types, so future producers don’t have to remember to convert.