-
Notifications
You must be signed in to change notification settings - Fork 507
Warn when workflow dispatches share conclusion concurrency #55836
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
Merged
pelikhan
merged 7 commits into
main
from
copilot/warn-workflow-dispatch-no-job-discriminator
Aug 26, 2026
+125
−0
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8bc4ed4
Initial plan
Copilot b38547c
Warn on shared dispatch conclusion concurrency
Copilot a478d98
Warn only for dispatches with inputs
Copilot 3eff649
Merge branch 'main' into copilot/warn-workflow-dispatch-no-job-discri…
github-actions[bot] 51b1f54
Gate dispatch warning on safe outputs
Copilot f86eac9
Merge main and resolve validator conflict
Copilot b8478f5
Merge branch 'main' into copilot/warn-workflow-dispatch-no-job-discri…
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
69 changes: 69 additions & 0 deletions
69
pkg/workflow/workflow_dispatch_concurrency_warning_test.go
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| //go:build !integration | ||
|
|
||
| package workflow | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/github/gh-aw/pkg/testutil" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestWorkflowDispatchConcurrencyWarning(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| on string | ||
| discriminator string | ||
| expectWarning bool | ||
| }{ | ||
| { | ||
| name: "workflow dispatch without discriminator", | ||
| on: "on: workflow_dispatch", | ||
| expectWarning: true, | ||
| }, | ||
| { | ||
| name: "workflow dispatch with inputs without discriminator", | ||
| on: "on:\n workflow_dispatch:\n inputs:\n target_repo:\n type: string", | ||
| expectWarning: true, | ||
| }, | ||
| { | ||
| name: "mixed workflow dispatch without discriminator", | ||
| on: "on:\n workflow_dispatch:\n schedule:\n - cron: '0 0 * * *'", | ||
| expectWarning: true, | ||
| }, | ||
| { | ||
| name: "workflow dispatch with discriminator", | ||
| on: "on: workflow_dispatch", | ||
| discriminator: "${{ github.run_id }}", | ||
| expectWarning: false, | ||
| }, | ||
| { | ||
| name: "schedule without discriminator", | ||
| on: "on:\n schedule:\n - cron: '0 0 * * *'", | ||
| expectWarning: false, | ||
| }, | ||
| } | ||
|
|
||
| const warning = "workflow_dispatch workflow has no concurrency.job-discriminator" | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| compiler := NewCompiler() | ||
| workflowData := &WorkflowData{ | ||
| On: tt.on, | ||
| ConcurrencyJobDiscriminator: tt.discriminator, | ||
| } | ||
|
|
||
| output := testutil.CaptureStderr(t, func() { | ||
| compiler.emitGeneralToolWarnings(workflowData, "test.md") | ||
| }) | ||
|
|
||
| if tt.expectWarning { | ||
| assert.Contains(t, output, warning) | ||
| assert.Equal(t, 1, compiler.GetWarningCount()) | ||
| } else { | ||
| assert.NotContains(t, output, warning) | ||
| assert.Zero(t, compiler.GetWarningCount()) | ||
| } | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.