Makefile: improve make commands (#1576)

This commit is contained in:
wit liu 2025-10-08 12:26:26 +08:00 committed by GitHub
parent 11e82672fe
commit 92fdd347cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 17 deletions

View file

@ -53,13 +53,13 @@ quick-test: all
lint: ## Run linters. lint: ## Run linters.
$(GORUN) build/ci.go lint $(GORUN) build/ci.go lint
#? check_tidy: Verify go.mod and go.sum by 'go mod tidy' #? tidy: Verify go.mod and go.sum by 'go mod tidy'
check_tidy: ## Run 'go mod tidy'. tidy: ## Run 'go mod tidy'.
$(GORUN) build/ci.go check_tidy $(GORUN) build/ci.go tidy
#? check_generate: Verify everything is 'go generate'-ed #? generate: Verify everything is 'go generate'-ed
check_generate: ## Run 'go generate ./...'. generate: ## Run 'go generate ./...'.
$(GORUN) build/ci.go check_generate $(GORUN) build/ci.go generate
#? fmt: Ensure consistent code formatting. #? fmt: Ensure consistent code formatting.
fmt: fmt:

View file

@ -25,8 +25,8 @@ Usage: go run build/ci.go <command> <command flags/arguments>
Available commands are: Available commands are:
lint -- runs certain pre-selected linters lint -- runs certain pre-selected linters
check_tidy -- verifies that everything is 'go mod tidy'-ed tidy -- verifies that everything is 'go mod tidy'-ed
check_generate -- verifies that everything is 'go generate'-ed generate -- verifies that everything is 'go generate'-ed
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
test [ -coverage ] [ packages... ] -- runs the tests test [ -coverage ] [ packages... ] -- runs the tests
@ -93,10 +93,10 @@ func main() {
doTest(os.Args[2:]) doTest(os.Args[2:])
case "lint": case "lint":
doLint(os.Args[2:]) doLint(os.Args[2:])
case "check_tidy": case "tidy":
doCheckTidy() doTidy()
case "check_generate": case "generate":
doCheckGenerate() doGenerate()
case "xgo": case "xgo":
doXgo(os.Args[2:]) doXgo(os.Args[2:])
default: default:
@ -254,8 +254,8 @@ func doTest(cmdline []string) {
build.MustRun(gotest) build.MustRun(gotest)
} }
// doCheckTidy assets that the Go modules files are tidied already. // doTidy assets that the Go modules files are tidied already.
func doCheckTidy() { func doTidy() {
targets := []string{"go.mod", "go.sum"} targets := []string{"go.mod", "go.sum"}
hashes, err := build.HashFiles(targets) hashes, err := build.HashFiles(targets)
@ -274,9 +274,9 @@ func doCheckTidy() {
fmt.Println("No untidy module files detected.") fmt.Println("No untidy module files detected.")
} }
// doCheckGenerate ensures that re-generating generated files does not cause // doGenerate ensures that re-generating generated files does not cause
// any mutations in the source file tree. // any mutations in the source file tree.
func doCheckGenerate() { func doGenerate() {
var ( var (
cachedir = flag.String("cachedir", "./build/cache", "directory for caching binaries.") cachedir = flag.String("cachedir", "./build/cache", "directory for caching binaries.")
) )