8000 Add function to delete a workflow run by ID by x4b1 · Pull Request #2207 · google/go-github · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add function to delete a workflow run by ID #2207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maint 8000 ainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions github/actions_workflow_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo str
return parsedURL, newResponse(resp), err
}

// DeleteWorkflowRun deletes a workflow run by ID.
//
// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)

req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}

return s.client.Do(ctx, req, nil)
}

// DeleteWorkflowRunLogs deletes all logs for a workflow run.
//
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-workflow-run-logs
Expand Down
26 changes: 26 additions & 0 deletions github/actions_workflow_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,32 @@ func TestActionService_ListRepositoryWorkflowRuns(t *testing.T) {
})
}

func TestActionService_DeleteWorkflowRun(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/actions/runs/399444496", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")

w.WriteHeader(http.StatusNoContent)
})

ctx := context.Background()
if _, err := client.Actions.DeleteWorkflowRun(ctx, "o", "r", 399444496); err != nil {
t.Errorf("DeleteWorkflowRun returned error: %v", err)
}

const methodName = "DeleteWorkflowRun"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Actions.DeleteWorkflowRun(ctx, "\n", "\n", 399444496)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Actions.DeleteWorkflowRun(ctx, "o", "r", 399444496)
})
}

func TestActionService_DeleteWorkflowRunLogs(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down
0