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

fix(engine): resync vcs status v1 #6843

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
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
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