Skip to content

Commit

Permalink
refactor: improve Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
gi8lino committed Feb 4, 2025
1 parent 9945c99 commit 99e0bd8
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,44 @@ VERSION := $(shell awk -F'"' '/const version/{gsub(/^v/, "", $$2); print $$2}' c

.PHONY: test cover clean update patch minor major tag

# Run all unit tests
test:
##@ General

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: download
download: ## Download go packages
go mod download

.PHONY: update-packages
update-packages: ## Update all Go packages to their latest versions
go get -u ./...
go mod tidy

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: test
test: ## Run all unit tests
go test ./... -v -count=1

# Generate and display test coverage
cover:
.PHONY: cover
cover: ## Generate and display test coverage
go test ./cmd/... ./internal/... -count=1 -coverprofile=coverage.out
go tool cover -html=coverage.out

# Clean up generated files
clean:
.PHONY: clean
clean: ## Clean up generated files
rm -f coverage.out coverage.html

# Update dependencies
update:
go get -u ./...
go mod tidy

##@ Versioning

patch: ## Increment the patch version (x.y.Z -> x.y.(Z+1)).
Expand Down

0 comments on commit 99e0bd8

Please sign in to comment.