Skip to content

fix(hotfix): scope the finalize trigger to its own component - #548

Merged
joshua-temple merged 1 commit into
mainfrom
fix/hotfix-finalize-trigger-component-scope
Jul 10, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
fix/hotfix-finalize-trigger-component-scope

Conversation

@joshua-temple

@joshua-temple joshua-temple commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The generated per-component hotfix workflows all emitted the same component-agnostic finalize trigger pull_request: types:[closed], branches: ['env/**']. In a multi-component repo this matches every component's env branches, so cascade-hotfix-web.yaml fires when an api hotfix PR into env/api/staging closes. The post-merge label guard keys on the constant cascade-hotfix label (not per-component), so the sibling workflow proceeds, misparses the target env, and runs finalize with the wrong --component and contents:write, a spurious cross-component state write on every sibling hotfix close. Per-component isolation is broken.

This also reverts an over-broad change: single-component previously emitted env/*; a prior fix widened it to env/** for the multi-component depth case, which changed single-component output unnecessarily.

Fix

internal/generate/hotfix.go: emit a component-scoped finalize branch filter. Single-component (default) emits env/* (single-segment env/<env>, restoring the original byte-identical output); a named component emits env/<component>/**, which matches only its own two-segment env/<component>/<env> branches and never a sibling's. Scoping the trigger gates the sibling event before the label guard is ever reached.

Verification

Regression test TestHotfixGenerator_FinalizeTriggerScopedToComponent (red before, green after): single=env/*, api=env/api/** (matches neither env/** nor env/web/), web=env/web/**. Byte-identical single-component golden restored to env/*; the hotfix e2e scenario assertion updated to match. go build ./..., go test ./... (2700 pass), go test ./... -race, golangci-lint run ./... all clean; e2e module builds and vets.

Caught by the v1-readiness fleet's new per-component monorepo coverage.

The pull_request(closed) finalize trigger emitted branches: ['env/**']
for every hotfix workflow. env/** matches all components' env branches,
so cascade-hotfix-web.yaml fired on an api hotfix PR into env/api/staging,
spawning a spurious cross-component run that broke per-component isolation.

Scope the trigger to the workflow's own component: single-component stays
env/* (single-segment env/staging, restoring the byte-identical historical
output), and a named component uses env/<component>/** so it matches only
its own two-segment env branches (env/api/staging) and never a sibling's.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit f904ea5 into main Jul 10, 2026
20 checks passed
@joshua-temple
joshua-temple deleted the fix/hotfix-finalize-trigger-component-scope branch July 10, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant