Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers 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

require a store for buffering #342

Merged
merged 1 commit into from
May 13, 2024
Merged
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
12 changes: 9 additions & 3 deletions modules/github-bots/sdk/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (c GitHubClient) GetWorkflowRunLogs(ctx context.Context, wre github.Workflo
}

// FetchWorkflowRunLogs returns a Reader for the logs of the given WorkflowRun
func (c GitHubClient) FetchWorkflowRunLogs(ctx context.Context, wr *github.WorkflowRun) (io.ReaderAt, error) {
func (c GitHubClient) FetchWorkflowRunLogs(ctx context.Context, wr *github.WorkflowRun, store httpreaderat.Store) (*zip.Reader, error) {
url, ghresp, err := c.inner.Actions.GetWorkflowRunLogs(ctx, *wr.Repository.Owner.Login, *wr.Repository.Name, *wr.ID, 3)
if err != nil {
return nil, fmt.Errorf("failed to initiate log retrieval: %w", err)
Expand All @@ -192,12 +192,18 @@ func (c GitHubClient) FetchWorkflowRunLogs(ctx context.Context, wr *github.Workf
return nil, err
}

htdrd, err := httpreaderat.New(nil, req, nil)
htdrd, err := httpreaderat.New(nil, req, store)
if err != nil {
return nil, err
}

return bufra.NewBufReaderAt(htdrd, c.bufSize), nil
bhtrdr := bufra.NewBufReaderAt(htdrd, c.bufSize)

zr, err := zip.NewReader(bhtrdr, htdrd.Size())
if err != nil {
return nil, fmt.Errorf("failed to create zip reader: %w", err)
}
return zr, nil
}

func (c GitHubClient) GetWorkloadRunPullRequestNumber(ctx context.Context, wre github.WorkflowRunEvent) (int, error) {
Expand Down
Loading