fix(hotfix): scope the finalize trigger to its own component - #548
Merged
Merged
Conversation
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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, socascade-hotfix-web.yamlfires when an api hotfix PR intoenv/api/stagingcloses. The post-merge label guard keys on the constantcascade-hotfixlabel (not per-component), so the sibling workflow proceeds, misparses the target env, and runs finalize with the wrong--componentandcontents: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 toenv/**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) emitsenv/*(single-segmentenv/<env>, restoring the original byte-identical output); a named component emitsenv/<component>/**, which matches only its own two-segmentenv/<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 neitherenv/**norenv/web/), web=env/web/**. Byte-identical single-component golden restored toenv/*; 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.