Skip to content

Commit

Permalink
Merge #137333
Browse files Browse the repository at this point in the history
137333: cmd/dev: add short flag to lint during build r=dt a=dt

Running nogo in every buuld can be very slow so it is common to have config=nolintonbuild set in bazelrc, but it is still handy to be able to quickly run it locally before CI or when CI detect a problem. This adds a shorthand --lint/-l to the 'build' cmd to enable validation during the build process even if the config would normally disable it.

Release note: none.
Epic: none.

Co-authored-by: David Taylor <[email protected]>
  • Loading branch information
craig[bot] and dt committed Dec 12, 2024
2 parents 90678e7 + fb7afda commit 6cb15dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cmd/dev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import (

const (
crossFlag = "cross"
lintFlag = "lint"
cockroachTarget = "//pkg/cmd/cockroach:cockroach"
nogoEnableFlag = "--run_validations"
nogoDisableFlag = "--norun_validations"
geosTarget = "//c-deps:libgeos"
devTarget = "//pkg/cmd/dev:dev"
Expand Down Expand Up @@ -59,6 +61,7 @@ func makeBuildCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Com
RunE: runE,
}
buildCmd.Flags().String(volumeFlag, "bzlhome", "the Docker volume to use as the container home directory (only used for cross builds)")
buildCmd.Flags().BoolP(lintFlag, "l", false, "perform linting (nogo) as part of the build process (i.e. override nolintonbuild config)")
buildCmd.Flags().String(crossFlag, "", "cross-compiles using the builder image (options: linux, linuxarm, macos, macosarm, windows)")
buildCmd.Flags().Lookup(crossFlag).NoOptDefVal = "linux"
buildCmd.Flags().StringArray(dockerArgsFlag, []string{}, "additional arguments to pass to Docker (only used for cross builds)")
Expand Down Expand Up @@ -141,12 +144,16 @@ func (d *dev) build(cmd *cobra.Command, commandLine []string) error {
targets, additionalBazelArgs := splitArgsAtDash(cmd, commandLine)
ctx := cmd.Context()
cross := mustGetFlagString(cmd, crossFlag)
lint := mustGetFlagBool(cmd, lintFlag)
dockerArgs := mustGetFlagStringArray(cmd, dockerArgsFlag)

args, buildTargets, err := d.getBasicBuildArgs(ctx, targets)
if err != nil {
return err
}
if lint {
args = append(args, nogoEnableFlag)
}
args = append(args, additionalBazelArgs...)
configArgs := getConfigArgs(args)

Expand Down

0 comments on commit 6cb15dc

Please sign in to comment.