Skip to content
Merged
Show file tree
Hide file tree
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
52 changes: 35 additions & 17 deletions cmd/src/batch_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,29 +292,46 @@ func executeBatchSpec(ctx context.Context, ui ui.ExecUI, opts executeBatchSpecOp

// EXECUTION OF TASKS
coord := svc.NewCoordinator(executor.NewCoordinatorOpts{
Creator: workspaceCreator,
CacheDir: opts.flags.cacheDir,
Cache: executor.NewDiskCache(opts.flags.cacheDir),
ClearCache: opts.flags.clearCache,
SkipErrors: opts.flags.skipErrors,
CleanArchives: opts.flags.cleanArchives,
Parallelism: opts.flags.parallelism,
Timeout: opts.flags.timeout,
KeepLogs: opts.flags.keepLogs,
TempDir: opts.flags.tempDir,
ImportChangesets: true,
Creator: workspaceCreator,
CacheDir: opts.flags.cacheDir,
Cache: executor.NewDiskCache(opts.flags.cacheDir),
SkipErrors: opts.flags.skipErrors,
CleanArchives: opts.flags.cleanArchives,
Parallelism: opts.flags.parallelism,
Timeout: opts.flags.timeout,
KeepLogs: opts.flags.keepLogs,
TempDir: opts.flags.tempDir,
})

ui.CheckingCache()
tasks := svc.BuildTasks(ctx, batchSpec, workspaces)
uncachedTasks, cachedSpecs, err := coord.CheckCache(ctx, tasks)
if err != nil {
return err
var (
specs []*batcheslib.ChangesetSpec
uncachedTasks []*executor.Task
)
if opts.flags.clearCache {
coord.ClearCache(ctx, tasks)
uncachedTasks = tasks
} else {
uncachedTasks, specs, err = coord.CheckCache(ctx, tasks)
if err != nil {
return err
}
}
ui.CheckingCacheSuccess(len(cachedSpecs), len(uncachedTasks))
ui.CheckingCacheSuccess(len(specs), len(uncachedTasks))

taskExecUI := ui.ExecutingTasks(*verbose, opts.flags.parallelism)
freshSpecs, logFiles, err := coord.Execute(ctx, uncachedTasks, batchSpec, taskExecUI)
freshSpecs, logFiles, execErr := coord.Execute(ctx, uncachedTasks, batchSpec, taskExecUI)
// Add external changeset specs.
importedSpecs, importErr := svc.CreateImportChangesetSpecs(ctx, batchSpec)
var errs *multierror.Error
if execErr != nil {
err = multierror.Append(err, execErr)
}
if importErr != nil {
err = multierror.Append(err, importErr)
}
err = errs.ErrorOrNil()
if err != nil && !opts.flags.skipErrors {
Comment thread
mrnugget marked this conversation as resolved.
return err
}
Expand All @@ -335,7 +352,8 @@ func executeBatchSpec(ctx context.Context, ui ui.ExecUI, opts executeBatchSpecOp
ui.LogFilesKept(logFiles)
}

specs := append(cachedSpecs, freshSpecs...)
specs = append(specs, freshSpecs...)
specs = append(specs, importedSpecs...)

err = svc.ValidateChangesetSpecs(repos, specs)
if err != nil {
Expand Down
23 changes: 15 additions & 8 deletions cmd/src/batch_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,31 @@ func executeBatchSpecInWorkspaces(ctx context.Context, ui *ui.JSONLines, opts ex
Creator: workspaceCreator,
CacheDir: opts.flags.cacheDir,
Cache: &executor.JSONLinesCache{Writer: ui},
ClearCache: opts.flags.clearCache,
SkipErrors: opts.flags.skipErrors,
CleanArchives: opts.flags.cleanArchives,
Parallelism: opts.flags.parallelism,
Timeout: opts.flags.timeout,
KeepLogs: opts.flags.keepLogs,
TempDir: opts.flags.tempDir,
// Do not import changesets in `src batch exec`
ImportChangesets: false,
})

ui.CheckingCache()
tasks := svc.BuildTasks(ctx, batchSpec, repoWorkspaces)
uncachedTasks, cachedSpecs, err := coord.CheckCache(ctx, tasks)
if err != nil {
return err
var (
specs []*batcheslib.ChangesetSpec
uncachedTasks []*executor.Task
)
// TODO: We don't need to support clear cache here at all.
if opts.flags.clearCache {
coord.ClearCache(ctx, tasks)
uncachedTasks = tasks
} else {
uncachedTasks, specs, err = coord.CheckCache(ctx, tasks)
if err != nil {
return err
}
}
ui.CheckingCacheSuccess(len(cachedSpecs), len(uncachedTasks))
ui.CheckingCacheSuccess(len(specs), len(uncachedTasks))

taskExecUI := ui.ExecutingTasks(*verbose, opts.flags.parallelism)
freshSpecs, _, err := coord.Execute(ctx, uncachedTasks, batchSpec, taskExecUI)
Expand All @@ -185,7 +192,7 @@ func executeBatchSpecInWorkspaces(ctx context.Context, ui *ui.JSONLines, opts ex
}
}

specs := append(cachedSpecs, freshSpecs...)
specs = append(specs, freshSpecs...)

ids := make([]graphql.ChangesetSpecID, len(specs))

Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ require (
github.com/google/go-cmp v0.5.6
github.com/hashicorp/go-multierror v1.1.1
github.com/jig/teereadcloser v0.0.0-20181016160506-953720c48e05
github.com/json-iterator/go v1.1.11
github.com/json-iterator/go v1.1.12
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-isatty v0.0.14
github.com/neelance/parallel v0.0.0-20160708114440-4de9ce63d14c
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
github.com/sourcegraph/go-diff v0.6.1
github.com/sourcegraph/jsonx v0.0.0-20200629203448-1a936bd500cf
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211104160022-5499420c85c9
github.com/sourcegraph/sourcegraph/lib v0.0.0-20211109155204-31a95b8405e0
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
jaytaylor.com/html2text v0.0.0-20200412013138-3577fbdbcff7
)
Expand All @@ -35,21 +35,21 @@ require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/klauspost/compress v1.12.2 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.1.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/sys v0.0.0-20211109065445-02f5c0300f6e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Expand Down
Loading