Skip to content

Commit 7de7af0

Browse files
Copilotpelikhan
andcommitted
Add more test cases for job-discriminator; apply to stale-repo-identifier and slide-deck-maintainer workflows
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 4d82b6b commit 7de7af0

5 files changed

Lines changed: 51 additions & 4 deletions

File tree

.github/workflows/slide-deck-maintainer.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/slide-deck-maintainer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ permissions:
1515
contents: read
1616
pull-requests: read
1717
issues: read
18+
concurrency:
19+
job-discriminator: ${{ inputs.focus || github.run_id }}
1820
tracker-id: slide-deck-maintainer
1921
engine: copilot
2022
timeout-minutes: 45

.github/workflows/stale-repo-identifier.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/stale-repo-identifier.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ permissions:
1717
pull-requests: read
1818
actions: read
1919

20+
concurrency:
21+
job-discriminator: ${{ inputs.organization || github.run_id }}
22+
2023
engine: copilot
2124
strict: true
2225
timeout-minutes: 45

pkg/workflow/concurrency_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,48 @@ func TestGenerateJobConcurrencyConfig(t *testing.T) {
520520
group: "engine-custom-group"`,
521521
description: "job-discriminator does not modify explicitly set engine concurrency",
522522
},
523+
{
524+
name: "Job discriminator using github.run_id for universal uniqueness (schedule)",
525+
workflowData: &WorkflowData{
526+
On: "on:\n schedule:\n - cron: '0 0 * * *'",
527+
EngineConfig: &EngineConfig{ID: "copilot"},
528+
ConcurrencyJobDiscriminator: "${{ github.run_id }}",
529+
},
530+
expected: `concurrency:
531+
group: "gh-aw-copilot-${{ github.workflow }}-${{ github.run_id }}"`,
532+
description: "github.run_id makes each run unique — useful when fan-out workflows all share the same schedule trigger",
533+
},
534+
{
535+
name: "Job discriminator with claude engine and schedule trigger",
536+
workflowData: &WorkflowData{
537+
On: "on:\n schedule:\n - cron: '0 9 1 * *'",
538+
EngineConfig: &EngineConfig{ID: "claude"},
539+
ConcurrencyJobDiscriminator: "${{ inputs.organization || github.run_id }}",
540+
},
541+
expected: `concurrency:
542+
group: "gh-aw-claude-${{ github.workflow }}-${{ inputs.organization || github.run_id }}"`,
543+
description: "job-discriminator works with any engine; fallback to run_id handles scheduled (no-input) runs",
544+
},
545+
{
546+
name: "Job discriminator ignored when push trigger (special trigger, no default group)",
547+
workflowData: &WorkflowData{
548+
On: "on:\n push:\n branches: [main]",
549+
EngineConfig: &EngineConfig{ID: "copilot"},
550+
ConcurrencyJobDiscriminator: "${{ github.run_id }}",
551+
},
552+
expected: "",
553+
description: "push is a special trigger — no default job concurrency is generated, so job-discriminator has no effect",
554+
},
555+
{
556+
name: "Job discriminator with pull_request trigger (special trigger, no default group)",
557+
workflowData: &WorkflowData{
558+
On: "on:\n pull_request:\n types: [opened, synchronize]",
559+
EngineConfig: &EngineConfig{ID: "codex"},
560+
ConcurrencyJobDiscriminator: "${{ github.run_id }}",
561+
},
562+
expected: "",
563+
description: "pull_request is a special trigger — job-discriminator has no effect",
564+
},
523565
}
524566

525567
for _, tt := range tests {

0 commit comments

Comments
 (0)