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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.6.0
* Fix: For `workflow_run` events, resolve the commit of the check run from related pull request head commits first (matching `workflow_run.head_branch`, then first PR), and fall back to `workflow_run.head_sha` for non-PR runs https://github.com/dorny/test-reporter/pull/673

## 2.5.0
* Feature: Add Nette Tester support with `tester-junit` reporter https://github.com/dorny/test-reporter/pull/707
* Maintenance: Bump actions/upload-artifact from 5 to 6 https://github.com/dorny/test-reporter/pull/695
Expand Down
12 changes: 11 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ export function getCheckRunContext(): {sha: string; runId: number} {
if (!event.workflow_run) {
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
}
const prs = event.workflow_run.pull_requests ?? []
// For `workflow_run`, we want to report against the PR commit when possible so annotations land
// on the contributor's changes. Prefer the PR whose `head.ref` matches `workflow_run.head_branch`,
// then fall back to the first PR head SHA, and finally to `workflow_run.head_sha` for non-PR runs.
const prShaMatch = prs.find(pr => pr.head?.ref === event.workflow_run.head_branch)?.head?.sha
const prShaFirst = prs[0]?.head?.sha
const sha = prShaMatch ?? prShaFirst ?? event.workflow_run.head_sha
if (!sha) {
throw new Error('Unable to resolve SHA from workflow_run (no PR head.sha or head_sha)')
}
return {
sha: event.workflow_run.head_commit.id,
sha,
runId: event.workflow_run.id
}
}
Expand Down