Skip to content

Commit

Permalink
fix: report status on skip (#476)
Browse files Browse the repository at this point in the history
* fix: report status on skip
  • Loading branch information
matt-fevold authored Aug 31, 2021
1 parent 417e15f commit 897c213
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ func CreateBuild(c *gin.Context) {
// skip the build if only the init or clone steps are found
skip := skipEmptyBuild(p)
if skip != "" {
// set build to successful status
input.SetStatus(constants.StatusSuccess)

// send API call to set the status on the commit
err = source.FromContext(c).Status(u, input, r.GetOrg(), r.GetName())
if err != nil {
// nolint: lll // ignore long line length due to error message
logrus.Errorf("unable to set commit status for %s/%d: %v", r.GetFullName(), input.GetNumber(), err)
}

c.JSON(http.StatusOK, skip)
return
}
Expand Down Expand Up @@ -852,6 +862,15 @@ func RestartBuild(c *gin.Context) {
// skip the build if only the init or clone steps are found
skip := skipEmptyBuild(p)
if skip != "" {
// set build to successful status
b.SetStatus(constants.StatusSuccess)

// send API call to set the status on the commit
err = source.FromContext(c).Status(u, b, r.GetOrg(), r.GetName())
if err != nil {
logrus.Errorf("unable to set commit status for %s/%d: %v", r.GetFullName(), b.GetNumber(), err)
}

c.JSON(http.StatusOK, skip)
return
}
Expand Down
9 changes: 9 additions & 0 deletions api/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ func PostWebhook(c *gin.Context) {
// skip the build if only the init or clone steps are found
skip := skipEmptyBuild(p)
if skip != "" {
// set build to successful status
b.SetStatus(constants.StatusSuccess)

// send API call to set the status on the commit
err = source.FromContext(c).Status(u, b, r.GetOrg(), r.GetName())
if err != nil {
logrus.Errorf("unable to set commit status for %s/%d: %v", r.GetFullName(), b.GetNumber(), err)
}

c.JSON(http.StatusOK, skip)
return
}
Expand Down

0 comments on commit 897c213

Please sign in to comment.