Skip to content

Commit 79d3112

Browse files
committed
feat: add workspace in order to copy all repos to runner
1 parent 57f0d3b commit 79d3112

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

config/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ type Linter struct {
139139
Repo string `json:"-"`
140140
// Number is the number of PR or MR.
141141
Number int `json:"-"`
142+
// Workspace is the workspace to store all git repositories related by the linter.
143+
Workspace string `json:"-"`
142144
// Enable is whether to enable this linter, if false, linter still run but not report.
143145
Enable *bool `json:"enable,omitempty"`
144146
// DockerAsRunner is the docker image to run the linter.
@@ -176,8 +178,8 @@ type Linter struct {
176178

177179
func (l Linter) String() string {
178180
return fmt.Sprintf(
179-
"Linter{Enable: %v, DockerAsRunner: %v, WorkDir: %v, Command: %v, Args: %v, ReportFormat: %v, ConfigPath: %v}",
180-
*l.Enable, l.DockerAsRunner, l.WorkDir, l.Command, l.Args, l.ReportFormat, l.ConfigPath)
181+
"Linter{Enable: %v, DockerAsRunner: %v, Workspace: %v, WorkDir: %v, Command: %v, Args: %v, ReportFormat: %v, ConfigPath: %v}",
182+
*l.Enable, l.DockerAsRunner, l.Workspace, l.WorkDir, l.Command, l.Args, l.ReportFormat, l.ConfigPath)
181183
}
182184

183185
var (

internal/runner/docker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ func (d *DockerRunner) Run(ctx context.Context, cfg *config.Linter) (io.ReadClos
148148

149149
// NOTE(Carl): do not know why mount volume does not work in DinD mode,
150150
// copy the code to container instead.
151-
log.Infof("copy code to container: src: %s, dst: %s", cfg.WorkDir, cfg.WorkDir)
152-
if err := d.copyToContainer(ctx, resp.ID, cfg.WorkDir, cfg.WorkDir); err != nil {
151+
log.Infof("copy code to container: src: %s, dst: %s", cfg.Workspace, cfg.Workspace)
152+
if err := d.copyToContainer(ctx, resp.ID, cfg.Workspace, cfg.Workspace); err != nil {
153153
return nil, fmt.Errorf("failed to copy code to container: %w", err)
154154
}
155155

internal/runner/kubernertes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (k *KubernetesRunner) Run(ctx context.Context, cfg *config.Linter) (io.Read
138138
}
139139

140140
// copy repo code to pod
141-
err = k.copyCodeToPod(ctx, cfg.WorkDir, namespace, podName, cfg.WorkDir)
141+
err = k.copyCodeToPod(ctx, cfg.Workspace, namespace, podName, cfg.Workspace)
142142
if err != nil {
143143
log.Errorf("failed to copy code to pod: %v", err)
144144
return nil, err

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ func (s *Server) handle(ctx context.Context, event *github.PullRequestEvent) err
399399
for name, fn := range linters.TotalPullRequestHandlers() {
400400
linterConfig := s.config.GetLinterConfig(org, repo, name)
401401
linterConfig.Number = num
402+
linterConfig.Workspace = workspace
402403
// skip linter if it is disabled
403404
if linterConfig.Enable != nil && !*linterConfig.Enable {
404405
continue

0 commit comments

Comments
 (0)