You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pull requests use wrong date from github context #327
This is a bit convluted so I'll file an issue instead of a PR...
I use a fork of github-action-benchmark and last week I learned of a case where ultimately the root cause is that you/we use the wrong date field from the github pull_request context. The relevant code is
After a night with hours of googling, it seems like this field and the contexts in general aren't fully documented. But based on some random StackOverflow thread coupled with my own observations, it turns out the pr.head.repo.updated_at field refers to either some generic meta-data being updated about the repo, or what was my observation, specifically it is the timestamp for when a fork was last synced with the upstream repo. So, when some developers never sync the main branch of their own fork, then this date will be far in the past.
The more correct timestamp in this area is the pushed_at field, which is when some patch was last pushed to the repo. But note that this is any push to any branch, so it's not necessarily the timestamp of the commit in the PR.
To get the correct timestamp you have to use the pr.head.sha and actually fetch the commit metadata from github. getCommitFromGithubApiRequest() works fine here.
That in turn means that github-token is required for pull requests and since in config.ts you don't really know that you are working on a pull request then you might as well make github-token always required.
Hope this helps, wanted to write down this before I forget it, but not going to work on a patch in the immediate future anyways.
Update src/extract.ts to make getCommitFromPullRequestPayload async, accept a github token, remove use of pr.head.repo.updated_at and fetch the commit via pr.head.sha from the GitHub API (returning commit.author.date), update calls to pass the token; update src/config.ts to require/validate github-token early with a clear error message; and change action.yml to mark github-token required (defaulting to ${{ github.token }}) so PR timestamps are accurate.
Update action.yml to make the github-token input required and clarify its purpose, add runtime validation in src/config.ts to throw if github-token is missing, and change src/extract.ts to require the token for pull-request events by adding a token parameter to getCommitFromPullRequestPayload and fetching commit metadata from the GitHub API (with the token) instead of relying on PR payload timestamps.
Activity
coderabbitai commentedon Nov 5, 2025
A summary of the changes CodeRabbit can apply:
fix: use merge commit timestamp for PR benchmark entries [#327]