check: paginate by push date, not git commit date #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
github-pr-resource used to paginate by
PushedDate
. This is a timestamp GitHub stores on each commit at the time the user typedgit push
. By paginating byPushedDate
, github-pr-resource would only trigger builds on PRs that have had a new commit pushed to them since the last time github-pr-resource ran. That makes sense.In telia-oss#22 it was discovered that on pull requests created from forked branches have
PushedDate: nil
. To fix, the paginated onCommitDate
, which is the time that the user typesgit commit
.However, this created telia-oss#26 - if someone types
git commit
, waits a few hours, then pushes, their commit won't be picked up because we've already handled newer commits.I attempted to fix this in #4 by removing the filter entirely. This fixes the problem but increases the github token usage a lot.
Instead, fix this by applying mplzik@edca4f5 and combining it with the PR creation date. This paginates by
max(lastCommit.PushedDate || lastCommit.CommitDate, pullRequest.CreatedAt)
. In code, all of our commits have a PushedDate so we're back to the original, fixed behavior. It also handles the case where you push a branch, then don't open a pull request for several minutes.This should reduce the github usage a lot, since we'll go from loading the data on all 300 open pull requests to only loading 1-5 pull requests that have opened since the last call.
Origin
Me
Summary of Changes
ChangedDate = PushedDate || CommitDate
Test Plan
task test
cat ~/tmp/test.json | go run cmd/check/main.go
I observed that this only returned the 4 new commits that have been updated since 2021-12-10T01:30:42Z.
To deploy:
to deploy:
latest
docker imageDocumentation
N/A