From c5b7b72431f2adf2cf6e5e8b9939686a3a7e2ed9 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Mon, 10 Feb 2020 20:59:23 +0700 Subject: [PATCH 01/12] Implement support for actions workflow jobs --- github/actions_workflow_jobs.go | 110 +++++++++++++++++++++++++++ github/actions_workflow_jobs_test.go | 91 ++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 github/actions_workflow_jobs.go create mode 100644 github/actions_workflow_jobs_test.go diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go new file mode 100644 index 00000000000..4644b7d1899 --- /dev/null +++ b/github/actions_workflow_jobs.go @@ -0,0 +1,110 @@ +// Copyright 2020 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// Step represents a single task from a sequence of tasks of a job. +type Step struct { + Name string `json:"name"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + Number int64 `json:"number"` + StartedAt Timestamp `json:"started_at"` + CompletedAt Timestamp `json:"completed_at"` +} + +// Job represents a repository action workflow job. +type Job struct { + ID int64 `json:"id"` + RunID int64 `json:"run_id"` + RunURL string `json:"run_url"` + NodeID string `json:"node_id"` + HeadSHA string `json:"head_sha"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + StartedAt Timestamp `json:"started_at"` + CompletedAt Timestamp `json:"completed_at"` + Name string `json:"name"` + Steps []*Step `json:"steps"` + CheckRunURL string `json:"check_run_url"` +} + +// Jobs represents a slice of repository action workflow job. +type Jobs struct { + TotalCount int `json:"total_count"` + Jobs []*Job `json:"jobs"` +} + +// ListWorkflowJobs lists all jobs for a workflow run. +// +// GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-jobs-for-a-workflow-run +func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*Jobs, *Response, error) { + u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + jobs := new(Jobs) + resp, err := s.client.Do(ctx, req, &jobs) + if err != nil { + return nil, resp, err + } + + return jobs, resp, nil +} + +// GetWorkflowJobByID gets a specific job in a workflow run by ID. +// +// GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-jobs-for-a-workflow-run +func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*Job, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + job := new(Job) + resp, err := s.client.Do(ctx, req, job) + if err != nil { + return nil, resp, err + } + + return job, resp, nil +} + +// ListWorkflowJobLogs gets a redirect URL to a download a plain text file of logs for a workflow job. +// +// GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-workflow-job-logs +func (s *ActionsService) ListWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64) (string, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return "", nil, err + } + + var logFileURL string + resp, err := s.client.Do(ctx, req, &logFileURL) + + if err != nil { + return "", resp, err + } + + return logFileURL, resp, nil +} diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go new file mode 100644 index 00000000000..8d9f9232487 --- /dev/null +++ b/github/actions_workflow_jobs_test.go @@ -0,0 +1,91 @@ +// Copyright 2020 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" + "net/http" + "reflect" + "testing" + "time" +) + +func TestActionsService_ListWorkflows(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/actions/workflows", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"per_page": "2", "page": "2"}) + fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":72845,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + }) + + opts := &ListOptions{Page: 2, PerPage: 2} + workflows, _, err := client.Actions.ListWorkflows(context.Background(), "o", "r", opts) + if err != nil { + t.Errorf("Actions.ListWorkflows returned error: %v", err) + } + + want := &Workflows{ + TotalCount: 4, + Workflows: []*Workflow{ + {ID: 72844, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + {ID: 72845, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + }, + } + if !reflect.DeepEqual(workflows, want) { + t.Errorf("Actions.ListWorkflows returned %+v, want %+v", workflows, want) + } +} + +func TestActionsService_GetWorkflowByID(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/actions/workflows/72844", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + }) + + workflow, _, err := client.Actions.GetWorkflowByID(context.Background(), "o", "r", 72844) + if err != nil { + t.Errorf("Actions.GetWorkflowByID returned error: %v", err) + } + + want := &Workflow{ + ID: 72844, + CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, + } + if !reflect.DeepEqual(workflow, want) { + t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) + } +} + +func TestActionsService_GetWorkflowByFileName(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/actions/workflows/main.yml", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + }) + + workflow, _, err := client.Actions.GetWorkflowByFileName(context.Background(), "o", "r", "main.yml") + if err != nil { + t.Errorf("Actions.GetWorkflowByFileName returned error: %v", err) + } + + want := &Workflow{ + ID: 72844, + CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, + UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, + } + if !reflect.DeepEqual(workflow, want) { + t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) + } +} From cae90e1a3306a10f5a193f6d50512a0497c5b431 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Mon, 10 Feb 2020 21:11:33 +0700 Subject: [PATCH 02/12] Fix test for actions_workflow_jobs --- github/actions_workflow_jobs_test.go | 64 +++++++++++++--------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 8d9f9232487..fb95a891f86 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -14,78 +14,74 @@ import ( "time" ) -func TestActionsService_ListWorkflows(t *testing.T) { +func TestActionsService_ListWorkflowJobs(t *testing.T) { client, mux, _, teardown := setup() defer teardown() - mux.HandleFunc("/repos/o/r/actions/workflows", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/runs/29679449/jobs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprint(w, `{"total_count":4,"workflows":[{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"id":72845,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) + fmt.Fprint(w, `{"total_count":4,"jobs":[{"id":399444496,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"},{"id":399444497,"run_id":29679449,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} - workflows, _, err := client.Actions.ListWorkflows(context.Background(), "o", "r", opts) + jobs, _, err := client.Actions.ListWorkflowJobs(context.Background(), "o", "r", 29679449, opts) if err != nil { - t.Errorf("Actions.ListWorkflows returned error: %v", err) + t.Errorf("Actions.ListWorkflowJobs returned error: %v", err) } - want := &Workflows{ + want := &Jobs{ TotalCount: 4, - Workflows: []*Workflow{ - {ID: 72844, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, - {ID: 72845, CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + Jobs: []*Job{ + {ID: 399444496, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + {ID: 399444497, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, }, } - if !reflect.DeepEqual(workflows, want) { - t.Errorf("Actions.ListWorkflows returned %+v, want %+v", workflows, want) + if !reflect.DeepEqual(jobs, want) { + t.Errorf("Actions.ListWorkflowJobs returned %+v, want %+v", jobs, want) } } -func TestActionsService_GetWorkflowByID(t *testing.T) { +func TestActionsService_GetWorkflowJobByID(t *testing.T) { client, mux, _, teardown := setup() defer teardown() - mux.HandleFunc("/repos/o/r/actions/workflows/72844", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/jobs/399444496", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `{"id":399444496,"started_at":"2019-01-02T15:04:05Z","completed_at":"2020-01-02T15:04:05Z"}`) }) - workflow, _, err := client.Actions.GetWorkflowByID(context.Background(), "o", "r", 72844) + job, _, err := client.Actions.GetWorkflowJobByID(context.Background(), "o", "r", 399444496) if err != nil { - t.Errorf("Actions.GetWorkflowByID returned error: %v", err) + t.Errorf("Actions.GetWorkflowJobByID returned error: %v", err) } - want := &Workflow{ - ID: 72844, - CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, + want := &Job{ + ID: 399444496, + StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, + CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, } - if !reflect.DeepEqual(workflow, want) { - t.Errorf("Actions.GetWorkflowByID returned %+v, want %+v", workflow, want) + if !reflect.DeepEqual(job, want) { + t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want) } } -func TestActionsService_GetWorkflowByFileName(t *testing.T) { +func TestActionsService_ListWorkflowJobLogs(t *testing.T) { client, mux, _, teardown := setup() defer teardown() - mux.HandleFunc("/repos/o/r/actions/workflows/main.yml", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/jobs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"id":72844,"created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`) + fmt.Fprint(w, `https://pipelines.actions.githubusercontent.com/ab1f3cCFPB34Nd6imvFxpGZH5hNlDp2wijMwl2gDoO0bcrrlJj/_apis/pipelines/1/jobs/19/signedlogcontent?urlExpires=2020-01-22T22%3A44%3A54.1389777Z&urlSigningMethod=HMACV1&urlSignature=2TUDfIg4fm36OJmfPy6km5QD5DLCOkBVzvhWZM8B%2BUY%3D`) }) - workflow, _, err := client.Actions.GetWorkflowByFileName(context.Background(), "o", "r", "main.yml") + logFileURL, _, err := client.Actions.ListWorkflowJobLogs(context.Background(), "o", "r", 399444496) if err != nil { - t.Errorf("Actions.GetWorkflowByFileName returned error: %v", err) + t.Errorf("Actions.ListWorkflowJobLogs returned error: %v", err) } - want := &Workflow{ - ID: 72844, - CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, - UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, - } - if !reflect.DeepEqual(workflow, want) { - t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", workflow, want) + want := "https://pipelines.actions.githubusercontent.com/ab1f3cCFPB34Nd6imvFxpGZH5hNlDp2wijMwl2gDoO0bcrrlJj/_apis/pipelines/1/jobs/19/signedlogcontent?urlExpires=2020-01-22T22%3A44%3A54.1389777Z&urlSigningMethod=HMACV1&urlSignature=2TUDfIg4fm36OJmfPy6km5QD5DLCOkBVzvhWZM8B%2BUY%3D" + if !reflect.DeepEqual(logFileURL, want) { + t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", logFileURL, want) } } From c59a6f8cca32683ce25b5565f617b5205781876e Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Tue, 11 Feb 2020 08:58:29 +0700 Subject: [PATCH 03/12] Update ListWorkflowJobLogs to GetWorkflowJobLogs --- github/actions_workflow_jobs.go | 43 +++++++++++++++---- github/actions_workflow_jobs_test.go | 63 ++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 15 deletions(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 4644b7d1899..e15a8bbf1d2 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -8,6 +8,8 @@ package github import ( "context" "fmt" + "net/http" + "net/url" ) // Step represents a single task from a sequence of tasks of a job. @@ -88,23 +90,48 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str return job, resp, nil } -// ListWorkflowJobLogs gets a redirect URL to a download a plain text file of logs for a workflow job. +// GetWorkflowJobLogs gets a redirect URL to a download a plain text file of logs for a workflow job. // // GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-workflow-job-logs -func (s *ActionsService) ListWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64) (string, *Response, error) { +func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID) - req, err := s.client.NewRequest("GET", u, nil) + resp, err := s.getWorkflowJobLogsFromURL(ctx, u, followRedirects) if err != nil { - return "", nil, err + return nil, nil, err } - var logFileURL string - resp, err := s.client.Do(ctx, req, &logFileURL) + if resp.StatusCode != http.StatusFound { + return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) + } + parsedURL, err := url.Parse(resp.Header.Get("Location")) + return parsedURL, newResponse(resp), err +} +func (s *ActionsService) getWorkflowJobLogsFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { + req, err := s.client.NewRequest("GET", u, nil) if err != nil { - return "", resp, err + return nil, err + } + + var resp *http.Response + // Use http.DefaultTransport if no custom Transport is configured + req = withContext(ctx, req) + if s.client.client.Transport == nil { + resp, err = http.DefaultTransport.RoundTrip(req) + } else { + resp, err = s.client.client.Transport.RoundTrip(req) + } + if err != nil { + return nil, err + } + resp.Body.Close() + + // If redirect response is returned, follow it + if followRedirects && resp.StatusCode == http.StatusMovedPermanently { + u = resp.Header.Get("Location") + resp, err = s.getWorkflowJobLogsFromURL(ctx, u, false) } + return resp, err - return logFileURL, resp, nil } diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index fb95a891f86..810511bb254 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -9,6 +9,7 @@ import ( "context" "fmt" "net/http" + "net/url" "reflect" "testing" "time" @@ -66,22 +67,70 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { } } -func TestActionsService_ListWorkflowJobLogs(t *testing.T) { +func TestActionsService_GetWorkflowJobLogsFile(t *testing.T) { client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/actions/jobs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `https://pipelines.actions.githubusercontent.com/ab1f3cCFPB34Nd6imvFxpGZH5hNlDp2wijMwl2gDoO0bcrrlJj/_apis/pipelines/1/jobs/19/signedlogcontent?urlExpires=2020-01-22T22%3A44%3A54.1389777Z&urlSigningMethod=HMACV1&urlSignature=2TUDfIg4fm36OJmfPy6km5QD5DLCOkBVzvhWZM8B%2BUY%3D`) + http.Redirect(w, r, "http://github.com/a", http.StatusFound) }) - logFileURL, _, err := client.Actions.ListWorkflowJobLogs(context.Background(), "o", "r", 399444496) + url, resp, err := client.Actions.GetWorkflowJobLogsFile(context.Background(), "o", "r", 399444496, true) if err != nil { - t.Errorf("Actions.ListWorkflowJobLogs returned error: %v", err) + t.Errorf("Actions.GetWorkflowJobLogsFile returned error: %v", err) + } + if resp.StatusCode != http.StatusFound { + t.Errorf("Actions.GetWorkflowJobLogsFile returned status: %d, want %d", resp.StatusCode, http.StatusFound) + } + want := "http://github.com/a" + if url.String() != want { + t.Errorf("Actions.GetWorkflowJobLogsFile returned %+v, want %+v", url.String(), want) + } +} + +func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_dontFollowRedirects(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/actions/jobs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + http.Redirect(w, r, "http://github.com/a", http.StatusMovedPermanently) + }) + + _, resp, _ := client.Actions.GetWorkflowJobLogsFile(context.Background(), "o", "r", 399444496, false) + if resp.StatusCode != http.StatusMovedPermanently { + t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) + } +} + +func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_followRedirects(t *testing.T) { + client, mux, serverURL, teardown := setup() + defer teardown() + + // Mock a redirect link, which leads to an archive link + mux.HandleFunc("/repos/o/r/actions/jobs/399444496/logs", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + redirectURL, _ := url.Parse(serverURL + baseURLPath + "/redirect") + http.Redirect(w, r, redirectURL.String(), http.StatusMovedPermanently) + }) + + mux.HandleFunc("/redirect", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + http.Redirect(w, r, "http://github.com/a", http.StatusFound) + }) + + url, resp, err := client.Actions.GetWorkflowJobLogs(context.Background(), "o", "r", 399444496, true) + if err != nil { + t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err) + } + + if resp.StatusCode != http.StatusFound { + t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) } - want := "https://pipelines.actions.githubusercontent.com/ab1f3cCFPB34Nd6imvFxpGZH5hNlDp2wijMwl2gDoO0bcrrlJj/_apis/pipelines/1/jobs/19/signedlogcontent?urlExpires=2020-01-22T22%3A44%3A54.1389777Z&urlSigningMethod=HMACV1&urlSignature=2TUDfIg4fm36OJmfPy6km5QD5DLCOkBVzvhWZM8B%2BUY%3D" - if !reflect.DeepEqual(logFileURL, want) { - t.Errorf("Actions.GetWorkflowByFileName returned %+v, want %+v", logFileURL, want) + want := "http://github.com/a" + if url.String() != want { + t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) } } From 22cf2d29817082b1142b0e8ef1ee89159b29ae90 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Tue, 11 Feb 2020 09:04:36 +0700 Subject: [PATCH 04/12] Update the function name to GetWorkflowJobLogs --- github/actions_workflow_jobs_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 810511bb254..9d164cd338b 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -67,7 +67,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { } } -func TestActionsService_GetWorkflowJobLogsFile(t *testing.T) { +func TestActionsService_GetWorkflowJobLogs(t *testing.T) { client, mux, _, teardown := setup() defer teardown() @@ -76,16 +76,16 @@ func TestActionsService_GetWorkflowJobLogsFile(t *testing.T) { http.Redirect(w, r, "http://github.com/a", http.StatusFound) }) - url, resp, err := client.Actions.GetWorkflowJobLogsFile(context.Background(), "o", "r", 399444496, true) + url, resp, err := client.Actions.GetWorkflowJobLogs(context.Background(), "o", "r", 399444496, true) if err != nil { - t.Errorf("Actions.GetWorkflowJobLogsFile returned error: %v", err) + t.Errorf("Actions.GetWorkflowJobLogs returned error: %v", err) } if resp.StatusCode != http.StatusFound { - t.Errorf("Actions.GetWorkflowJobLogsFile returned status: %d, want %d", resp.StatusCode, http.StatusFound) + t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusFound) } want := "http://github.com/a" if url.String() != want { - t.Errorf("Actions.GetWorkflowJobLogsFile returned %+v, want %+v", url.String(), want) + t.Errorf("Actions.GetWorkflowJobLogs returned %+v, want %+v", url.String(), want) } } @@ -98,7 +98,7 @@ func TestActionsService_GetWorkflowJobLogs_StatusMovedPermanently_dontFollowRedi http.Redirect(w, r, "http://github.com/a", http.StatusMovedPermanently) }) - _, resp, _ := client.Actions.GetWorkflowJobLogsFile(context.Background(), "o", "r", 399444496, false) + _, resp, _ := client.Actions.GetWorkflowJobLogs(context.Background(), "o", "r", 399444496, false) if resp.StatusCode != http.StatusMovedPermanently { t.Errorf("Actions.GetWorkflowJobLogs returned status: %d, want %d", resp.StatusCode, http.StatusMovedPermanently) } From ada4acfb6b8cdbe663975a22d355b3970a88f573 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Tue, 11 Feb 2020 12:10:05 +0700 Subject: [PATCH 05/12] Fix typo --- github/actions_workflow_jobs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index e15a8bbf1d2..752839bba43 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -90,7 +90,7 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str return job, resp, nil } -// GetWorkflowJobLogs gets a redirect URL to a download a plain text file of logs for a workflow job. +// GetWorkflowJobLogs gets a redirect URL to download a plain text file of logs for a workflow job. // // GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-workflow-job-logs func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) { From b695b0a883b57d047709add43c73db532be4d7d3 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Wed, 26 Feb 2020 20:51:35 +0700 Subject: [PATCH 06/12] Convert Task and Job struct's properties to pointer --- github/actions_workflow_jobs.go | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 752839bba43..3bed27e2401 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -14,35 +14,35 @@ import ( // Step represents a single task from a sequence of tasks of a job. type Step struct { - Name string `json:"name"` - Status string `json:"status"` - Conclusion string `json:"conclusion"` - Number int64 `json:"number"` - StartedAt Timestamp `json:"started_at"` - CompletedAt Timestamp `json:"completed_at"` + Name *string `json:"name"` + Status *string `json:"status"` + Conclusion *string `json:"conclusion"` + Number *int64 `json:"number"` + StartedAt *Timestamp `json:"started_at"` + CompletedAt *Timestamp `json:"completed_at"` } // Job represents a repository action workflow job. type Job struct { - ID int64 `json:"id"` - RunID int64 `json:"run_id"` - RunURL string `json:"run_url"` - NodeID string `json:"node_id"` - HeadSHA string `json:"head_sha"` - URL string `json:"url"` - HTMLURL string `json:"html_url"` - Status string `json:"status"` - Conclusion string `json:"conclusion"` - StartedAt Timestamp `json:"started_at"` - CompletedAt Timestamp `json:"completed_at"` - Name string `json:"name"` - Steps []*Step `json:"steps"` - CheckRunURL string `json:"check_run_url"` + ID *int64 `json:"id"` + RunID *int64 `json:"run_id"` + RunURL *string `json:"run_url"` + NodeID *string `json:"node_id"` + HeadSHA *string `json:"head_sha"` + URL *string `json:"url"` + HTMLURL *string `json:"html_url"` + Status *string `json:"status"` + Conclusion *string `json:"conclusion"` + StartedAt *Timestamp `json:"started_at"` + CompletedAt *Timestamp `json:"completed_at"` + Name *string `json:"name"` + Steps []*Step `json:"steps"` + CheckRunURL *string `json:"check_run_url"` } // Jobs represents a slice of repository action workflow job. type Jobs struct { - TotalCount int `json:"total_count"` + TotalCount *int `json:"total_count"` Jobs []*Job `json:"jobs"` } From db076ae3dc6b94d3e656e60160951343a94b5b1f Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Wed, 26 Feb 2020 20:53:39 +0700 Subject: [PATCH 07/12] Add tag omitempty for Task and Job struct's properties --- github/actions_workflow_jobs.go | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 3bed27e2401..beeabdf49db 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -14,35 +14,35 @@ import ( // Step represents a single task from a sequence of tasks of a job. type Step struct { - Name *string `json:"name"` - Status *string `json:"status"` - Conclusion *string `json:"conclusion"` - Number *int64 `json:"number"` - StartedAt *Timestamp `json:"started_at"` - CompletedAt *Timestamp `json:"completed_at"` + Name *string `json:"name,omitempty"` + Status *string `json:"status,omitempty"` + Conclusion *string `json:"conclusion,omitempty"` + Number *int64 `json:"number,omitempty"` + StartedAt *Timestamp `json:"started_at,omitempty"` + CompletedAt *Timestamp `json:"completed_at,omitempty"` } // Job represents a repository action workflow job. type Job struct { - ID *int64 `json:"id"` - RunID *int64 `json:"run_id"` - RunURL *string `json:"run_url"` - NodeID *string `json:"node_id"` - HeadSHA *string `json:"head_sha"` - URL *string `json:"url"` - HTMLURL *string `json:"html_url"` - Status *string `json:"status"` - Conclusion *string `json:"conclusion"` - StartedAt *Timestamp `json:"started_at"` - CompletedAt *Timestamp `json:"completed_at"` - Name *string `json:"name"` - Steps []*Step `json:"steps"` - CheckRunURL *string `json:"check_run_url"` + ID *int64 `json:"id,omitempty"` + RunID *int64 `json:"run_id,omitempty"` + RunURL *string `json:"run_url,omitempty"` + NodeID *string `json:"node_id,omitempty"` + HeadSHA *string `json:"head_sha,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + Status *string `json:"status,omitempty"` + Conclusion *string `json:"conclusion,omitempty"` + StartedAt *Timestamp `json:"started_at,omitempty"` + CompletedAt *Timestamp `json:"completed_at,omitempty"` + Name *string `json:"name,omitempty"` + Steps []*Step `json:"steps,omitempty"` + CheckRunURL *string `json:"check_run_url,omitempty"` } // Jobs represents a slice of repository action workflow job. type Jobs struct { - TotalCount *int `json:"total_count"` + TotalCount *int `json:"total_count,omitempty"` Jobs []*Job `json:"jobs"` } From 518cd9de194450121e7b8120c5f603c07a53b2e2 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Wed, 26 Feb 2020 20:54:32 +0700 Subject: [PATCH 08/12] ADd tag omitempty to Jobs struct properties --- github/actions_workflow_jobs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index beeabdf49db..333b53b16b8 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -43,7 +43,7 @@ type Job struct { // Jobs represents a slice of repository action workflow job. type Jobs struct { TotalCount *int `json:"total_count,omitempty"` - Jobs []*Job `json:"jobs"` + Jobs []*Job `json:"jobs,omitempty"` } // ListWorkflowJobs lists all jobs for a workflow run. From 1bae46c43dbbe92f6fe443da0d72012779f23bad Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Wed, 26 Feb 2020 20:59:57 +0700 Subject: [PATCH 09/12] Rename struct Task to TaskStep and Job to WorkflowJob --- github/actions_workflow_jobs.go | 44 ++++++++++++++-------------- github/actions_workflow_jobs_test.go | 4 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 333b53b16b8..d9adad7de4d 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -12,8 +12,8 @@ import ( "net/url" ) -// Step represents a single task from a sequence of tasks of a job. -type Step struct { +// TaskStep represents a single task step from a sequence of tasks of a job. +type TaskStep struct { Name *string `json:"name,omitempty"` Status *string `json:"status,omitempty"` Conclusion *string `json:"conclusion,omitempty"` @@ -22,28 +22,28 @@ type Step struct { CompletedAt *Timestamp `json:"completed_at,omitempty"` } -// Job represents a repository action workflow job. -type Job struct { - ID *int64 `json:"id,omitempty"` - RunID *int64 `json:"run_id,omitempty"` - RunURL *string `json:"run_url,omitempty"` - NodeID *string `json:"node_id,omitempty"` - HeadSHA *string `json:"head_sha,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - Status *string `json:"status,omitempty"` - Conclusion *string `json:"conclusion,omitempty"` - StartedAt *Timestamp `json:"started_at,omitempty"` - CompletedAt *Timestamp `json:"completed_at,omitempty"` - Name *string `json:"name,omitempty"` - Steps []*Step `json:"steps,omitempty"` - CheckRunURL *string `json:"check_run_url,omitempty"` +// WorkflowJob represents a repository action workflow job. +type WorkflowJob struct { + ID *int64 `json:"id,omitempty"` + RunID *int64 `json:"run_id,omitempty"` + RunURL *string `json:"run_url,omitempty"` + NodeID *string `json:"node_id,omitempty"` + HeadSHA *string `json:"head_sha,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + Status *string `json:"status,omitempty"` + Conclusion *string `json:"conclusion,omitempty"` + StartedAt *Timestamp `json:"started_at,omitempty"` + CompletedAt *Timestamp `json:"completed_at,omitempty"` + Name *string `json:"name,omitempty"` + Steps []*TaskStep `json:"steps,omitempty"` + CheckRunURL *string `json:"check_run_url,omitempty"` } // Jobs represents a slice of repository action workflow job. type Jobs struct { - TotalCount *int `json:"total_count,omitempty"` - Jobs []*Job `json:"jobs,omitempty"` + TotalCount *int `json:"total_count,omitempty"` + Jobs []*WorkflowJob `json:"jobs,omitempty"` } // ListWorkflowJobs lists all jobs for a workflow run. @@ -73,7 +73,7 @@ func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo strin // GetWorkflowJobByID gets a specific job in a workflow run by ID. // // GitHub API docs: https://developer.github.com/v3/actions/workflow_jobs/#list-jobs-for-a-workflow-run -func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*Job, *Response, error) { +func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID) req, err := s.client.NewRequest("GET", u, nil) @@ -81,7 +81,7 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str return nil, nil, err } - job := new(Job) + job := new(WorkflowJob) resp, err := s.client.Do(ctx, req, job) if err != nil { return nil, resp, err diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 9d164cd338b..9f672cdbf41 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -33,7 +33,7 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { want := &Jobs{ TotalCount: 4, - Jobs: []*Job{ + Jobs: []*WorkflowJob{ {ID: 399444496, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, {ID: 399444497, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, }, @@ -57,7 +57,7 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { t.Errorf("Actions.GetWorkflowJobByID returned error: %v", err) } - want := &Job{ + want := &WorkflowJob{ ID: 399444496, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, From 016438dea3817a8547a3d4dedcb2bc024331488d Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Thu, 27 Feb 2020 08:57:39 +0700 Subject: [PATCH 10/12] Running go generate command --- github/github-accessors.go | 160 +++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 212e334b460..26ae2ba31f9 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4972,6 +4972,14 @@ func (i *IssueStats) GetTotalIssues() int { return *i.TotalIssues } +// GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. +func (j *Jobs) GetTotalCount() int { + if j == nil || j.TotalCount == nil { + return 0 + } + return *j.TotalCount +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (k *Key) GetCreatedAt() Timestamp { if k == nil || k.CreatedAt == nil { @@ -11916,6 +11924,54 @@ func (t *Tag) GetVerification() *SignatureVerification { return t.Verification } +// GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetCompletedAt() Timestamp { + if t == nil || t.CompletedAt == nil { + return Timestamp{} + } + return *t.CompletedAt +} + +// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetConclusion() string { + if t == nil || t.Conclusion == nil { + return "" + } + return *t.Conclusion +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetName() string { + if t == nil || t.Name == nil { + return "" + } + return *t.Name +} + +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetNumber() int64 { + if t == nil || t.Number == nil { + return 0 + } + return *t.Number +} + +// GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetStartedAt() Timestamp { + if t == nil || t.StartedAt == nil { + return Timestamp{} + } + return *t.StartedAt +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (t *TaskStep) GetStatus() string { + if t == nil || t.Status == nil { + return "" + } + return *t.Status +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (t *Team) GetDescription() string { if t == nil || t.Description == nil { @@ -13851,3 +13907,107 @@ func (w *WeeklyStats) GetWeek() Timestamp { } return *w.Week } + +// GetCheckRunURL returns the CheckRunURL field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetCheckRunURL() string { + if w == nil || w.CheckRunURL == nil { + return "" + } + return *w.CheckRunURL +} + +// GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetCompletedAt() Timestamp { + if w == nil || w.CompletedAt == nil { + return Timestamp{} + } + return *w.CompletedAt +} + +// GetConclusion returns the Conclusion field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetConclusion() string { + if w == nil || w.Conclusion == nil { + return "" + } + return *w.Conclusion +} + +// GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetHeadSHA() string { + if w == nil || w.HeadSHA == nil { + return "" + } + return *w.HeadSHA +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetHTMLURL() string { + if w == nil || w.HTMLURL == nil { + return "" + } + return *w.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetID() int64 { + if w == nil || w.ID == nil { + return 0 + } + return *w.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetName() string { + if w == nil || w.Name == nil { + return "" + } + return *w.Name +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetNodeID() string { + if w == nil || w.NodeID == nil { + return "" + } + return *w.NodeID +} + +// GetRunID returns the RunID field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetRunID() int64 { + if w == nil || w.RunID == nil { + return 0 + } + return *w.RunID +} + +// GetRunURL returns the RunURL field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetRunURL() string { + if w == nil || w.RunURL == nil { + return "" + } + return *w.RunURL +} + +// GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetStartedAt() Timestamp { + if w == nil || w.StartedAt == nil { + return Timestamp{} + } + return *w.StartedAt +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetStatus() string { + if w == nil || w.Status == nil { + return "" + } + return *w.Status +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetURL() string { + if w == nil || w.URL == nil { + return "" + } + return *w.URL +} From 00b8d439b0dacfd1c9fca565ddf446eb9e2db8a7 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 26 Feb 2020 21:16:35 -0500 Subject: [PATCH 11/12] Update github/actions_workflow_jobs_test.go --- github/actions_workflow_jobs_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 9f672cdbf41..8e23b2f9a6d 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -32,10 +32,10 @@ func TestActionsService_ListWorkflowJobs(t *testing.T) { } want := &Jobs{ - TotalCount: 4, + TotalCount: Int(4), Jobs: []*WorkflowJob{ - {ID: 399444496, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, - {ID: 399444497, RunID: 29679449, StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + {ID: Int64(399444496), RunID: Int64(29679449), StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, + {ID: Int64(399444497), RunID: Int64(29679449), StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}}, }, } if !reflect.DeepEqual(jobs, want) { From aefa9a01249644655419503294613e5614cf493d Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 26 Feb 2020 21:16:44 -0500 Subject: [PATCH 12/12] Update github/actions_workflow_jobs_test.go --- github/actions_workflow_jobs_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 8e23b2f9a6d..36cf7a82ea4 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -58,9 +58,9 @@ func TestActionsService_GetWorkflowJobByID(t *testing.T) { } want := &WorkflowJob{ - ID: 399444496, - StartedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, - CompletedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, + ID: Int64(399444496), + StartedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, + CompletedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}, } if !reflect.DeepEqual(job, want) { t.Errorf("Actions.GetWorkflowJobByID returned %+v, want %+v", job, want)