From d36763753cfafbef9f30f3b37e7e2661cb69cdfb Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Thu, 8 Sep 2022 18:03:26 -0500 Subject: [PATCH 1/2] dev: build more stuff with linting turned on as part of `dev lint` This will find more failures in more components. Release note: None --- pkg/cmd/dev/build.go | 4 ++-- pkg/cmd/dev/lint.go | 10 +++++++++- pkg/cmd/dev/testdata/datadriven/lint | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/dev/build.go b/pkg/cmd/dev/build.go index b2b9c1e1cd77..ac460b83c81a 100644 --- a/pkg/cmd/dev/build.go +++ b/pkg/cmd/dev/build.go @@ -88,12 +88,12 @@ var buildTargetMapping = map[string]string{ "goimports": "@com_github_cockroachdb_gostdlib//x/tools/cmd/goimports:goimports", "label-merged-pr": "//pkg/cmd/label-merged-pr:label-merged-pr", "geos": geosTarget, + "langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen", "libgeos": geosTarget, - "obsservice": "//pkg/obsservice/cmd/obsservice", + "obsservice": "//pkg/obsservice/cmd/obsservice:obsservice", "optgen": "//pkg/sql/opt/optgen/cmd/optgen:optgen", "optfmt": "//pkg/sql/opt/optgen/cmd/optfmt:optfmt", "oss": "//pkg/cmd/cockroach-oss:cockroach-oss", - "langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen", "reduce": "//pkg/cmd/reduce:reduce", "roachprod": "//pkg/cmd/roachprod:roachprod", "roachprod-stress": "//pkg/cmd/roachprod-stress:roachprod-stress", diff --git a/pkg/cmd/dev/lint.go b/pkg/cmd/dev/lint.go index 380c6798767e..045a862b7e57 100644 --- a/pkg/cmd/dev/lint.go +++ b/pkg/cmd/dev/lint.go @@ -82,7 +82,15 @@ func (d *dev) lint(cmd *cobra.Command, commandLine []string) error { return err } if !short && filter == "" { - args := []string{"build", "//pkg/cmd/cockroach-short", "--//build/toolchains:nogo_flag"} + args := []string{ + "build", + "//pkg/cmd/cockroach-short", + "//pkg/cmd/dev", + "//pkg/obsservice/cmd/obsservice", + "//pkg/cmd/roachprod", + "//pkg/cmd/roachtest", + "--//build/toolchains:nogo_flag", + } if numCPUs != 0 { args = append(args, fmt.Sprintf("--local_cpu_resources=%d", numCPUs)) } diff --git a/pkg/cmd/dev/testdata/datadriven/lint b/pkg/cmd/dev/testdata/datadriven/lint index f00069b0996b..0c7da9396adb 100644 --- a/pkg/cmd/dev/testdata/datadriven/lint +++ b/pkg/cmd/dev/testdata/datadriven/lint @@ -2,7 +2,7 @@ exec dev lint ---- bazel run --config=test //build/bazelutil:lint -- -test.v -bazel build //pkg/cmd/cockroach-short --//build/toolchains:nogo_flag +bazel build //pkg/cmd/cockroach-short //pkg/cmd/dev //pkg/obsservice/cmd/obsservice //pkg/cmd/roachprod //pkg/cmd/roachtest --//build/toolchains:nogo_flag exec dev lint --short --timeout=5m @@ -24,7 +24,7 @@ exec dev lint --cpus 4 ---- bazel run --config=test //build/bazelutil:lint --local_cpu_resources=4 -- -test.v -bazel build //pkg/cmd/cockroach-short --//build/toolchains:nogo_flag --local_cpu_resources=4 +bazel build //pkg/cmd/cockroach-short //pkg/cmd/dev //pkg/obsservice/cmd/obsservice //pkg/cmd/roachprod //pkg/cmd/roachtest --//build/toolchains:nogo_flag --local_cpu_resources=4 exec dev lint pkg/cmd/dev pkg/spanconfig From b7569233f3ea7d8ca51320228296773edb9f98b1 Mon Sep 17 00:00:00 2001 From: healthy-pod Date: Thu, 8 Sep 2022 15:58:17 -0700 Subject: [PATCH 2/2] dev: ensure libdir is created and populated when running roachprod-stress Previously, `geos libs` were created under the `artifacts` directory. This code change copies them into their own directory. Closes #87643 Release note: None --- dev | 2 +- pkg/cmd/dev/roachprod_stress.go | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dev b/dev index 7236f19945fa..a060e931f1c5 100755 --- a/dev +++ b/dev @@ -8,7 +8,7 @@ fi set -euo pipefail # Bump this counter to force rebuilding `dev` on all machines. -DEV_VERSION=57 +DEV_VERSION=58 THIS_DIR=$(cd "$(dirname "$0")" && pwd) BINARY_DIR=$THIS_DIR/bin/dev-versions diff --git a/pkg/cmd/dev/roachprod_stress.go b/pkg/cmd/dev/roachprod_stress.go index 70adc5e5f7a2..9642f1c356f6 100644 --- a/pkg/cmd/dev/roachprod_stress.go +++ b/pkg/cmd/dev/roachprod_stress.go @@ -12,6 +12,7 @@ package main import ( "fmt" + "path" "path/filepath" "strings" @@ -87,6 +88,7 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error { // List of targets we need to cross-build. crossTargets := []string{testTarget, stressTarget} // Check whether this target depends on libgeos. + dependsOnGeos := false queryArgs := []string{"query", fmt.Sprintf("somepath(%s, //c-deps:libgeos)", testTarget)} queryOutput, err := d.exec.CommandContextSilent(ctx, "bazel", queryArgs...) if err != nil { @@ -94,6 +96,7 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error { } if strings.TrimSpace(string(queryOutput)) != "" { // If the test depends on geos we additionally want to cross-build it. + dependsOnGeos = true crossTargets = append(crossTargets, "//c-deps:libgeos") } @@ -109,24 +112,43 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error { return err } - testTargetBasename := strings.Split(targets[0].fullName, ":")[1] - // Build roachprod-stress and roachprod. - args, buildTargets, err := d.getBasicBuildArgs(ctx, []string{"//pkg/cmd/roachprod-stress"}) + // Build roachprod-stress. + args, roachprodStressTarget, err := d.getBasicBuildArgs(ctx, []string{"//pkg/cmd/roachprod-stress"}) if err != nil { return err } if _, err := d.exec.CommandContextSilent(ctx, "bazel", args...); err != nil { return err } - if err := d.stageArtifacts(ctx, buildTargets); err != nil { + if err := d.stageArtifacts(ctx, roachprodStressTarget); err != nil { return err } + workspace, err := d.getWorkspace(ctx) if err != nil { return err } + + libdir := path.Join(workspace, "artifacts", "libgeos", "lib") + if dependsOnGeos { + if err = d.os.MkdirAll(libdir); err != nil { + return err + } + for _, libWithExt := range []string{"libgeos.so", "libgeos_c.so"} { + src := filepath.Join(workspace, "artifacts", libWithExt) + dst := filepath.Join(libdir, libWithExt) + if err := d.os.CopyFile(src, dst); err != nil { + return err + } + if err := d.os.Remove(src); err != nil { + return err + } + } + } + + testTargetBasename := strings.Split(targets[0].fullName, ":")[1] // Run roachprod-stress. - roachprodStressArgs := []string{cluster, fmt.Sprintf("./%s", pkg), "-testbin", filepath.Join(workspace, "artifacts", testTargetBasename), "-stressbin", filepath.Join(workspace, "artifacts", "stress"), "-libdir", filepath.Join(workspace, "artifacts", "libgeos", "lib")} + roachprodStressArgs := []string{cluster, fmt.Sprintf("./%s", pkg), "-testbin", filepath.Join(workspace, "artifacts", testTargetBasename), "-stressbin", filepath.Join(workspace, "artifacts", "stress"), "-libdir", libdir} roachprodStressArgs = append(roachprodStressArgs, strings.Fields(stressCmdArgs)...) roachprodStressArgs = append(roachprodStressArgs, "--") roachprodStressArgs = append(roachprodStressArgs, testArgs...)