Skip to content

Out-of-order commits on different PRs result in skipped builds #26

@seanmailander-orange

Description

@seanmailander-orange

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.

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