Skip to content

Commit

Permalink
fix(engine): resync vcs status v1 (#6843)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
yesnault authored Feb 16, 2024
1 parent 4b641a7 commit b0227ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 49 deletions.
4 changes: 2 additions & 2 deletions engine/api/workflow/workflow_run_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (e *VCSEventMessenger) SendVCSEvent(ctx context.Context, db *gorp.DbMap, st
}
e.commitsStatuses[ref] = statuses
}
expected := sdk.VCSCommitStatusDescription(proj.Key, wr.Workflow.Name, sdk.EventRunWorkflowNode{
expected := sdk.VCSCommitStatusContextV1(proj.Key, wr.Workflow.Name, sdk.EventRunWorkflowNode{
NodeName: nodeRun.WorkflowNodeName,
})
log.Info(ctx, "expected status description is %q", expected)
Expand Down Expand Up @@ -305,7 +305,7 @@ func (e *VCSEventMessenger) sendVCSEventStatus(ctx context.Context, db gorp.SqlE
}

buildStatus := sdk.VCSBuildStatus{
Title: fmt.Sprintf("%s-%s-%s", evt.ProjectKey, evt.WorkflowName, eventWNR.NodeName),
Title: sdk.VCSCommitStatusContextV1(evt.ProjectKey, evt.WorkflowName, eventWNR),
Description: eventWNR.NodeName + ": " + eventWNR.Status,
URLCDS: fmt.Sprintf("%s/project/%s/workflow/%s/run/%d", cdsUIURL, evt.ProjectKey, evt.WorkflowName, eventWNR.Number),
Context: fmt.Sprintf("%s-%s-%s", evt.ProjectKey, evt.WorkflowName, eventWNR.NodeName),
Expand Down
44 changes: 0 additions & 44 deletions engine/vcs/github/client_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,3 @@ func processGithubState(s Status) string {
return sdk.StatusDisabled
}
}

func processEventWorkflowNodeRun(event sdk.Event, cdsUIURL string, disabledStatusDetail bool) (statusData, error) {
data := statusData{}
var eventNR sdk.EventRunWorkflowNode
if err := sdk.JSONUnmarshal(event.Payload, &eventNR); err != nil {
return data, sdk.WrapError(err, "cannot unmarshal payload")
}
//We only manage status Success and Failure
if eventNR.Status == sdk.StatusChecking ||
eventNR.Status == sdk.StatusDisabled ||
eventNR.Status == sdk.StatusNeverBuilt ||
eventNR.Status == sdk.StatusSkipped ||
eventNR.Status == sdk.StatusUnknown ||
eventNR.Status == sdk.StatusWaiting {
return data, nil
}

switch eventNR.Status {
case sdk.StatusFail:
data.status = "error"
case sdk.StatusSuccess:
data.status = "success"
default:
data.status = "pending"
}
data.hash = eventNR.Hash
data.repoFullName = eventNR.RepositoryFullName

if !disabledStatusDetail {
data.urlPipeline = fmt.Sprintf("%s/project/%s/workflow/%s/run/%d",
cdsUIURL,
event.ProjectKey,
event.WorkflowName,
eventNR.Number,
)
} else {
//CDS can avoid sending github targer url in status, if it's disable
data.urlPipeline = ""
}

data.context = sdk.VCSCommitStatusDescription(event.ProjectKey, event.WorkflowName, eventNR)
data.desc = eventNR.NodeName + ": " + eventNR.Status
return data, nil
}
6 changes: 3 additions & 3 deletions sdk/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,14 @@ func GetDefaultBranch(branches []VCSBranch) VCSBranch {
return VCSBranch{}
}

// VCSCommitStatusDescription return a node formated status description
func VCSCommitStatusDescription(projKey, workflowName string, evt EventRunWorkflowNode) string {
// VCSCommitStatusContextV1 return a node formated status Context for workflow V1
func VCSCommitStatusContextV1(projKey, workflowName string, evt EventRunWorkflowNode) string {
key := fmt.Sprintf("%s-%s-%s",
projKey,
workflowName,
evt.NodeName,
)
return fmt.Sprintf("CDS/%s", key)
return fmt.Sprintf("%s", key)
}

type VCSBuildStatus struct {
Expand Down

0 comments on commit b0227ae

Please sign in to comment.