Skip to content
Merged
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
62 changes: 3 additions & 59 deletions .github/workflows/reusable-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
issues: read
pull-requests: read
outputs:
stage: ${{ steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }}
stage: ${{ steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }}
Comment thread
rh-hemartin marked this conversation as resolved.
Resolved
trigger_source: ${{ steps.route.outputs.trigger_source }}
event_payload: ${{ steps.payload.outputs.event_payload }}
steps:
Expand Down Expand Up @@ -421,55 +421,6 @@ jobs:
echo "stage=${STAGE}" >> "${GITHUB_OUTPUT}"
echo "trigger_source=${TRIGGER_SOURCE}" >> "${GITHUB_OUTPUT}"

- name: Check for existing PRs
id: pr-check
if: steps.route.outputs.stage == 'code'
Comment thread
rh-hemartin marked this conversation as resolved.
Resolved
env:
GH_TOKEN: ${{ github.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
SOURCE_REPO: ${{ github.repository }}
run: |
set -euo pipefail
# Query for PRs that actually close this issue (Fixes/Closes/Resolves
# keywords), not a substring search over title/body — the latter
# false-positives on any PR that merely references the issue (#5575).
# closedByPullRequestsReferences also returns MERGED PRs regardless of
# includeClosedPrs, so filter on .state explicitly. Exclude the code-
# agent bot via __typename + login so it can re-dispatch even when it
# already has an open PR (#5974); other bots (e.g. Renovate) still
# block. See docs/contributing/bot-identities.md for the login format.
# NOTE: bot identity is checked in three places — (1) this existing-PR
# guard (GraphQL __typename), (2) the fix eligibility script
# (.defaults/.github/scripts/check-fix-eligibility.sh — gh pr view
# is_bot/login), (3) org-scaffold dispatch.yml:226 (webhook [bot]$
# regex). See docs/contributing/bot-identities.md.
OWNER="${SOURCE_REPO%%/*}"
REPO_NAME="${SOURCE_REPO##*/}"
GQL_ERR=$(mktemp)
if ! LINKED_PRS=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) {
closedByPullRequestsReferences(first: 20) {
nodes { number state author { login __typename } }
}
}
}
}' -f owner="${OWNER}" -f repo="${REPO_NAME}" -F number="${ISSUE_NUMBER}" \
--jq '[.data.repository.issue.closedByPullRequestsReferences.nodes[]
| select(.state == "OPEN")
| select(.author.__typename != "Bot" or .author.login != "fullsend-ai-coder")]
| map("#\(.number)") | join(", ")' \
2>"${GQL_ERR}"); then
echo "::warning::Linked-PR query failed for issue #${ISSUE_NUMBER}: $(tr '\n' ' ' < "${GQL_ERR}" | sed 's/::/__/g')"
LINKED_PRS=""
fi
rm -f "${GQL_ERR}"
if [[ -n "${LINKED_PRS}" ]]; then
echo "::notice::Skipping code dispatch — issue #${ISSUE_NUMBER} has open PR(s) ${LINKED_PRS}"
echo "skipped=true" >> "${GITHUB_OUTPUT}"
fi

- name: Validate routed stage
if: steps.route.outputs.stage != ''
env:
Expand Down Expand Up @@ -571,7 +522,7 @@ jobs:

- name: Check agent is enabled
id: agent-check
if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true'
if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true'
env:
STAGE: ${{ steps.route.outputs.stage }}
run: |
Expand Down Expand Up @@ -599,7 +550,7 @@ jobs:

- name: Resolve PR head for issue_comment events
id: pr-head
if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true' && github.event_name == 'issue_comment' && github.event.issue.pull_request
if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && github.event_name == 'issue_comment' && github.event.issue.pull_request
env:
GH_TOKEN: ${{ github.token }}
SOURCE_REPO: ${{ github.repository }}
Expand Down Expand Up @@ -868,13 +819,6 @@ jobs:
FULLSEND_WORK_ITEM_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }}
FULLSEND_WORK_ITEM_KEY: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }}
ISSUE_NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }}
# Reaches the harness pre-script inside fullsend run, which reads it
# for its --force override of the existing-PR check (pre-script
# output protocol, issue #4718). The override is not end-to-end:
# the route job's own "Check for existing PRs" step above gates
# stage=code first and does not honor --force, so a /fs-code
# --force comment is stopped before this value is ever read.
# env-quoted, never interpolated into run: blocks.
COMMENT_BODY: ${{ fromJSON(needs.route.outputs.event_payload).comment.body }}
REPO_FULL_NAME: ${{ github.repository }}
CODE_ALLOWED_TARGET_BRANCHES: ''
Expand Down
38 changes: 0 additions & 38 deletions internal/scaffold/workflow_call_alignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,6 @@ func TestDispatchPRHeadResolution(t *testing.T) {
assert.Contains(t, s, "id: pr-head",
"resolve step must have id: pr-head")

assert.Contains(t, s, `steps.pr-check.outputs.skipped != 'true'`,
"resolve step if: must include pr-check guard")

assert.Contains(t, s, `'.pull_request = $pr'`,
"must merge PR JSON into event_payload via jq")

Expand All @@ -1003,41 +1000,6 @@ func TestDispatchPRHeadResolution(t *testing.T) {
}
}

// TestDispatchPRCheckBotFilter validates that the existing-PR guard in both
// dispatch workflows uses __typename + login for bot detection (not bare login
// string comparison), and includes matched PR numbers in the skip notice (#5974).
func TestDispatchPRCheckBotFilter(t *testing.T) {
type workflowCase struct {
name string
content func(t *testing.T) []byte
}

cases := []workflowCase{
{
"reusable-dispatch.yml",
loadRepoFile(".github/workflows/reusable-dispatch.yml"),
},
}

for _, wc := range cases {
t.Run(wc.name, func(t *testing.T) {
s := string(wc.content(t))

assert.Contains(t, s, `author { login __typename }`,
"GraphQL query must request both login and __typename for bot detection")

assert.Contains(t, s, `select(.author.__typename != "Bot" or .author.login != "fullsend-ai-coder")`,
"bot filter must exclude only the code-agent bot via __typename + login — see docs/contributing/bot-identities.md")

assert.Contains(t, s, `map("#\(.number)") | join(", ")`,
"jq must format PR numbers as #N, #M — bare .[].number silently truncates multi-PR notices")

assert.Regexp(t, `::notice::.*\$\{LINKED_PRS\}`, s,
"skip notice must include the matched PR number(s)")
})
}
}

// TestActionPRHeadSHAInput validates that action.yml declares the pr-head-sha
// input and uses it in both the fullsend run step and the reconcile step.
func TestActionPRHeadSHAInput(t *testing.T) {
Expand Down
Loading