kamilkisiela / graphql-inspector

🕵️‍♀️ Validate schema, get schema change notifications, validate operations, find breaking changes, look for similar types, schema coverage
https://the-guild.dev/graphql/inspector
MIT License
1.64k stars 185 forks source link

Inspector action incorrectly uses first run when there's multiple runs referencing the same git commit #2596

Open garyd203 opened 1 year ago

garyd203 commented 1 year ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

We've integrated the Inspector action into our GitHub pull request workflow (it's been working well - thank you 🎉 ). However, if multiple GitHub Action runs reference the same git commit [*], then the Inspector action for subsequent runs will incorrectly use the first run. This affects looking up the approve-label on the PR, and posting the check to the PR.

[*] We use the git-flow workflow, so we will push a first PR (with a GitHub Actions run) to our development branch (with a second GitHub Actions run after merge), and then from time to time create a PR (with a third GitHub Actions run) merging the development branch into the deployment branch (with yet another GitHub Actions run). Because the 3rd run is on a PR that uses the same commit as the 2nd run, then breaking changes get blocked by the Inspector action, even if we set the approved-breaking-change label on the PR

To Reproduce

  1. Add Inspector action to a GitHub workflow. Enable the workflow for all changes, but only enable the Inspector step for PR's (eg. use if: github.base_ref != '' on the step)
  2. Push a breaking change direct to branch1, wait for the GitHub Actions run to finish
  3. Create a PR merging branch1 to branch2.
  4. Note that the "GraphQL Inspector" check is added to the GitHub Actions run from point (2), not the one for the PR in point (3)
  5. Add the "approved-breaking-change" label to the PR and re-run the failed check. Note that the check still fails, because it doesn't look for the label on the PR.

Expected behavior

The Inspector action should look up the run based on the GitHub Actions run ID, not based on the git commit.

Environment:

Additional context

kolkinn commented 3 weeks ago

We also see this in our setup. Here we retroactively label the pull request if necessary, in turn triggering the action.

  pull_request:
    branches:
      - dev
      - prod
    types:
      # Default options
      - opened
      - reopened
      - synchronize
      # Allows using a label to have the check pass on breaking changes
      - labeled
      - unlabeled