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 https://github.com/mplzik/github-pr-resource/commit/edca4f5303b8086f6847012710398b9a26f1bdca 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 || CommitDateTest Plan
task testcat ~/tmp/test.json | go run cmd/check/main.go{ "source": { "repository": "opendoor-labs/code", "access_token": "ghp_<redacted>", "base_branch": "master" }, "version": { "approved_review_count": "0", "changed": "2021-12-10T01:30:42Z", "commit": "0130ca9d1475adfc094a84b4b6c230122f97db4f", "committed": "2021-12-10T01:30:32Z", "pr": "38122", "state": "OPEN" } }I observed that this only returned the 4 new commits that have been updated since 2021-12-10T01:30:42Z.
To deploy:
to deploy:
latestdocker imageDocumentation
N/A