Skip to content

Commit

Permalink
Add referenced_workflows field to WorkflowRun
Browse files Browse the repository at this point in the history
  • Loading branch information
schaffe-cb committed Oct 25, 2023
1 parent 66ed84d commit 435c2bd
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 34 deletions.
73 changes: 40 additions & 33 deletions github/actions_workflow_runs.go
Expand Up @@ -14,39 +14,40 @@ 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"`
RunAttempt *int `json:"run_attempt,omitempty"`
Event *string `json:"event,omitempty"`
DisplayTitle *string `json:"display_title,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"`
RunStartedAt *Timestamp `json:"run_started_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"`
PreviousAttemptURL *string `json:"previous_attempt_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"`
Actor *User `json:"actor,omitempty"`
TriggeringActor *User `json:"triggering_actor,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"`
RunAttempt *int `json:"run_attempt,omitempty"`
Event *string `json:"event,omitempty"`
DisplayTitle *string `json:"display_title,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"`
RunStartedAt *Timestamp `json:"run_started_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"`
PreviousAttemptURL *string `json:"previous_attempt_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"`
Actor *User `json:"actor,omitempty"`
TriggeringActor *User `json:"triggering_actor,omitempty"`
ReferencedWorkflows []*ReferencedWorkflow `json:"referenced_workflows,omitempty"`
}

// WorkflowRuns represents a slice of repository action workflow run.
Expand Down Expand Up @@ -104,6 +105,12 @@ type PendingDeploymentsRequest struct {
Comment string `json:"comment"`
}

type ReferencedWorkflow struct {
Path *string `json:"path,omitempty"`
SHA *string `json:"sha,omitempty"`
Ref *string `json:"ref,omitempty"`
}

func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
u, err := addOptions(endpoint, opts)
if err != nil {
Expand Down
16 changes: 15 additions & 1 deletion github/actions_workflow_runs_test.go
Expand Up @@ -761,6 +761,13 @@ func TestWorkflowRun_Marshal(t *testing.T) {
SuspendedAt: &Timestamp{referenceTime},
URL: String("u2"),
},
ReferencedWorkflows: []*ReferencedWorkflow{
{
Path: String("rwfp"),
SHA: String("rwfsha"),
Ref: String("rwfref"),
},
},
}

want := `{
Expand Down Expand Up @@ -881,7 +888,14 @@ func TestWorkflowRun_Marshal(t *testing.T) {
"created_at": ` + referenceTimeStr + `,
"suspended_at": ` + referenceTimeStr + `,
"url": "u2"
}
},
"referenced_workflows": [
{
"path": "rwfp",
"sha": "rwfsha",
"ref": "rwfref"
}
]
}`

testJSONMarshal(t, u, want)
Expand Down
24 changes: 24 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 435c2bd

Please sign in to comment.