Skip to content

Propagate cancellation context through workflow job detail/status GitHub API calls#46963

Merged
pelikhan merged 6 commits into
mainfrom
copilot/replace-run-gh-combined-with-context
Jul 21, 2026
Merged

Propagate cancellation context through workflow job detail/status GitHub API calls#46963
pelikhan merged 6 commits into
mainfrom
copilot/replace-run-gh-combined-with-context

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

fetchJobDetailsWithCounts previously used RunGHCombined, which binds to context.Background() and could not be cancelled on interrupt/deadline. This change threads caller context into job-detail/status fetch paths so long-running GitHub API calls can terminate promptly when the parent operation is cancelled.

  • Problem scope

    • Make job-detail fetches in audit/logs respect cancellation instead of running detached from caller context.
  • Core API change

    • fetchJobDetailsWithCounts now accepts ctx context.Context and uses workflow.RunGHCombinedContext(ctx, ...).
  • Context plumbing in audit path

    • Propagated ctx through:
      • collectAuditAnalysisResults
      • launchCoreAuditAnalyses
      • launchJobDetailsAnalysis
    • launchJobDetailsAnalysis now calls fetchJobDetailsWithCounts(ctx, ...).
  • Wrapper and downstream propagation

    • Updated wrappers to be context-aware:
      • fetchJobDetails(ctx, runID, verbose)
      • fetchJobStatuses(ctx, runID, verbose)
    • Threaded ctx through logs run processing where these wrappers are used (analyzeRunArtifacts / finalizeAndSaveRunSummary).
  • Compatibility updates

    • Adjusted affected tests/stubs to match new function signatures where context is now required.
func fetchJobDetailsWithCounts(ctx context.Context, runID int64, verbose bool) ([]JobInfoWithDuration, int, error) {
	output, err := workflow.RunGHCombinedContext(
		ctx,
		"Fetching job details...",
		"api",
		fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d/jobs", runID),
		"--jq", ".jobs[] | { ... }",
	)
	// ...
}

Copilot AI and others added 3 commits July 21, 2026 04:08
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fetchJobDetailsWithCounts to use context for cancellation Propagate cancellation context through workflow job detail/status GitHub API calls Jul 21, 2026
Copilot AI requested a review from pelikhan July 21, 2026 04:37
@pelikhan
pelikhan marked this pull request as ready for review July 21, 2026 04:42
Copilot AI review requested due to automatic review settings July 21, 2026 04:42
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

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

Propagates cancellation contexts through workflow job-detail and status API calls.

Changes:

  • Threads context through audit and log-analysis paths.
  • Updates wrappers and tests for context-aware signatures.
  • Regenerates an unrelated smoke workflow lock file.
Show a summary per file
File Description
pkg/cli/logs_run_processor.go Propagates context during run analysis.
pkg/cli/logs_orchestrator_filters.go Updates job-status call, but uses a detached context.
pkg/cli/logs_orchestrator_filters_test.go Updates status-fetch test stubs.
pkg/cli/logs_github_api.go Uses the context-aware GitHub CLI runner.
pkg/cli/logs_github_api_test.go Updates job-detail tests.
pkg/cli/audit.go Propagates audit context to job-detail analysis.
.github/workflows/smoke-call-workflow.lock.yml Expands unrelated workflow permissions and secret forwarding.

Review details

Tip

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

  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Medium


// Add failed jobs to error count.
if failedJobCount, err := fetchJobStatusesForProcessedRun(run.DatabaseID, verbose); err == nil {
if failedJobCount, err := fetchJobStatusesForProcessedRun(context.Background(), run.DatabaseID, verbose); err == nil {
Comment on lines +1114 to +1117
actions: read
contents: read
pull-requests: read
issues: write
pull-requests: write
Copilot AI and others added 2 commits July 21, 2026 04:53
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…tx parameter

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Merge conflicts resolved in pkg/cli/audit.go. The two conflicting function definitions (launchCoreAuditAnalyses and launchJobDetailsAnalysis) now combine the doc comments added in main with the ctx context.Context parameter from this branch. All other files from main auto-merged cleanly. The code compiles and pre-PR validation passes.

@pelikhan
pelikhan merged commit f57e9ce into main Jul 21, 2026
23 checks passed
@pelikhan
pelikhan deleted the copilot/replace-run-gh-combined-with-context branch July 21, 2026 05:12
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Replace RunGHCombined with RunGHCombinedContext in fetchJobDetailsWithCounts

3 participants