Skip to content

fix(ci): dedupe two-stage consumer jobs in dispatch groups - #10231

Open
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:sweep/bugfix-consumer-standalone-removal
Open

fix(ci): dedupe two-stage consumer jobs in dispatch groups#10231
andrewwhitecdw wants to merge 2 commits into
NVIDIA:mainfrom
andrewwhitecdw:sweep/bugfix-consumer-standalone-removal

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 26, 2026

Copy link
Copy Markdown

Summary

build-workflow.py's finalize_workflow_dispatch_groups deduplicates jobs
that appear both in a dispatch group's standalone array and as
producer/consumer jobs of a two_stage entry, so each job executes exactly
once. Jobs that were duplicated as two-stage consumers were never removed
from the standalone array, so they were scheduled (and executed) twice:
once standalone and once as a consumer.

Root cause

The consumer-removal loop passes the wrong variable to the dedup helper:

for consumer in two_stage_job['consumers']:
    if remove_dispatch_job_from_container(producer, unique_standalone_jobs):
        print(f"Removing standalone job '{consumer['name']}' " +
              f"as it appears as a consumer in '{group_name}'", ...)

producer is the leftover loop variable from the preceding
for producer in ... loop. Since the producer was already removed from
unique_standalone_jobs by that earlier loop, the second removal attempt
always returns False, so no consumer standalone job is ever removed and
the "appears as a consumer" notice is never printed.

Fix

Pass consumer instead of producer:

if remove_dispatch_job_from_container(consumer, unique_standalone_jobs):

Testing

No automated regression test is included per reviewer feedback: the project
has no existing test infrastructure for these CI scripts, and adding one is
out of scope for a typo fix PR.

The fix was verified manually by exercising finalize_workflow_dispatch_groups
with a synthetic dispatch group where job test job appears both standalone
and as a two-stage consumer:

  • With the fix: standalone after finalize: [] / PASS (duplicated
    standalone removed, consumer notice printed).
  • With the unmodified code: FAIL: standalone not emptied: ['test job']
    reproduces the bug.

Why existing tests missed it

This scripting layer has no unit tests; the duplication only manifests as a
silently double-scheduled CI job, which CI itself does not flag as a failure.


Ported from NVIDIA/cccl-gha#1 at the request of @alliepiper — the same typo
was still present in this repo.

@copy-pr-bot

copy-pr-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jul 26, 2026
@andrewwhitecdw
andrewwhitecdw marked this pull request as ready for review July 26, 2026 16:44
@andrewwhitecdw
andrewwhitecdw requested a review from a team as a code owner July 26, 2026 16:44
@andrewwhitecdw
andrewwhitecdw requested a review from wmaxey July 26, 2026 16:44
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9e463c8a-01e5-4a04-843e-e26e2221bc38

📥 Commits

Reviewing files that changed from the base of the PR and between a9f6466 and 6c1296d.

📒 Files selected for processing (1)
  • .github/actions/workflow-build/build-workflow.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/actions/workflow-build/build-workflow.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Corrected workflow job cleanup to remove only the matching standalone consumer job.
    • Prevented unrelated workflow jobs from being removed during dispatch processing.

Walkthrough

Changes

Workflow dispatch cleanup

Layer / File(s) Summary
Correct consumer removal check
.github/actions/workflow-build/build-workflow.py
Standalone dispatch cleanup now passes the current consumer job instead of the producer job during two-stage consumer processing.

Suggested reviewers: wmaxey


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/test_finalize_workflow_dispatch_groups.py (1)

60-71: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

suggestion: Assert exact occurrence counts for the shared job in both locations. The current checks would pass if the consumer appeared multiple times under two_stage; asserting one standalone occurrence before finalization and exactly one consumer occurrence afterward would make the regression guard against duplicate scheduling more robust.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 405ebbec-c28f-4923-9cbf-57dda07829e5

📥 Commits

Reviewing files that changed from the base of the PR and between 71282e2 and a9f6466.

📒 Files selected for processing (1)
  • tests/test_finalize_workflow_dispatch_groups.py

@alliepiper alliepiper left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest dropping the test -- it isn't integrated and doesn't run automatically, so it'd just be dead code.

There really isn't existing test infra for these CI scripts, and adding it should be out of scope for a typo fix PR.

Otherwise the fix is correct, lgtm

@github-project-automation github-project-automation Bot moved this from In Review to In Progress in CCCL Jul 26, 2026
## Summary

`build-workflow.py`'s `finalize_workflow_dispatch_groups` deduplicates jobs
that appear both in a dispatch group's `standalone` array and as
producer/consumer jobs of a `two_stage` entry, so each job executes exactly
once. Jobs that were duplicated as two-stage **consumers** were never removed
from the `standalone` array, so they were scheduled (and executed) twice:
once standalone and once as a consumer.

## Root cause

The consumer-removal loop passes the wrong variable to the dedup helper:

```python
for consumer in two_stage_job['consumers']:
    if remove_dispatch_job_from_container(producer, unique_standalone_jobs):
        print(f"Removing standalone job '{consumer['name']}' " +
              f"as it appears as a consumer in '{group_name}'", ...)
```

`producer` is the leftover loop variable from the preceding
`for producer in ...` loop. Since the producer was already removed from
`unique_standalone_jobs` by that earlier loop, the second removal attempt
always returns `False`, so no consumer standalone job is ever removed and
the "appears as a consumer" notice is never printed.

## Fix

Pass `consumer` instead of `producer`:

```python
if remove_dispatch_job_from_container(consumer, unique_standalone_jobs):
```

## Testing

No automated regression test is included per reviewer feedback: the project
has no existing test infrastructure for these CI scripts, and adding one is
out of scope for a typo fix PR.

The fix was verified manually by exercising `finalize_workflow_dispatch_groups`
with a synthetic dispatch group where job `test job` appears both standalone
and as a two-stage consumer:

- With the fix: `standalone after finalize: []` / PASS (duplicated
  standalone removed, consumer notice printed).
- With the unmodified code: `FAIL: standalone not emptied: ['test job']` —
  reproduces the bug.

## Why existing tests missed it

This scripting layer has no unit tests; the duplication only manifests as a
silently double-scheduled CI job, which CI itself does not flag as a failure.

---

Ported from NVIDIA/cccl-gha#1 at the request of @alliepiper — the same typo
was still present in this repo.
@andrewwhitecdw
andrewwhitecdw force-pushed the sweep/bugfix-consumer-standalone-removal branch from a9f6466 to 6c1296d Compare July 26, 2026 18:45
@github-project-automation github-project-automation Bot moved this from In Progress to In Review in CCCL Jul 27, 2026
@miscco

miscco commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot, that looks like a valid fix ^^

@miscco

miscco commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

/ok to test 6c1296d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants