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(scm): skipped map to failure for step status + remove deploy #1097

Merged
merged 4 commits into from
Mar 29, 2024
Merged
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
19 changes: 11 additions & 8 deletions scm/github/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,14 @@
// depending on what the status of the build is
switch b.GetStatus() {
case constants.StatusRunning, constants.StatusPending:
//nolint:goconst // ignore making constant
state = "pending"
description = fmt.Sprintf("the build is %s", b.GetStatus())
case constants.StatusPendingApproval:
state = "pending"
description = "build needs approval from repo admin to run"
case constants.StatusSuccess:
//nolint:goconst // ignore making constant
state = "success"
description = "the build was successful"
case constants.StatusFailure:
Expand Down Expand Up @@ -402,6 +404,11 @@
"user": u.GetName(),
}).Tracef("setting commit status for %s/%s/%d @ %s", org, name, b.GetNumber(), b.GetCommit())

// no commit statuses on deployments
if strings.EqualFold(b.GetEvent(), constants.EventDeploy) {
return nil
}

// create GitHub OAuth client with user's token
client := c.newClientToken(*u.Token)

Expand All @@ -414,19 +421,15 @@
)

// set the state and description for the status context
// depending on what the status of the build is
// depending on what the status of the step is
switch s.GetStatus() {
case constants.StatusRunning, constants.StatusPending:
state = "pending"
description = fmt.Sprintf("the step is %s", s.GetStatus())
case constants.StatusPendingApproval:
case constants.StatusRunning, constants.StatusPending, constants.StatusPendingApproval:
state = "pending"
description = fmt.Sprintf("the step is %s", s.GetStatus())
case constants.StatusSuccess:
state = "success"
description = "the step was successful"
case constants.StatusFailure:
//nolint:goconst // ignore making constant
state = "failure"
description = "the step has failed"
case constants.StatusCanceled:
Expand All @@ -436,8 +439,8 @@
state = "failure"
description = "the step was killed"
case constants.StatusSkipped:
state = "success"
description = "step was skipped as no steps/stages found"
state = "failure"
description = "step was skipped or never ran"
default:
state = "error"
description = "there was an error"
Expand Down Expand Up @@ -521,7 +524,7 @@
// loop to capture *ALL* the repos
for {
// send API call to capture the user's repos
repos, resp, err := client.Repositories.List(ctx, "", opts)

Check failure on line 527 in scm/github/repo.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] scm/github/repo.go#L527

SA1019: client.Repositories.List is deprecated: Use RepositoriesService.ListByUser or RepositoriesService.ListByAuthenticatedUser instead. (staticcheck)
Raw output
scm/github/repo.go:527:23: SA1019: client.Repositories.List is deprecated: Use RepositoriesService.ListByUser or RepositoriesService.ListByAuthenticatedUser instead. (staticcheck)
		repos, resp, err := client.Repositories.List(ctx, "", opts)
		                    ^
if err != nil {
return nil, fmt.Errorf("unable to list user repos: %w", err)
}
Expand Down
Loading