Skip to content

Refactor logs download orchestration to reduce pkg/cli largefunc backlog#46125

Merged
pelikhan merged 6 commits into
mainfrom
copilot/lint-monster-function-length-refactor
Jul 17, 2026
Merged

Refactor logs download orchestration to reduce pkg/cli largefunc backlog#46125
pelikhan merged 6 commits into
mainfrom
copilot/lint-monster-function-length-refactor

Conversation

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This issue tracks function-length reduction across pkg/cli and pkg/workflow with behavior-preserving refactors. This change takes a small slice of the pkg/cli logs pipeline by splitting DownloadWorkflowLogs into focused orchestration helpers.

  • What changed

    • Moved the logs download orchestration out of the monolithic DownloadWorkflowLogs body into a dedicated helper file: pkg/cli/logs_orchestrator_download.go
    • Kept DownloadWorkflowLogs as the public entrypoint, but reduced it to high-level flow control:
      • prepare runtime/config
      • collect processed runs
      • handle empty results
      • apply output limits / continuation
      • render output
  • Helper extraction

    • Isolated setup concerns:
      • artifact-set validation / filter resolution
      • logs directory preparation
      • optional cleanup for --after
      • timeout context construction
    • Isolated iterative collection concerns:
      • batch-size calculation
      • pagination / empty-batch handling
      • rate-limit wait handling
      • chunked artifact download + processed-run accumulation
    • Isolated result-finalization concerns:
      • empty-result JSON/stderr handling
      • count limiting
  • Behavior preserved

    • Existing flags, continuation behavior, timeout semantics, filtering, parsing, and output rendering stay on the same code paths
    • No public interface changes; the refactor is internal to the logs orchestration layer
  • Targeted unit coverage

    • Added unit coverage for extracted helper behavior around:
      • dynamic batch sizing
      • empty batch pagination decisions
  • Example

    func DownloadWorkflowLogs(ctx context.Context, opts LogsDownloadOptions) error {
    	runtime, err := prepareLogsDownload(ctx, opts)
    	if err != nil {
    		return err
    	}
    	defer cancelLogsDownload(runtime.timeoutCancel)
    
    	processedRuns, timeoutReached, countLimitReached, err := collectProcessedWorkflowRuns(runtime, opts)
    	if err != nil {
    		return err
    	}
    
    	// ... finalize empty results, continuation, and rendering
    }

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor long functions identified by lint-monster Refactor logs download orchestration to reduce pkg/cli largefunc backlog Jul 17, 2026
Copilot AI requested a review from pelikhan July 17, 2026 05:14
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Great work on this refactor! 🎉 The decomposition of DownloadWorkflowLogs into focused orchestration helpers is clean and well-scoped — the helper extraction for setup, iterative collection, and result finalization reads naturally and keeps the public interface stable.

The PR includes targeted unit coverage for the extracted batch-sizing and empty-batch pagination logic, and the description clearly explains what changed and why. This looks ready for review!

Generated by ✅ Contribution Check · 87.5 AIC · ⌖ 15.7 AIC · ⊞ 6.2K ·

@pelikhan
pelikhan marked this pull request as ready for review July 17, 2026 07:01
Copilot AI review requested due to automatic review settings July 17, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors workflow-log download orchestration into focused internal helpers while preserving the public entry point.

Changes:

  • Extracts setup, collection, pagination, parsing, and finalization helpers.
  • Adds unit tests for batch sizing and empty-batch pagination.
  • Simplifies DownloadWorkflowLogs.
Show a summary per file
File Description
pkg/cli/logs_orchestrator.go Retains high-level orchestration entry point.
pkg/cli/logs_orchestrator_download.go Adds extracted download pipeline helpers.
pkg/cli/logs_orchestrator_unit_test.go Tests extracted pagination and batch-size logic.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread pkg/cli/logs_orchestrator_download.go
@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk medium
Score 30/100 (impact:12, urgency:6, quality:12)
Action defer

Rationale: DRAFT — pkg/cli log download orchestration refactor for largefunc backlog. No CI yet. Low urgency; defer until undrafted.

Generated by 🔧 PR Triage Agent · 166.4 AIC · ⌖ 6.15 AIC · ⊞ 5.6K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review feedback, investigate the failed checks listed below, and rerun checks once the branch is up to date.

Unresolved review threads:

Failed checks:

Generated by PR Sous Chef: https://github.com/github/gh-aw/actions/runs/29563491899

Generated by 👨‍🍳 PR Sous Chef · 7.53 AIC · ⌖ 9 AIC · ⊞ 6K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 17, 2026 07:49
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address the unresolved review feedback, investigate the failed checks listed below, and rerun checks once the branch is up to date.

Unresolved review thre...

Addressed in 08dcad2.

  • Resolved the open review feedback on timeout handling in collectProcessedWorkflowRuns.
  • Investigated failed check agent (run 29561792838, job 87825991546): failure was [ERROR] No log sources found. Run awf with a command first to generate logs.
  • Branch is now up to date with the fix.

I can’t trigger a fresh CI run from this cloud-agent push path; a maintainer re-trigger is needed (close/reopen PR, workflow_dispatch, or maintainer push).

Copilot AI requested a review from gh-aw-bot July 17, 2026 08:12
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, confirm the remaining open review thread is fully addressed, and either resolve it with a clear follow-up or push the needed fix. Then rerun checks once the branch is up to date so maintainers can quickly verify readiness.

Generated by 👨‍🍳 PR Sous Chef · 11.9 AIC · ⌖ 6.58 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, confirm the remaining open review thread is fully addressed, and either resolve it with a clear follow-up or push the needed fix. Then rerun checks once th...

Confirmed: there are no remaining open review threads on this PR; the prior thread is resolved and already covered by 08dcad2, so no additional code fix was needed.

I re-triaged checks and inspected run/job logs:

  • Latest PR-head runs on 08dcad2 are action_required and did not start jobs (0 jobs listed).
  • Last concrete failing job remains Smoke CI run 29561792838 / job 87825991546 with [ERROR] No log sources found. Run awf with a command first to generate logs.

I can’t re-run checks from this cloud-agent push path; a maintainer needs to re-trigger CI (close/reopen PR, workflow_dispatch, or maintainer push) for readiness verification on current head.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, rerun checks once the branch is up to date.

Generated by PR Sous Chef: https://github.com/github/gh-aw/actions/runs/29569653113

Generated by 👨‍🍳 PR Sous Chef · 5.53 AIC · ⌖ 5.1 AIC · ⊞ 6K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, rerun checks once the branch is up to date.

Generated by PR Sous Chef: https://github.com/github/gh-aw/actions/runs/29569653113...

I ran the pr-finisher workflow for this PR.

  • Reviews: no unresolved in-scope review threads remain (the Copilot reviewer thread is resolved).
  • Local checks: make fmt, make lint, make test-unit, make test, and make recompile all passed on current head (a5f572e).
  • CI triage: latest PR-head runs are action_required with 0 jobs started, so there was nothing runnable to rerun from this agent path.
  • Prior failing check was inspected at log level (run 29561792838, job 87825991546): failure was [ERROR] No log sources found. Run awf with a command first to generate logs.

From this cloud-agent environment I can’t trigger fresh CI runs; a maintainer needs to re-trigger checks (close/reopen PR, workflow_dispatch, or maintainer push) to verify green status on the latest head.

@pelikhan
pelikhan merged commit da9762a into main Jul 17, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/lint-monster-function-length-refactor branch July 17, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] lint-monster: function-length refactoring backlog (724 findings)

4 participants