-
Notifications
You must be signed in to change notification settings - Fork 22
feat: gitlab integration #428
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
Conversation
✅ Deploy Preview for reviewbot-x canceled.
|
f51dbab
to
6fedd79
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #428 +/- ##
==========================================
- Coverage 30.13% 25.61% -4.53%
==========================================
Files 30 31 +1
Lines 3796 4467 +671
==========================================
Hits 1144 1144
- Misses 2515 3185 +670
- Partials 137 138 +1 ☔ View full report in Codecov by Sentry. |
49ecb83
to
4ae269d
Compare
dc22817
to
194c8c3
Compare
d313f1c
to
ebfda9b
Compare
26a954c
to
70ee7fe
Compare
[Git-flow] Hi @never112, There are some suggestions for your information: Rebase suggestions
Which seems insignificant, recommend to use For other If you have any questions about this comment, feel free to raise an issue here: |
return fmt.Sprintf("[**%s**]", linterName) | ||
} | ||
|
||
func (g *GitlabProvider) Report(ctx context.Context, a Agent, lintResults map[string][]LinterOutput) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
cognitive complexity 33 of func (*GitlabProvider).Report
is high (> 30) (gocognit)
num := a.Provider.GetCodeReviewInfo().Number | ||
orgRepo := fmt.Sprintf("%s/%s", org, repo) | ||
reportformat := ReportFormMatCheck(g.GitLabClient, a.LinterConfig.ReportType) | ||
switch reportformat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
missing cases in switch of type config.ReportType: config.GithubCheckRuns, config.GithubPRReview, config.GithubMixType (exhaustive)
|
||
func ListMergeRequestsFiles(ctx context.Context, gc *gitlab.Client, owner string, repo string, pid int, number int) ([]*gitlab.MergeRequestDiff, *gitlab.Response, error) { | ||
// For version compatibility,because verion below 10.8 not support ListMergeRequestDiffs | ||
files, response, err := gc.MergeRequests.GetMergeRequestChanges(pid, number, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
SA1019: gc.MergeRequests.GetMergeRequestChanges is deprecated: This endpoint has been replaced by MergeRequestsService.ListMergeRequestDiffs() (staticcheck)
return s.gitlabHandle(ctx, event) | ||
} | ||
|
||
func (s *Server) gitlabHandle(ctx context.Context, event *gitlab.MergeEvent) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
cognitive complexity 35 of func (*Server).gitlabHandle
is high (> 30) (gocognit)
log.Fatalf("Failed to create client: %v", err) | ||
} | ||
return git | ||
} | ||
|
||
func (s *Server) handle(ctx context.Context, event *github.PullRequestEvent) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
cognitive complexity 31 of func (*Server).handle
is high (> 30) (gocognit)
} else { | ||
log.Infof("no .gitmodules file in repo %s", repo) | ||
} | ||
for name, fn := range linters.TotalPullRequestHandlers() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
empty-lines: extra empty line at the start of a block (revive)
@@ -220,6 +231,10 @@ func (s *Server) pullImageWithRetry(ctx context.Context, image string, dockerRun | |||
} | |||
|
|||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
Non-inherited new context, use function like context.WithXXX
or r.Context
instead (contextcheck)
@@ -20,6 +20,7 @@ import ( | |||
"context" | |||
"errors" | |||
"fmt" | |||
"io/ioutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
eventGUID = eventGUID[len(eventGUID)-12:] | ||
} | ||
ctx := context.WithValue(context.Background(), lintersutil.EventGUIDKey, eventGUID) | ||
log := lintersutil.FromContext(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci-lint] reported by reviewbot🐮
Non-inherited new context, use function like context.WithXXX
or r.Context
instead (contextcheck)
func (o options) Validate() error { | ||
if o.accessToken == "" && o.appID == 0 { | ||
return errors.New("either access-token or github app information should be provided") | ||
if o.gitHubAccessToken == "" && o.appID == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewbot 应当允许只使用 gitlab ,这里就不合适了
@@ -220,6 +231,10 @@ func (s *Server) pullImageWithRetry(ctx context.Context, image string, dockerRun | |||
} | |||
|
|||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
if r.Header.Get("X-Gitlab-Event") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github 也需要包装下
@@ -63,6 +69,38 @@ func NewFileHunkChecker(commitFiles []*github.CommitFile) (*FileHunkChecker, err | |||
Hunks: hunks, | |||
}, nil | |||
} | |||
func NewGitLabCommitFileHunkChecker(commitFiles []*gitlab.MergeRequestDiff) (*FileHunkChecker, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件应该剥离 对github 和 gitlab的耦合
@@ -6,7 +6,8 @@ | |||
# 3. Conducting specific gray testing for a particular feature. | |||
|
|||
globalDefaultConfig: # global default settings, will be overridden by qbox org and repo specific settings if they exist | |||
githubReportType: "github_check_run" # github_pr_review, github_check_run, github_mix | |||
githubReportType: "github_check_run" # github_pr_review, github_check_run | |||
gitlabReportType: "gitlab_mr_comment_discussion" # gitlab_mr_comment, gitlab_mr_discussion,gitlab_mr_comment_discussion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码里应该要有最佳实践,通常这里不需要配置
无配置:>=10.8 版本 comments+discussion,<10.8版本使用comments,
有配置:>=10.8 版本 使用配置,<10.8版本使用comments.
全局无配置,repo无配置,->无配置
全局无配置,repo有配置 ,->repo配置
全局有配置,repo有配置,->repo配置
github/gitlab 统一使用 accesstokne的方式拉取代码 需要重新设计?
report: comment:



Fail:Folding
Fail: Unfolding
pass:
report:discussion

comments-table
