-
Notifications
You must be signed in to change notification settings - Fork 0
docs: refresh spec, challenges, and testing post-turns extraction #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ export async function resolveWorkflowRun({ | |
| const { triggerNumber, triggerEvent, triggerType, triggerRef } = await resolveTrigger({ | ||
| pullRequests: run?.pull_requests ?? [], | ||
| headBranch: run?.head_branch ?? '', | ||
| headSha: run?.head_sha ?? '', | ||
| event: run?.event ?? '', | ||
| octokit, | ||
| owner, | ||
|
|
@@ -223,6 +224,7 @@ async function fetchRun({ | |
| run_started_at?: string | null; | ||
| updated_at?: string | null; | ||
| head_branch?: string | null; | ||
| head_sha?: string | null; | ||
| event?: string | null; | ||
| name?: string | null; | ||
| pull_requests?: Array<{ number: number }>; | ||
|
|
@@ -237,6 +239,7 @@ async function fetchRun({ | |
| run_started_at: data.run_started_at, | ||
| updated_at: data.updated_at, | ||
| head_branch: data.head_branch, | ||
| head_sha: data.head_sha, | ||
| event: data.event, | ||
| name: data.name, | ||
| pull_requests: (data.pull_requests ?? []).map((pr) => ({ number: pr.number })), | ||
|
|
@@ -255,6 +258,7 @@ async function fetchRun({ | |
| */ | ||
| async function resolveTrigger({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code style: Function parameters should be in alphabetical order per the repo's style guide. Current: (Note: This was pre-existing, but since the PR touches these lines, it's a good opportunity to fix it.) |
||
| headBranch, | ||
| headSha, | ||
| event, | ||
| octokit, | ||
| owner, | ||
|
|
@@ -263,6 +267,8 @@ async function resolveTrigger({ | |
| }: { | ||
| /** Head branch name of the triggering run */ | ||
| headBranch: string; | ||
| /** Head commit SHA of the triggering run — used to validate the PR fallback match */ | ||
| headSha: string; | ||
| /** Event that triggered the original workflow run */ | ||
| event: string; | ||
| /** Authenticated Octokit instance */ | ||
|
|
@@ -301,17 +307,20 @@ async function resolveTrigger({ | |
| // Omit owner prefix so forked PRs are also matched (fork owner differs from base owner) | ||
| head: headBranch, | ||
| owner, | ||
| per_page: 1, | ||
| per_page: 5, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test coverage: The change from The existing test at Add a test that verifies:
|
||
| repo, | ||
| sort: 'updated', | ||
| state: 'all', | ||
| }); | ||
| if (prs[0]) { | ||
| // Validate by head SHA when available to avoid matching the wrong PR when multiple | ||
| // PRs share the same branch name (e.g. reused or fork branches). | ||
| const match = headSha ? (prs.find((pr) => pr.head.sha === headSha) ?? prs[0]) : prs[0]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type safety violation: The Add an explicit type annotation: const match = headSha ? (prs.find((pr: { head: { sha: string } }) => pr.head.sha === headSha) ?? prs[0]) : prs[0];Or better yet, destructure the |
||
| if (match) { | ||
| return { | ||
| triggerNumber: prs[0].number, | ||
| triggerNumber: match.number, | ||
| triggerEvent: event, | ||
| triggerType: normalizeTriggerType({ event, isPR: true }), | ||
| triggerRef: `PR #${prs[0].number}`, | ||
| triggerRef: `PR #${match.number}`, | ||
| }; | ||
| } | ||
| } catch (error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete documentation: This paragraph doesn't mention the SHA validation that was added to the
pulls.listfallback.The code now validates PRs by head SHA to avoid misattribution when multiple PRs share the same branch name (e.g., reused or fork branches). Consider adding: