Skip to content

Commit

Permalink
Go mod tidy after each go mod edit
Browse files Browse the repository at this point in the history
This prevents errors as it resolves non semantic versions such as latest
to semantic ones
  • Loading branch information
mstoykov committed Aug 25, 2021
1 parent 9dea6e5 commit f080854
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
if err != nil {
return nil, err
}
// tidy the module to ensure go.mod will not have versions such as `latest`
tidyCmd := env.newCommand("go", "mod", "tidy")
if err := env.runCommand(ctx, tidyCmd, b.TimeoutGet); err != nil {
return nil, err
}
replace := fmt.Sprintf("%s=%s", k6ModulePath, b.K6Repo)
if b.K6Version != "" {
replace = fmt.Sprintf("%s@%s", replace, b.K6Version)
Expand Down Expand Up @@ -260,7 +255,13 @@ func (env environment) execGoModRequire(ctx context.Context, modulePath, moduleV
mod += "@latest"
}
cmd := env.newCommand("go", "mod", "edit", "-require", mod)
return env.runCommand(ctx, cmd, env.timeoutGoGet)
err := env.runCommand(ctx, cmd, env.timeoutGoGet)
if err != nil {
return err
}
// tidy the module to ensure go.mod will not have versions such as `latest`
tidyCmd := env.newCommand("go", "mod", "tidy")
return env.runCommand(ctx, tidyCmd, env.timeoutGoGet)
}

type goModTemplateContext struct {
Expand Down

0 comments on commit f080854

Please sign in to comment.