Repository: google/go-github
Pull request #2101 (2021-09-19 20:29:45)

Add common Installation field to webhook events
Closes: #2099. 

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2101](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (dfadd92) into [master](https://codecov.io/gh/google/go-github/commit/bd8dd5277b501dcc51869451a65d98df75de903c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (bd8dd52) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2101/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2101   +/-   ##
=======================================
  Coverage   97.77%   97.77%           
=======================================
  Files         109      109           
  Lines        9724     9724           
=======================================
  Hits         9508     9508           
  Misses        150      150           
  Partials       66       66           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/event\_types.go](https://codecov.io/gh/google/go-github/pull/2101/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2V2ZW50X3R5cGVzLmdv) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [bd8dd52...dfadd92](https://codecov.io/gh/google/go-github/pull/2101?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go
index b2c40d47..3cd9df13 100644
--- a/github/actions_workflow_runs.go
+++ b/github/actions_workflow_runs.go
@@ -14,31 +14,33 @@ import (
 
 // WorkflowRun represents a repository action workflow run.
 type WorkflowRun struct {
-	ID             *int64         `json:"id,omitempty"`
-	Name           *string        `json:"name,omitempty"`
-	NodeID         *string        `json:"node_id,omitempty"`
-	HeadBranch     *string        `json:"head_branch,omitempty"`
-	HeadSHA        *string        `json:"head_sha,omitempty"`
-	RunNumber      *int           `json:"run_number,omitempty"`
-	Event          *string        `json:"event,omitempty"`
-	Status         *string        `json:"status,omitempty"`
-	Conclusion     *string        `json:"conclusion,omitempty"`
-	WorkflowID     *int64         `json:"workflow_id,omitempty"`
-	URL            *string        `json:"url,omitempty"`
-	HTMLURL        *string        `json:"html_url,omitempty"`
-	PullRequests   []*PullRequest `json:"pull_requests,omitempty"`
-	CreatedAt      *Timestamp     `json:"created_at,omitempty"`
-	UpdatedAt      *Timestamp     `json:"updated_at,omitempty"`
-	JobsURL        *string        `json:"jobs_url,omitempty"`
-	LogsURL        *string        `json:"logs_url,omitempty"`
-	CheckSuiteURL  *string        `json:"check_suite_url,omitempty"`
-	ArtifactsURL   *string        `json:"artifacts_url,omitempty"`
-	CancelURL      *string        `json:"cancel_url,omitempty"`
-	RerunURL       *string        `json:"rerun_url,omitempty"`
-	HeadCommit     *HeadCommit    `json:"head_commit,omitempty"`
-	WorkflowURL    *string        `json:"workflow_url,omitempty"`
-	Repository     *Repository    `json:"repository,omitempty"`
-	HeadRepository *Repository    `json:"head_repository,omitempty"`
+	ID               *int64         `json:"id,omitempty"`
+	Name             *string        `json:"name,omitempty"`
+	NodeID           *string        `json:"node_id,omitempty"`
+	HeadBranch       *string        `json:"head_branch,omitempty"`
+	HeadSHA          *string        `json:"head_sha,omitempty"`
+	RunNumber        *int           `json:"run_number,omitempty"`
+	Event            *string        `json:"event,omitempty"`
+	Status           *string        `json:"status,omitempty"`
+	Conclusion       *string        `json:"conclusion,omitempty"`
+	WorkflowID       *int64         `json:"workflow_id,omitempty"`
+	CheckSuiteID     *int64         `json:"check_suite_id,omitempty"`
+	CheckSuiteNodeID *string        `json:"check_suite_node_id,omitempty"`
+	URL              *string        `json:"url,omitempty"`
+	HTMLURL          *string        `json:"html_url,omitempty"`
+	PullRequests     []*PullRequest `json:"pull_requests,omitempty"`
+	CreatedAt        *Timestamp     `json:"created_at,omitempty"`
+	UpdatedAt        *Timestamp     `json:"updated_at,omitempty"`
+	JobsURL          *string        `json:"jobs_url,omitempty"`
+	LogsURL          *string        `json:"logs_url,omitempty"`
+	CheckSuiteURL    *string        `json:"check_suite_url,omitempty"`
+	ArtifactsURL     *string        `json:"artifacts_url,omitempty"`
+	CancelURL        *string        `json:"cancel_url,omitempty"`
+	RerunURL         *string        `json:"rerun_url,omitempty"`
+	HeadCommit       *HeadCommit    `json:"head_commit,omitempty"`
+	WorkflowURL      *string        `json:"workflow_url,omitempty"`
+	Repository       *Repository    `json:"repository,omitempty"`
+	HeadRepository   *Repository    `json:"head_repository,omitempty"`
 }
 
 // WorkflowRuns represents a slice of repository action workflow run.
diff --git a/github/event_types.go b/github/event_types.go
index 384aa3a1..e55685c7 100644
--- a/github/event_types.go
+++ b/github/event_types.go
@@ -130,6 +130,9 @@ type DeployKeyEvent struct {
 
 	// The deploy key resource.
 	Key *Key `json:"key,omitempty"`
+
+	// The following fields are only populated by Webhook events.
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // DeploymentEvent represents a deployment.
@@ -186,7 +189,8 @@ type GitHubAppAuthorizationEvent struct {
 	Action *string `json:"action,omitempty"`
 
 	// The following fields are only populated by Webhook events.
-	Sender *User `json:"sender,omitempty"`
+	Sender       *User         `json:"sender,omitempty"`
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // Page represents a single Wiki page.
@@ -478,6 +482,9 @@ type MetaEvent struct {
 	// This will contain different keys based on the type of webhook it is: repository,
 	// organization, business, app, or GitHub Marketplace.
 	Hook *Hook `json:"hook,omitempty"`
+
+	// The following fields are only populated by Webhook events.
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // MilestoneEvent is triggered when a milestone is created, closed, opened, edited, or deleted.
@@ -551,6 +558,9 @@ type PackageEvent struct {
 	Repo    *Repository   `json:"repository,omitempty"`
 	Org     *Organization `json:"organization,omitempty"`
 	Sender  *User         `json:"sender,omitempty"`
+
+	// The following fields are only populated by Webhook events.
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // PageBuildEvent represents an attempted build of a GitHub Pages site, whether
@@ -939,6 +949,9 @@ type RepositoryVulnerabilityAlertEvent struct {
 
 	//The repository of the vulnerable dependency.
 	Repository *Repository `json:"repository,omitempty"`
+
+	// The following fields are only populated by Webhook events.
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // RepositoryVulnerabilityAlert represents a repository security alert.
@@ -969,9 +982,10 @@ type StarEvent struct {
 	StarredAt *Timestamp `json:"starred_at,omitempty"`
 
 	// The following fields are only populated by Webhook events.
-	Org    *Organization `json:"organization,omitempty"`
-	Repo   *Repository   `json:"repository,omitempty"`
-	Sender *User         `json:"sender,omitempty"`
+	Org          *Organization `json:"organization,omitempty"`
+	Repo         *Repository   `json:"repository,omitempty"`
+	Sender       *User         `json:"sender,omitempty"`
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // StatusEvent is triggered when the status of a Git commit changes.
@@ -1049,6 +1063,9 @@ type UserEvent struct {
 	Action     *string     `json:"action,omitempty"`
 	Enterprise *Enterprise `json:"enterprise,omitempty"`
 	Sender     *User       `json:"sender,omitempty"`
+
+	// The following fields are only populated by Webhook events.
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // WatchEvent is related to starring a repository, not watching. See this API
@@ -1078,9 +1095,10 @@ type WorkflowDispatchEvent struct {
 	Workflow *string         `json:"workflow,omitempty"`
 
 	// The following fields are only populated by Webhook events.
-	Repo   *Repository   `json:"repository,omitempty"`
-	Org    *Organization `json:"organization,omitempty"`
-	Sender *User         `json:"sender,omitempty"`
+	Repo         *Repository   `json:"repository,omitempty"`
+	Org          *Organization `json:"organization,omitempty"`
+	Sender       *User         `json:"sender,omitempty"`
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // WorkflowJobEvent is triggered when a job is queued, started or completed.
@@ -1092,9 +1110,10 @@ type WorkflowJobEvent struct {
 	Action *string `json:"action,omitempty"`
 
 	// The following fields are only populated by Webhook events.
-	Org    *Organization `json:"organization,omitempty"`
-	Repo   *Repository   `json:"repository,omitempty"`
-	Sender *User         `json:"sender,omitempty"`
+	Org          *Organization `json:"organization,omitempty"`
+	Repo         *Repository   `json:"repository,omitempty"`
+	Sender       *User         `json:"sender,omitempty"`
+	Installation *Installation `json:"installation,omitempty"`
 }
 
 // WorkflowRunEvent is triggered when a GitHub Actions workflow run is requested or completed.
@@ -1106,7 +1125,8 @@ type WorkflowRunEvent struct {
 	WorkflowRun *WorkflowRun `json:"workflow_run,omitempty"`
 
 	// The following fields are only populated by Webhook events.
-	Org    *Organization `json:"organization,omitempty"`
-	Repo   *Repository   `json:"repository,omitempty"`
-	Sender *User         `json:"sender,omitempty"`
+	Org          *Organization `json:"organization,omitempty"`
+	Repo         *Repository   `json:"repository,omitempty"`
+	Sender       *User         `json:"sender,omitempty"`
+	Installation *Installation `json:"installation,omitempty"`
 }
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 8422d6a7..d57c57c2 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -3148,6 +3148,14 @@ func (d *DeployKeyEvent) GetAction() string {
 	return *d.Action
 }
 
+// GetInstallation returns the Installation field.
+func (d *DeployKeyEvent) GetInstallation() *Installation {
+	if d == nil {
+		return nil
+	}
+	return d.Installation
+}
+
 // GetKey returns the Key field.
 func (d *DeployKeyEvent) GetKey() *Key {
 	if d == nil {
@@ -4612,6 +4620,14 @@ func (g *GitHubAppAuthorizationEvent) GetAction() string {
 	return *g.Action
 }
 
+// GetInstallation returns the Installation field.
+func (g *GitHubAppAuthorizationEvent) GetInstallation() *Installation {
+	if g == nil {
+		return nil
+	}
+	return g.Installation
+}
+
 // GetSender returns the Sender field.
 func (g *GitHubAppAuthorizationEvent) GetSender() *User {
 	if g == nil {
@@ -7796,6 +7812,14 @@ func (m *MetaEvent) GetHookID() int64 {
 	return *m.HookID
 }
 
+// GetInstallation returns the Installation field.
+func (m *MetaEvent) GetInstallation() *Installation {
+	if m == nil {
+		return nil
+	}
+	return m.Installation
+}
+
 // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
 func (m *Metric) GetHTMLURL() string {
 	if m == nil || m.HTMLURL == nil {
@@ -8972,6 +8996,14 @@ func (p *PackageEvent) GetAction() string {
 	return *p.Action
 }
 
+// GetInstallation returns the Installation field.
+func (p *PackageEvent) GetInstallation() *Installation {
+	if p == nil {
+		return nil
+	}
+	return p.Installation
+}
+
 // GetOrg returns the Org field.
 func (p *PackageEvent) GetOrg() *Organization {
 	if p == nil {
@@ -14292,6 +14324,14 @@ func (r *RepositoryVulnerabilityAlertEvent) GetAlert() *RepositoryVulnerabilityA
 	return r.Alert
 }
 
+// GetInstallation returns the Installation field.
+func (r *RepositoryVulnerabilityAlertEvent) GetInstallation() *Installation {
+	if r == nil {
+		return nil
+	}
+	return r.Installation
+}
+
 // GetRepository returns the Repository field.
 func (r *RepositoryVulnerabilityAlertEvent) GetRepository() *Repository {
 	if r == nil {
@@ -14908,6 +14948,14 @@ func (s *StarEvent) GetAction() string {
 	return *s.Action
 }
 
+// GetInstallation returns the Installation field.
+func (s *StarEvent) GetInstallation() *Installation {
+	if s == nil {
+		return nil
+	}
+	return s.Installation
+}
+
 // GetOrg returns the Org field.
 func (s *StarEvent) GetOrg() *Organization {
 	if s == nil {
@@ -16852,6 +16900,14 @@ func (u *UserEvent) GetEnterprise() *Enterprise {
 	return u.Enterprise
 }
 
+// GetInstallation returns the Installation field.
+func (u *UserEvent) GetInstallation() *Installation {
+	if u == nil {
+		return nil
+	}
+	return u.Installation
+}
+
 // GetSender returns the Sender field.
 func (u *UserEvent) GetSender() *User {
 	if u == nil {
@@ -17468,6 +17524,14 @@ func (w *WorkflowBill) GetTotalMS() int64 {
 	return *w.TotalMS
 }
 
+// GetInstallation returns the Installation field.
+func (w *WorkflowDispatchEvent) GetInstallation() *Installation {
+	if w == nil {
+		return nil
+	}
+	return w.Installation
+}
+
 // GetOrg returns the Org field.
 func (w *WorkflowDispatchEvent) GetOrg() *Organization {
 	if w == nil {
@@ -17644,6 +17708,14 @@ func (w *WorkflowJobEvent) GetAction() string {
 	return *w.Action
 }
 
+// GetInstallation returns the Installation field.
+func (w *WorkflowJobEvent) GetInstallation() *Installation {
+	if w == nil {
+		return nil
+	}
+	return w.Installation
+}
+
 // GetOrg returns the Org field.
 func (w *WorkflowJobEvent) GetOrg() *Organization {
 	if w == nil {
@@ -17692,6 +17764,22 @@ func (w *WorkflowRun) GetCancelURL() string {
 	return *w.CancelURL
 }
 
+// GetCheckSuiteID returns the CheckSuiteID field if it's non-nil, zero value otherwise.
+func (w *WorkflowRun) GetCheckSuiteID() int64 {
+	if w == nil || w.CheckSuiteID == nil {
+		return 0
+	}
+	return *w.CheckSuiteID
+}
+
+// GetCheckSuiteNodeID returns the CheckSuiteNodeID field if it's non-nil, zero value otherwise.
+func (w *WorkflowRun) GetCheckSuiteNodeID() string {
+	if w == nil || w.CheckSuiteNodeID == nil {
+		return ""
+	}
+	return *w.CheckSuiteNodeID
+}
+
 // GetCheckSuiteURL returns the CheckSuiteURL field if it's non-nil, zero value otherwise.
 func (w *WorkflowRun) GetCheckSuiteURL() string {
 	if w == nil || w.CheckSuiteURL == nil {
@@ -17916,6 +18004,14 @@ func (w *WorkflowRunEvent) GetAction() string {
 	return *w.Action
 }
 
+// GetInstallation returns the Installation field.
+func (w *WorkflowRunEvent) GetInstallation() *Installation {
+	if w == nil {
+		return nil
+	}
+	return w.Installation
+}
+
 // GetOrg returns the Org field.
 func (w *WorkflowRunEvent) GetOrg() *Organization {
 	if w == nil {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index df604c44..51c3d155 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -3681,6 +3681,13 @@ func TestDeployKeyEvent_GetAction(tt *testing.T) {
 	d.GetAction()
 }
 
+func TestDeployKeyEvent_GetInstallation(tt *testing.T) {
+	d := &DeployKeyEvent{}
+	d.GetInstallation()
+	d = nil
+	d.GetInstallation()
+}
+
 func TestDeployKeyEvent_GetKey(tt *testing.T) {
 	d := &DeployKeyEvent{}
 	d.GetKey()
@@ -5391,6 +5398,13 @@ func TestGitHubAppAuthorizationEvent_GetAction(tt *testing.T) {
 	g.GetAction()
 }
 
+func TestGitHubAppAuthorizationEvent_GetInstallation(tt *testing.T) {
+	g := &GitHubAppAuthorizationEvent{}
+	g.GetInstallation()
+	g = nil
+	g.GetInstallation()
+}
+
 func TestGitHubAppAuthorizationEvent_GetSender(tt *testing.T) {
 	g := &GitHubAppAuthorizationEvent{}
 	g.GetSender()
@@ -9134,6 +9148,13 @@ func TestMetaEvent_GetHookID(tt *testing.T) {
 	m.GetHookID()
 }
 
+func TestMetaEvent_GetInstallation(tt *testing.T) {
+	m := &MetaEvent{}
+	m.GetInstallation()
+	m = nil
+	m.GetInstallation()
+}
+
 func TestMetric_GetHTMLURL(tt *testing.T) {
 	var zeroValue string
 	m := &Metric{HTMLURL: &zeroValue}
@@ -10532,6 +10553,13 @@ func TestPackageEvent_GetAction(tt *testing.T) {
 	p.GetAction()
 }
 
+func TestPackageEvent_GetInstallation(tt *testing.T) {
+	p := &PackageEvent{}
+	p.GetInstallation()
+	p = nil
+	p.GetInstallation()
+}
+
 func TestPackageEvent_GetOrg(tt *testing.T) {
 	p := &PackageEvent{}
 	p.GetOrg()
@@ -16699,6 +16727,13 @@ func TestRepositoryVulnerabilityAlertEvent_GetAlert(tt *testing.T) {
 	r.GetAlert()
 }
 
+func TestRepositoryVulnerabilityAlertEvent_GetInstallation(tt *testing.T) {
+	r := &RepositoryVulnerabilityAlertEvent{}
+	r.GetInstallation()
+	r = nil
+	r.GetInstallation()
+}
+
 func TestRepositoryVulnerabilityAlertEvent_GetRepository(tt *testing.T) {
 	r := &RepositoryVulnerabilityAlertEvent{}
 	r.GetRepository()
@@ -17457,6 +17492,13 @@ func TestStarEvent_GetAction(tt *testing.T) {
 	s.GetAction()
 }
 
+func TestStarEvent_GetInstallation(tt *testing.T) {
+	s := &StarEvent{}
+	s.GetInstallation()
+	s = nil
+	s.GetInstallation()
+}
+
 func TestStarEvent_GetOrg(tt *testing.T) {
 	s := &StarEvent{}
 	s.GetOrg()
@@ -19752,6 +19794,13 @@ func TestUserEvent_GetEnterprise(tt *testing.T) {
 	u.GetEnterprise()
 }
 
+func TestUserEvent_GetInstallation(tt *testing.T) {
+	u := &UserEvent{}
+	u.GetInstallation()
+	u = nil
+	u.GetInstallation()
+}
+
 func TestUserEvent_GetSender(tt *testing.T) {
 	u := &UserEvent{}
 	u.GetSender()
@@ -20483,6 +20532,13 @@ func TestWorkflowBill_GetTotalMS(tt *testing.T) {
 	w.GetTotalMS()
 }
 
+func TestWorkflowDispatchEvent_GetInstallation(tt *testing.T) {
+	w := &WorkflowDispatchEvent{}
+	w.GetInstallation()
+	w = nil
+	w.GetInstallation()
+}
+
 func TestWorkflowDispatchEvent_GetOrg(tt *testing.T) {
 	w := &WorkflowDispatchEvent{}
 	w.GetOrg()
@@ -20685,6 +20741,13 @@ func TestWorkflowJobEvent_GetAction(tt *testing.T) {
 	w.GetAction()
 }
 
+func TestWorkflowJobEvent_GetInstallation(tt *testing.T) {
+	w := &WorkflowJobEvent{}
+	w.GetInstallation()
+	w = nil
+	w.GetInstallation()
+}
+
 func TestWorkflowJobEvent_GetOrg(tt *testing.T) {
 	w := &WorkflowJobEvent{}
 	w.GetOrg()
@@ -20733,6 +20796,26 @@ func TestWorkflowRun_GetCancelURL(tt *testing.T) {
 	w.GetCancelURL()
 }
 
+func TestWorkflowRun_GetCheckSuiteID(tt *testing.T) {
+	var zeroValue int64
+	w := &WorkflowRun{CheckSuiteID: &zeroValue}
+	w.GetCheckSuiteID()
+	w = &WorkflowRun{}
+	w.GetCheckSuiteID()
+	w = nil
+	w.GetCheckSuiteID()
+}
+
+func TestWorkflowRun_GetCheckSuiteNodeID(tt *testing.T) {
+	var zeroValue string
+	w := &WorkflowRun{CheckSuiteNodeID: &zeroValue}
+	w.GetCheckSuiteNodeID()
+	w = &WorkflowRun{}
+	w.GetCheckSuiteNodeID()
+	w = nil
+	w.GetCheckSuiteNodeID()
+}
+
 func TestWorkflowRun_GetCheckSuiteURL(tt *testing.T) {
 	var zeroValue string
 	w := &WorkflowRun{CheckSuiteURL: &zeroValue}
@@ -20995,6 +21078,13 @@ func TestWorkflowRunEvent_GetAction(tt *testing.T) {
 	w.GetAction()
 }
 
+func TestWorkflowRunEvent_GetInstallation(tt *testing.T) {
+	w := &WorkflowRunEvent{}
+	w.GetInstallation()
+	w = nil
+	w.GetInstallation()
+}
+
 func TestWorkflowRunEvent_GetOrg(tt *testing.T) {
 	w := &WorkflowRunEvent{}
 	w.GetOrg()