Skip to content

Commit 8f10b7c

Browse files
committed
fix: correctly update pending and running commit status
Signed-off-by: ab-ghosh <abghosh@redhat.com>
1 parent 565420c commit 8f10b7c

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

pkg/pipelineascode/pipelineascode.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ func (p *PacRun) startPR(ctx context.Context, match matcher.Match) (*tektonv1.Pi
301301
return pr, fmt.Errorf("cannot use the API on the provider platform to create a in_progress status: %w", err)
302302
}
303303

304+
// Also update the parent status (without pipeline name) to reflect pipeline is now running.
305+
// This updates the initial "Pipelines as Code CI" status that was set when waiting for /ok-to-test.
306+
parentStatus := status
307+
parentStatus.OriginalPipelineRunName = ""
308+
if err := p.vcx.CreateStatus(ctx, p.event, parentStatus); err != nil {
309+
p.logger.Warnf("failed to update parent status: %v", err)
310+
}
311+
304312
// Patch pipelineRun with logURL annotation, skips for GitHub App as we patch logURL while patching CheckrunID
305313
if _, ok := pr.Annotations[keys.InstallationID]; !ok {
306314
patchAnnotations[keys.LogURL] = p.run.Clients.ConsoleUI().DetailURL(pr)

pkg/provider/gitlab/gitlab.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ func (v *Provider) CreateStatus(_ context.Context, event *info.Event, statusOpts
281281
statusOpts.Conclusion = "success"
282282
statusOpts.Title = "completed"
283283
case "pending":
284+
statusOpts.Conclusion = "pending"
285+
}
286+
// When the pipeline is actually running (in_progress), show it as running
287+
// not pending. Pending is only for waiting states like /ok-to-test approval.
288+
if statusOpts.Status == "in_progress" {
284289
statusOpts.Conclusion = "running"
285290
}
286291
if statusOpts.DetailsURL != "" {

pkg/reconciler/reconciler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ func (r *Reconciler) updatePipelineRunToInProgress(ctx context.Context, logger *
360360
return nil
361361
}
362362

363+
// Also update the parent status (without pipeline name) to reflect pipeline is running.
364+
// This updates the initial "Pipelines as Code CI" status that was set when waiting for /ok-to-test.
365+
parentStatus := status
366+
parentStatus.OriginalPipelineRunName = ""
367+
if err := detectedProvider.CreateStatus(ctx, event, parentStatus); err != nil {
368+
logger.Warnf("failed to update parent status: %v", err)
369+
}
370+
363371
logger.Info("updated in_progress status on provider platform for pipelineRun ", pr.GetName())
364372
return nil
365373
}

pkg/reconciler/status.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ func (r *Reconciler) postFinalStatus(ctx context.Context, logger *zap.SugaredLog
158158

159159
err = createStatusWithRetry(ctx, logger, vcx, event, status)
160160
logger.Infof("pipelinerun %s has a status of '%s'", pr.Name, status.Conclusion)
161+
162+
// Also update the parent status (without pipeline name) to reflect pipeline completion.
163+
// This updates the initial "Pipelines as Code CI" status that was set when waiting for /ok-to-test.
164+
parentStatus := status
165+
parentStatus.OriginalPipelineRunName = ""
166+
if err := vcx.CreateStatus(ctx, event, parentStatus); err != nil {
167+
logger.Warnf("failed to update parent status: %v", err)
168+
}
169+
161170
return pr, err
162171
}
163172

0 commit comments

Comments
 (0)