Skip to content

pull requests use wrong date from github context #327

@henrikingo

Description

@henrikingo

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

https://github.com/benchmark-action/github-action-benchmark/blob/2e6f4e33d6695578ee68981a04100aa77e0ac037/src/extract.ts#L256C20-L256C43

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions