From 2f4754ee7c1501a4e17d611a4bd822d15e0758b8 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Sat, 29 Nov 2025 16:49:50 +0100 Subject: [PATCH] Split make install targets (#5796) --- .woodpecker/test.yaml | 2 +- Makefile | 38 ++++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index 99ff3881d..ef1dc910a 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -73,7 +73,7 @@ steps: lint-license-header: image: *golang_image commands: - - go install github.com/google/addlicense@latest # cspell:words addlicense + - make install-addlicense # cspell:words addlicense - 'addlicense -check -ignore "vendor/**" **/*.go' when: *when diff --git a/Makefile b/Makefile index effc05ec0..9b3e4a6f7 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ vendor: ## Update the vendor directory go mod tidy go mod vendor -format: install-tools ## Format source code +format: install-gofumpt ## Format source code @gofumpt -extra -w . .PHONY: clean @@ -118,15 +118,15 @@ clean-all: clean ## Clean all artifacts rm -rf docs/docs/40-cli.md docs/openapi.json .PHONY: generate -generate: install-tools generate-openapi ## Run all code generations +generate: install-mockery generate-openapi ## Run all code generations mockery CGO_ENABLED=0 go generate ./... -generate-openapi: install-tools ## Run openapi code generation and format it +generate-openapi: ## Run openapi code generation and format it CGO_ENABLED=0 go run github.com/swaggo/swag/cmd/swag fmt --exclude pipeline/rpc/proto CGO_ENABLED=0 go generate cmd/server/openapi.go -generate-license-header: install-tools +generate-license-header: install-addlicense addlicense -c "Woodpecker Authors" -ignore "vendor/**" **/*.go check-xgo: ## Check if xgo is installed @@ -134,33 +134,43 @@ check-xgo: ## Check if xgo is installed $(GO) install src.techknowlogick.com/xgo@latest; \ fi -install-tools: ## Install development tools +install-golangci-lint: @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) ; \ - fi ; \ - hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + fi + +install-gofumpt: + @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION); \ - fi ; \ - hash addlicense > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + fi + +install-addlicense: + @hash addlicense > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install github.com/google/addlicense@latest; \ - fi ; \ - hash mockery > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + fi + +install-mockery: + @hash mockery > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install github.com/vektra/mockery/v3@latest; \ - fi ; \ - hash protoc-gen-go > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + fi + +install-protoc-gen-go: + @hash protoc-gen-go > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest; \ fi ; \ hash protoc-gen-go-grpc > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest; \ fi +install-tools: install-golangci-lint install-gofumpt install-addlicense install-mockery install-protoc-gen-go ## Install development tools + ui-dependencies: ## Install UI dependencies (cd web/; pnpm install --frozen-lockfile) ##@ Test .PHONY: lint -lint: install-tools ## Lint code +lint: install-golangci-lint ## Lint code @echo "Running golangci-lint" golangci-lint run