Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

batches: use correct repository field for check_suite & check_run webhook events#52035

Merged
BolajiOlajide merged 5 commits into
mainfrom
bo/fix-github-webhook-nonexistent-field-payload
May 16, 2023
Merged

batches: use correct repository field for check_suite & check_run webhook events#52035
BolajiOlajide merged 5 commits into
mainfrom
bo/fix-github-webhook-nonexistent-field-payload

Conversation

@BolajiOlajide

@BolajiOlajide BolajiOlajide commented May 16, 2023

Copy link
Copy Markdown
Contributor

Closes #51782

GitHub (not sure of how recent this change is) removed the repository field from the CheckSuite and CheckRun field from the check_suite and check_run events.
This resulted in the CI status for customers needing to be updated. I tested this on S2 and I had the same issue.

Here's a link to the Batch Change I created on S2

Here's a changeset that got created via a Batch Change with CI checks passing:

CleanShot 2023-05-16 at 21 49 58@2x

Here's the batch change on S2 not showing the status checks:

CleanShot 2023-05-16 at 21 49 53@2x

Context

Test plan

To test this, you must send a webhook payload to your Sourcegraph instance manually. This fix is specific to GitHub webhooks, here's a sample payload for the check_run event.

  "action": "completed",
  "check_run": {
    "id": 13489247530,
    "name": "build",
    "node_id": "CR_kwDOH1Ragc8AAAADJAWVKg",
    "head_sha": "972fc96f7d318f16c54d86fe4d75b9fe8822cf1f",
    "external_id": "ca395085-040a-526b-2ce8-bdc85f692774",
    "url": "https://api.github.com/repos/sourcegraph-testing/markdowns/check-runs/13489247530",
    "html_url": "https://github.com/sourcegraph-testing/markdowns/actions/runs/4981958423/jobs/8916946181",
    "details_url": "https://github.com/sourcegraph-testing/markdowns/actions/runs/4981958423/jobs/8916946181",
    "status": "completed",
    "conclusion": "success",
    "started_at": "2023-05-15T15:02:24Z",
    "completed_at": "2023-05-15T15:02:26Z",
    "output": {
      "title": null,
      "summary": null,
      "text": null,
      "annotations_count": 0,
      "annotations_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/check-runs/13489247530/annotations"
    },
    "check_suite": {
      "id": 12905278104,
      "node_id": "CS_kwDOH1Ragc8AAAADATbqmA",
      "head_branch": "trois-pop-2",
      "head_sha": "972fc96f7d318f16c54d86fe4d75b9fe8822cf1f",
      "status": "in_progress",
      "conclusion": null,
      "url": "https://api.github.com/repos/sourcegraph-testing/markdowns/check-suites/12905278104",
      "before": "0000000000000000000000000000000000000000",
      "after": "972fc96f7d318f16c54d86fe4d75b9fe8822cf1f",
      "pull_requests": [
        {
          "url": "https://api.github.com/repos/sourcegraph-testing/markdowns/pulls/33",
          "id": 1350971322,
          "number": 33,
          "head": {
            "ref": "trois-pop-2",
            "sha": "972fc96f7d318f16c54d86fe4d75b9fe8822cf1f",
            "repo": {
              "id": 525621889,
              "url": "https://api.github.com/repos/sourcegraph-testing/markdowns",
              "name": "markdowns"
            }
          },
          "base": {
            "ref": "main",
            "sha": "75824a1da2e35f5048a1be1b7d6c19daa3fef8bf",
            "repo": {
              "id": 525621889,
              "url": "https://api.github.com/repos/sourcegraph-testing/markdowns",
              "name": "markdowns"
            }
          }
        }
      ],
      "app": {
        "id": 15368,
        "slug": "github-actions",
        "node_id": "MDM6QXBwMTUzNjg=",
        "owner": {
          "login": "github",
          "id": 9919,
          "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
          "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/github",
          "html_url": "https://github.com/github",
          "followers_url": "https://api.github.com/users/github/followers",
          "following_url": "https://api.github.com/users/github/following{/other_user}",
          "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/github/subscriptions",
          "organizations_url": "https://api.github.com/users/github/orgs",
          "repos_url": "https://api.github.com/users/github/repos",
          "events_url": "https://api.github.com/users/github/events{/privacy}",
          "received_events_url": "https://api.github.com/users/github/received_events",
          "type": "Organization",
          "site_admin": false
        },
        "name": "GitHub Actions",
        "description": "Automate your workflow from idea to production",
        "external_url": "https://help.github.com/en/actions",
        "html_url": "https://github.com/apps/github-actions",
        "created_at": "2018-07-30T09:30:17Z",
        "updated_at": "2019-12-10T19:04:12Z",
        "permissions": {
          "actions": "write",
          "administration": "read",
          "checks": "write",
          "contents": "write",
          "deployments": "write",
          "discussions": "write",
          "issues": "write",
          "merge_queues": "write",
          "metadata": "read",
          "packages": "write",
          "pages": "write",
          "pull_requests": "write",
          "repository_hooks": "write",
          "repository_projects": "write",
          "security_events": "write",
          "statuses": "write",
          "vulnerability_alerts": "read"
        },
        "events": [
          "branch_protection_rule",
          "check_run",
          "check_suite",
          "create",
          "delete",
          "deployment",
          "deployment_status",
          "discussion",
          "discussion_comment",
          "fork",
          "gollum",
          "issues",
          "issue_comment",
          "label",
          "merge_group",
          "milestone",
          "page_build",
          "project",
          "project_card",
          "project_column",
          "public",
          "pull_request",
          "pull_request_review",
          "pull_request_review_comment",
          "push",
          "registry_package",
          "release",
          "repository",
          "repository_dispatch",
          "status",
          "watch",
          "workflow_dispatch",
          "workflow_run"
        ]
      },
      "created_at": "2023-05-15T15:02:15Z",
      "updated_at": "2023-05-15T15:02:25Z"
    },
    "app": {
      "id": 15368,
      "slug": "github-actions",
      "node_id": "MDM6QXBwMTUzNjg=",
      "owner": {
        "login": "github",
        "id": 9919,
        "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
        "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/github",
        "html_url": "https://github.com/github",
        "followers_url": "https://api.github.com/users/github/followers",
        "following_url": "https://api.github.com/users/github/following{/other_user}",
        "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/github/subscriptions",
        "organizations_url": "https://api.github.com/users/github/orgs",
        "repos_url": "https://api.github.com/users/github/repos",
        "events_url": "https://api.github.com/users/github/events{/privacy}",
        "received_events_url": "https://api.github.com/users/github/received_events",
        "type": "Organization",
        "site_admin": false
      },
      "name": "GitHub Actions",
      "description": "Automate your workflow from idea to production",
      "external_url": "https://help.github.com/en/actions",
      "html_url": "https://github.com/apps/github-actions",
      "created_at": "2018-07-30T09:30:17Z",
      "updated_at": "2019-12-10T19:04:12Z",
      "permissions": {
        "actions": "write",
        "administration": "read",
        "checks": "write",
        "contents": "write",
        "deployments": "write",
        "discussions": "write",
        "issues": "write",
        "merge_queues": "write",
        "metadata": "read",
        "packages": "write",
        "pages": "write",
        "pull_requests": "write",
        "repository_hooks": "write",
        "repository_projects": "write",
        "security_events": "write",
        "statuses": "write",
        "vulnerability_alerts": "read"
      },
      "events": [
        "branch_protection_rule",
        "check_run",
        "check_suite",
        "create",
        "delete",
        "deployment",
        "deployment_status",
        "discussion",
        "discussion_comment",
        "fork",
        "gollum",
        "issues",
        "issue_comment",
        "label",
        "merge_group",
        "milestone",
        "page_build",
        "project",
        "project_card",
        "project_column",
        "public",
        "pull_request",
        "pull_request_review",
        "pull_request_review_comment",
        "push",
        "registry_package",
        "release",
        "repository",
        "repository_dispatch",
        "status",
        "watch",
        "workflow_dispatch",
        "workflow_run"
      ]
    },
    "pull_requests": [
      {
        "url": "https://api.github.com/repos/sourcegraph-testing/markdowns/pulls/33",
        "id": 1350971322,
        "number": 33,
        "head": {
          "ref": "trois-pop-2",
          "sha": "972fc96f7d318f16c54d86fe4d75b9fe8822cf1f",
          "repo": {
            "id": 525621889,
            "url": "https://api.github.com/repos/sourcegraph-testing/markdowns",
            "name": "markdowns"
          }
        },
        "base": {
          "ref": "main",
          "sha": "75824a1da2e35f5048a1be1b7d6c19daa3fef8bf",
          "repo": {
            "id": 525621889,
            "url": "https://api.github.com/repos/sourcegraph-testing/markdowns",
            "name": "markdowns"
          }
        }
      }
    ]
  },
  "repository": {
    "id": 525621889,
    "node_id": "R_kgDOH1RagQ",
    "name": "markdowns",
    "full_name": "sourcegraph-testing/markdowns",
    "private": false,
    "owner": {
      "login": "sourcegraph-testing",
      "id": 57702698,
      "node_id": "MDEyOk9yZ2FuaXphdGlvbjU3NzAyNjk4",
      "avatar_url": "https://avatars.githubusercontent.com/u/57702698?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/sourcegraph-testing",
      "html_url": "https://github.com/sourcegraph-testing",
      "followers_url": "https://api.github.com/users/sourcegraph-testing/followers",
      "following_url": "https://api.github.com/users/sourcegraph-testing/following{/other_user}",
      "gists_url": "https://api.github.com/users/sourcegraph-testing/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/sourcegraph-testing/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/sourcegraph-testing/subscriptions",
      "organizations_url": "https://api.github.com/users/sourcegraph-testing/orgs",
      "repos_url": "https://api.github.com/users/sourcegraph-testing/repos",
      "events_url": "https://api.github.com/users/sourcegraph-testing/events{/privacy}",
      "received_events_url": "https://api.github.com/users/sourcegraph-testing/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "html_url": "https://github.com/sourcegraph-testing/markdowns",
    "description": "repository contain several markdown",
    "fork": false,
    "url": "https://api.github.com/repos/sourcegraph-testing/markdowns",
    "forks_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/forks",
    "keys_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/teams",
    "hooks_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/hooks",
    "issue_events_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/issues/events{/number}",
    "events_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/events",
    "assignees_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/assignees{/user}",
    "branches_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/branches{/branch}",
    "tags_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/tags",
    "blobs_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/languages",
    "stargazers_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/stargazers",
    "contributors_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/contributors",
    "subscribers_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/subscribers",
    "subscription_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/subscription",
    "commits_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/contents/{+path}",
    "compare_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/merges",
    "archive_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/downloads",
    "issues_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/issues{/number}",
    "pulls_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/labels{/name}",
    "releases_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/releases{/id}",
    "deployments_url": "https://api.github.com/repos/sourcegraph-testing/markdowns/deployments",
    "created_at": "2022-08-17T03:13:22Z",
    "updated_at": "2023-01-31T20:13:05Z",
    "pushed_at": "2023-05-15T15:02:14Z",
    "git_url": "git://github.com/sourcegraph-testing/markdowns.git",
    "ssh_url": "git@github.com:sourcegraph-testing/markdowns.git",
    "clone_url": "https://github.com/sourcegraph-testing/markdowns.git",
    "svn_url": "https://github.com/sourcegraph-testing/markdowns",
    "homepage": null,
    "size": 7,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": null,
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "has_discussions": false,
    "forks_count": 1,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 1,
    "license": null,
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [

    ],
    "visibility": "public",
    "forks": 1,
    "open_issues": 1,
    "watchers": 0,
    "default_branch": "main"
  },
  "organization": {
    "login": "sourcegraph-testing",
    "id": 57702698,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjU3NzAyNjk4",
    "url": "https://api.github.com/orgs/sourcegraph-testing",
    "repos_url": "https://api.github.com/orgs/sourcegraph-testing/repos",
    "events_url": "https://api.github.com/orgs/sourcegraph-testing/events",
    "hooks_url": "https://api.github.com/orgs/sourcegraph-testing/hooks",
    "issues_url": "https://api.github.com/orgs/sourcegraph-testing/issues",
    "members_url": "https://api.github.com/orgs/sourcegraph-testing/members{/member}",
    "public_members_url": "https://api.github.com/orgs/sourcegraph-testing/public_members{/member}",
    "avatar_url": "https://avatars.githubusercontent.com/u/57702698?v=4",
    "description": null
  },
  "sender": {
    "login": "BolajiOlajide",
    "id": 25608335,
    "node_id": "MDQ6VXNlcjI1NjA4MzM1",
    "avatar_url": "https://avatars.githubusercontent.com/u/25608335?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/BolajiOlajide",
    "html_url": "https://github.com/BolajiOlajide",
    "followers_url": "https://api.github.com/users/BolajiOlajide/followers",
    "following_url": "https://api.github.com/users/BolajiOlajide/following{/other_user}",
    "gists_url": "https://api.github.com/users/BolajiOlajide/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/BolajiOlajide/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/BolajiOlajide/subscriptions",
    "organizations_url": "https://api.github.com/users/BolajiOlajide/orgs",
    "repos_url": "https://api.github.com/users/BolajiOlajide/repos",
    "events_url": "https://api.github.com/users/BolajiOlajide/events{/privacy}",
    "received_events_url": "https://api.github.com/users/BolajiOlajide/received_events",
    "type": "User",
    "site_admin": false
  }
}

@BolajiOlajide BolajiOlajide self-assigned this May 16, 2023
@cla-bot cla-bot Bot added the cla-signed label May 16, 2023
@BolajiOlajide BolajiOlajide changed the title batches: use correct repository field for check_suite & check_run events batches: use correct repository field for check_suite & check_run webhook events May 16, 2023
@BolajiOlajide BolajiOlajide marked this pull request as ready for review May 16, 2023 20:54
@BolajiOlajide BolajiOlajide requested a review from a team May 16, 2023 20:54

@courier-new courier-new left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! Looks reasonable to me!

@BolajiOlajide BolajiOlajide merged commit 9578c41 into main May 16, 2023
@BolajiOlajide BolajiOlajide deleted the bo/fix-github-webhook-nonexistent-field-payload branch May 16, 2023 22:40
github-actions Bot pushed a commit that referenced this pull request May 16, 2023
…hook events (#52035)

Closes #51782

GitHub (not sure of how recent this change is) removed the `repository` field from the `CheckSuite` and `CheckRun` field from the `check_suite` and `check_run` events.
This resulted in the CI status for customers needing to be updated. I tested this on S2 and I had the same issue.

Here's a link to the [Batch Change I created on S2](https://sourcegraph.sourcegraph.com/users/BolajiOlajide/batch-changes/wh-test?visible=1)

(cherry picked from commit 9578c41)
camdencheek pushed a commit that referenced this pull request May 16, 2023
…& check_run webhook events (#52043)

Closes #51782

GitHub (not sure of how recent this change is) removed the `repository`
field from the `CheckSuite` and `CheckRun` field from the `check_suite`
and `check_run` events.
This resulted in the CI status for customers needing to be updated. I
tested this on S2 and I had the same issue.

Backport 9578c41 from #52035

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batches: Check State doesn't seem to update without manual refresh

2 participants