Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/reusable-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:
TRIGGERING_LABEL: ${{ github.event.label.name }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PR_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
ORG_NAME: ${{ github.repository_owner }}
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -284,7 +285,14 @@ jobs:
closed)
# Intentional ungated: any closer may trigger read-only retro
# (lifecycle accounting). See ADR 0054 #5223 note.
STAGE="retro"
case "${PR_HEAD_REF}" in
fullsend/onboard|fullsend/offboard|fullsend/scaffold-install)
Comment on lines +288 to +289

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Per-org scaffold prs still run retros 📘 Rule violation ⚙ Maintainability

The new scaffold-branch guard in reusable-dispatch.yml is absent from the per-org dispatch.yml,
whose closed-PR route still sets STAGE="retro". Closing a PR on any of the three scaffold branches
through the per-org route therefore continues to dispatch a retro, and the new regression test
exercises only the per-repo route.
Agent Prompt
## Issue description
The per-repo route now skips retro for three scaffold branches, but the per-org route still dispatches retro for them.

## Fix Focus Areas
- .github/workflows/reusable-dispatch.yml[288-295]
- internal/scaffold/fullsend-repo/.github/workflows/dispatch.yml[215-219]

## Recommended Fix
Apply the same branch guard to the per-org route and test both routes. If the difference is intentional, add an inline comment explaining why it is specific to the per-repo workflow.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[medium] protected-path

This PR modifies a protected infrastructure file: .github/workflows/reusable-dispatch.yml. Issue #8043 and the PR description explain the scaffold-retro suppression, but protected-path changes always require human approval, regardless of context.

Suggested fix: Obtain a human maintainer's approval of the workflow routing change.

echo "::notice::Skipping retro for fullsend scaffold PR on ${PR_HEAD_REF}"
Comment on lines +288 to +290

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Unrelated pull requests skip retros 🐞 Bug ≡ Correctness

The closed route decides whether to suppress retro using only PR_HEAD_REF, without verifying
that the pull request is a scaffold PR. If a contributor closes a substantive PR from a fork branch
named fullsend/onboard or fullsend/offboard, the caller forwards the event but the route emits
no stage, so the automatic retro never runs.
Agent Prompt
## Issue description
The closed-PR route treats predictable branch names as proof that a PR is a scaffold PR, allowing unrelated PRs to bypass automatic retro.
## Fix Focus Areas
- .github/workflows/reusable-dispatch.yml[119-123]
- .github/workflows/reusable-dispatch.yml[284-295]
## Recommended Fix
Require a trustworthy scaffold ownership signal in addition to the exact branch name before suppressing retro; route PRs with missing or mismatched ownership data to retro. Add a regression case for an unrelated PR using a scaffold-named branch.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

;;
*)
STAGE="retro"
;;
esac
;;
esac
;;
Expand Down
79 changes: 79 additions & 0 deletions internal/scaffold/dispatch_retro_scaffold_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package scaffold

import (
"os"
"os/exec"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)

// TestReusableDispatchSkipsRetroForScaffoldBranches executes the actual route
// script, so the branch guard cannot drift from the workflow's behaviour.
func TestReusableDispatchSkipsRetroForScaffoldBranches(t *testing.T) {
if _, err := exec.LookPath("bash"); err != nil {
t.Skip("bash not available")
}

content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-dispatch.yml"))
require.NoError(t, err)

var workflow struct {
Jobs struct {
Route struct {
Steps []struct {
Name string `yaml:"name"`
Run string `yaml:"run"`
} `yaml:"steps"`
} `yaml:"route"`
} `yaml:"jobs"`
}
require.NoError(t, yaml.Unmarshal(content, &workflow))

var script string
for _, step := range workflow.Jobs.Route.Steps {
if step.Name == "Determine stage" {
script = step.Run
break
}
}
require.NotEmpty(t, script, "route job must retain its Determine stage script")

runRoute := func(t *testing.T, branch string) string {
t.Helper()
dir := t.TempDir()
scriptPath := filepath.Join(dir, "route.sh")
outputPath := filepath.Join(dir, "output")
require.NoError(t, os.WriteFile(scriptPath, []byte(script), 0o644))

cmd := exec.Command("bash", scriptPath)
cmd.Env = append(os.Environ(),
"EVENT_NAME=pull_request_target",
"EVENT_ACTION=closed",
"PR_HEAD_REF="+branch,
"GITHUB_OUTPUT="+outputPath,
)
out, err := cmd.CombinedOutput()
require.NoError(t, err, "route script must exit cleanly: %s", out)

result, err := os.ReadFile(outputPath)
require.NoError(t, err)
return string(result)
}

for _, branch := range []string{
"fullsend/onboard",
"fullsend/offboard",
"fullsend/scaffold-install",
} {
t.Run(branch, func(t *testing.T) {
require.Equal(t, "stage=\n", runRoute(t, branch))
})
}

t.Run("ordinary branch still routes to retro", func(t *testing.T) {
require.Equal(t, "stage=retro\ntrigger_source=\n", runRoute(t, "fix/8043"))
})
}
Loading