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

feat:add re-run #281

Merged
merged 1 commit into from
Aug 24, 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
18 changes: 17 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
log.Errorf("process pull request event: %v", err)
}
}()
case *github.CheckRunEvent:
go func() {

Check warning on line 80 in server.go

View check run for this annotation

qiniu-x / golangci-lint

server.go#L80

Function `ServeHTTP$2->processCheckRunRequestEvent` should pass the context parameter (contextcheck)
if err := s.processCheckRunRequestEvent(log, event); err != nil {
log.Errorf("process check run request event: %v", err)
}
}()
default:
log.Debugf("skipping event type %s\n", github.WebHookType(r))
}
Expand All @@ -89,8 +95,18 @@

return s.handle(log, context.Background(), event)
}

func (s *Server) processCheckRunRequestEvent(log *xlog.Logger, event *github.CheckRunEvent) error {
if event.GetAction() != "rerequested" {
log.Debugf("skipping action %s\n", event.GetAction())
return nil
}
var pevent = github.PullRequestEvent{}
pevent.Repo = event.GetRepo()
pevent.PullRequest = event.GetCheckRun().PullRequests[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PullRequests 什么情况下会多个?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A分支,同一个commit 向B,C 分支提交PR,创建的check run,就会是同一个, 这时候 这个checkrun 获取的到的pullrequests 就会是多个。 checkrun的创建需要一个必填参数head-sha :the SHA of the commit, 这两次的创建的check run head-sha 会是相同的
https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run

Uploading image.png…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那应该是能精确判断,本次重试是哪个PR吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是关联多个PR的话 是没法确定重试的是那个PR, 多个PR下的checkrun其实就是同一个。

pevent.Installation = event.GetInstallation()
return s.handle(log, context.Background(), &pevent)
}
func (s *Server) handle(log *xlog.Logger, ctx context.Context, event *github.PullRequestEvent) error {

Check warning on line 109 in server.go

View check run for this annotation

qiniu-x / golangci-lint

server.go#L109

function-length: maximum number of lines per function exceeded; max 75 but got 100 (revive)
var (
num = event.GetPullRequest().GetNumber()
org = event.GetRepo().GetOwner().GetLogin()
Expand Down
Loading