-
Notifications
You must be signed in to change notification settings - Fork 8
Description
We've been evaluating this resource, and have observed skipped CI builds "randomly"
Broadly, I'm looking for a path to more robust handling of potentially out-of-order commit timestamps
Our pipeline is fairly standard, and triggered via webhooks
groups: []
resources:
- name: pull-request
webhook_token: ((token))
type: pull-request
source:
access_token: ((github-token))
repository: [some-repo]
check_every: 24h
resource_types:
- name: pull-request
type: docker-image
source:
repository: itsdalmo/github-pr-resource
...
[snip]
...
jobs:
- name: build
plan:
- get: [our-repository]
trigger: true
resource: pull-request
version: every
...
[snip]
After further investigation, I've managed to reproduce reliably with the following workflow in a test repository (commits with timestamps separated by 1 second):
git checkout pr-test-1 && git commit --allow-empty -m "trigger build" && git checkout pr-test-2 && git commit --allow-empty -m "trigger build" && git push origin pr-test-2 && git push origin pr-test-1
Also reproduces the "skipped build", when the order is reversed (so nothing special about a particular branch):
git checkout pr-test-2 && git commit --allow-empty -m "trigger build" && git checkout pr-test-1 && git commit --allow-empty -m "trigger build" && git push origin pr-test-1 && git push origin pr-test-2
What does not reproduce (commits with timestamp to the same second):
git checkout pr-test-1 && git commit --allow-empty -m "trigger build" && git checkout pr-test-2 && git commit --allow-empty -m "trigger build" && git push origin pr-test-1 pr-test-2
I'm curious about the logic on https://github.com/itsdalmo/github-pr-resource/blob/master/check.go#L38, and wondering if the Github GraphQL is potentially mangling the commit timestamps, or perhaps does not guarantee the commits to appear across PRs in the same moment?
I.e. perhaps when the GraphQL API is queried from the first webhook-initiated check, PR-2 contains the latest commit, but PR-1 does not (perhaps not yet cache-invalidated/re-indexed/refreshed)
Immediately afterwards, when the second webhook-initiated check queries the GraphQL API, the missing commit may be backfilled into PR-1, but the timestamp check on L38 will exclude it....
...I'm really scratching my head as to what is going on.
I'll continue investigation, with a forked version of this resource with some debugging to get more visibility into what is actually being retrieved from the API.