diff --git a/go.mod b/go.mod index db07bb6dab09..66d92d379025 100644 --- a/go.mod +++ b/go.mod @@ -104,7 +104,7 @@ require ( github.com/shirou/gopsutil/v4 v4.25.5 github.com/sirupsen/logrus v1.9.3 github.com/sivchari/containedctx v1.0.3 - github.com/sonatard/noctx v0.3.4 + github.com/sonatard/noctx v0.3.5 github.com/sourcegraph/go-diff v0.7.0 github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 diff --git a/go.sum b/go.sum index 51a82b62990a..fc048a679f16 100644 --- a/go.sum +++ b/go.sum @@ -535,8 +535,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sonatard/noctx v0.3.4 h1:ZeiM4rEeFTFSie/G5/HD9lHiMpQg/L4fnilaNmFQ2/A= -github.com/sonatard/noctx v0.3.4/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= +github.com/sonatard/noctx v0.3.5 h1:KJmJt2jEXFu2JLlGfjpGNOjyjc4qvfzl4918XJ4Odpc= +github.com/sonatard/noctx v0.3.5/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= diff --git a/scripts/website/dump_info/main.go b/scripts/website/dump_info/main.go index 0d27181270ea..0ce77badad4b 100644 --- a/scripts/website/dump_info/main.go +++ b/scripts/website/dump_info/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "context" "encoding/json" "fmt" "log" @@ -33,7 +34,7 @@ func main() { log.Fatalf("Save default exclusions: %v", err) } - err = saveCLIHelp(filepath.Join("assets", "cli-help.json")) + err = saveCLIHelp(context.Background(), filepath.Join("assets", "cli-help.json")) if err != nil { log.Fatalf("Save CLI help: %v", err) } @@ -139,25 +140,25 @@ func saveDefaultExclusions() error { return saveToJSONFile(filepath.Join("assets", "exclusion-presets.json"), data) } -func saveCLIHelp(dst string) error { - err := exec.Command("make", "build").Run() +func saveCLIHelp(ctx context.Context, dst string) error { + err := exec.CommandContext(ctx, "make", "build").Run() if err != nil { return fmt.Errorf("can't run make build: %w", err) } - lintersOut, err := exec.Command("./golangci-lint", "help", "linters").Output() + lintersOut, err := exec.CommandContext(ctx, "./golangci-lint", "help", "linters").Output() if err != nil { return fmt.Errorf("can't run linters cmd: %w", err) } lintersOutParts := bytes.Split(lintersOut, []byte("\n\n")) - rumCmdHelp, err := getCmdHelp("run") + rumCmdHelp, err := getCmdHelp(ctx, "run") if err != nil { return err } - fmtCmdHelp, err := getCmdHelp("fmt") + fmtCmdHelp, err := getCmdHelp(ctx, "fmt") if err != nil { return err } @@ -171,8 +172,8 @@ func saveCLIHelp(dst string) error { return saveToJSONFile(dst, data) } -func getCmdHelp(name string) (string, error) { - helpCmd := exec.Command("./golangci-lint", name, "-h") +func getCmdHelp(ctx context.Context, name string) (string, error) { + helpCmd := exec.CommandContext(ctx, "./golangci-lint", name, "-h") helpCmd.Env = append(helpCmd.Env, os.Environ()...) help, err := helpCmd.Output() diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index 18b13039a7a9..4c712f9b0638 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -2,6 +2,7 @@ package bench import ( "bytes" + "context" "errors" "fmt" "go/build" @@ -63,7 +64,8 @@ func Benchmark_linters(b *testing.B) { for _, repo := range repos { b.Run(repo.name, func(b *testing.B) { - _ = exec.Command(binName, "cache", "clean").Run() + // TODO(ldez): clean inside go1.25 PR + _ = exec.CommandContext(context.Background(), binName, "cache", "clean").Run() err = os.Chdir(repo.dir) require.NoErrorf(b, err, "can't chdir to %s", repo.dir) @@ -94,7 +96,8 @@ func Benchmark_golangciLint(b *testing.B) { installGolangCILint(b) - _ = exec.Command(binName, "cache", "clean").Run() + // TODO(ldez): clean inside go1.25 PR + _ = exec.CommandContext(context.Background(), binName, "cache", "clean").Run() cases := getAllRepositories(b) @@ -177,7 +180,8 @@ func cloneGithubProject(tb testing.TB, benchRoot, owner, name string) string { if _, err := os.Stat(dir); os.IsNotExist(err) { repo := fmt.Sprintf("https://github.com/%s/%s.git", owner, name) - err = exec.Command("git", "clone", "--depth", "1", "--single-branch", repo, dir).Run() + // TODO(ldez): clean inside go1.25 PR + err = exec.CommandContext(context.Background(), "git", "clone", "--depth", "1", "--single-branch", repo, dir).Run() if err != nil { tb.Fatalf("can't git clone %s/%s: %s", owner, name, err) } @@ -210,7 +214,8 @@ func launch(tb testing.TB, run func(testing.TB, string, []string), args []string func run(tb testing.TB, name string, args []string) { tb.Helper() - cmd := exec.Command(name, args...) + // TODO(ldez): clean inside go1.25 PR + cmd := exec.CommandContext(context.Background(), name, args...) if os.Getenv("PRINT_CMD") == "1" { log.Print(strings.Join(cmd.Args, " ")) } @@ -228,7 +233,8 @@ func run(tb testing.TB, name string, args []string) { func countGoLines(tb testing.TB) int { tb.Helper() - cmd := exec.Command("bash", "-c", `find . -type f -name "*.go" | grep -F -v vendor | xargs wc -l | tail -1`) + // TODO(ldez): clean inside go1.25 PR + cmd := exec.CommandContext(context.Background(), "bash", "-c", `find . -type f -name "*.go" | grep -F -v vendor | xargs wc -l | tail -1`) out, err := cmd.CombinedOutput() if err != nil { @@ -341,7 +347,8 @@ func installGolangCILint(tb testing.TB) { parentPath := findMakefile(tb) - cmd := exec.Command("make", "-C", parentPath, "build") + // TODO(ldez): clean inside go1.25 PR + cmd := exec.CommandContext(context.Background(), "make", "-C", parentPath, "build") output, err := cmd.CombinedOutput() if err != nil { diff --git a/test/testshared/install.go b/test/testshared/install.go index 8eeb7fa8ae3c..d1fd3dcba53c 100644 --- a/test/testshared/install.go +++ b/test/testshared/install.go @@ -1,6 +1,7 @@ package testshared import ( + "context" "fmt" "io" "os" @@ -48,7 +49,8 @@ func InstallGolangciLint(tb testing.TB) string { defer builtLock.Unlock() if !built { - cmd := exec.Command("make", "-C", parentPath, "build") + // TODO(ldez): clean inside go1.25 PR + cmd := exec.CommandContext(context.Background(), "make", "-C", parentPath, "build") output, err := cmd.CombinedOutput() require.NoError(tb, err, "can't install golangci-lint %s", string(output)) diff --git a/test/testshared/integration/fix.go b/test/testshared/integration/fix.go index 75275125faab..3e40263c6aa1 100644 --- a/test/testshared/integration/fix.go +++ b/test/testshared/integration/fix.go @@ -1,6 +1,7 @@ package integration import ( + "context" "os" "os/exec" "path/filepath" @@ -30,7 +31,8 @@ func setupTestFix(t *testing.T) []string { sourcesDir := filepath.Join(testdataDir, "fix") - err := exec.Command("cp", "-R", sourcesDir, tmpDir).Run() + // TODO(ldez): clean inside go1.25 PR + err := exec.CommandContext(context.Background(), "cp", "-R", sourcesDir, tmpDir).Run() require.NoError(t, err) return findSources(t, tmpDir, "in", "*.go") diff --git a/test/testshared/runner.go b/test/testshared/runner.go index 69bb8bac80a7..52606c223d18 100644 --- a/test/testshared/runner.go +++ b/test/testshared/runner.go @@ -1,6 +1,7 @@ package testshared import ( + "context" "os" "os/exec" "path/filepath" @@ -263,8 +264,9 @@ func (r *Runner) Command() *exec.Cmd { runArgs := append([]string{r.command}, r.args...) + // TODO(ldez): clean inside go1.25 PR //nolint:gosec // we don't use user input here - cmd := exec.Command(r.binPath, runArgs...) + cmd := exec.CommandContext(context.Background(), r.binPath, runArgs...) cmd.Env = append(os.Environ(), r.env...) return cmd